Custom Serial Chat Profile.
Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.
#include "at_ble_api.h"
Data Structures | |
struct | app_csc_data |
struct | csc_report_ntf |
SPOG report notification or indication, notify to user. More... | |
Macros | |
#define | ADV_DATA_128_UUID_TYPE (0x07) |
Advertisement 128bit UUID type. More... | |
#define | ADV_DATA_APPEARANCE_TYPE (0x19) |
Advertisement appearance type. More... | |
#define | ADV_DATA_NAME_DATA ("AT-CSC") |
Advertisement name. More... | |
#define | ADV_DATA_NAME_LEN (6) |
Advertisement data name length. More... | |
#define | ADV_DATA_NAME_TYPE (0x09) |
Advertisement data type. More... | |
#define | ADV_TYPE_LEN (0x01) |
Advertisement type length. More... | |
#define | APP_CSC_ADV_TIMEOUT (1000) |
APP_SPOG_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x3FFF in seconds, 0x0000 disables time-out. More... | |
#define | APP_CSC_FAST_ADV (100) |
APP_SPOG_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s). More... | |
#define | AT_DISCOVER_SUCCESS (10) |
Discovery success status. More... | |
#define | CSC_UUID_128_LEN (16) |
Custom serial chat UUID length. More... | |
#define | END_HANDLE (0xffff) |
#define | SCAN_RESP_LEN (10) |
scan_resp_len is the length of the scan response data More... | |
#define | START_HANDLE (0x0001) |
start and end handle More... | |
Typedefs | |
typedef struct app_csc_data | app_csc_data_t |
typedef struct csc_report_ntf | csc_report_ntf_t |
SPOG report notification or indication, notify to user. More... | |
typedef void(* | recv_ntf_callback_t )(csc_report_ntf_t *) |
Receive notification callback. More... | |
Enumerations | |
enum | ble_discovery_role { DISCOVER_IDLE = 0, DISCOVER_SERVICE, DISCOVER_INCLUDE_SERVICE, DISCOVER_CHARACTERISTIC, DISCOVER_DESCRIPTOR, DISCOVER_COMPLETED } |
type of attribute discovery More... | |
Functions | |
void | csc_prf_buf_init (uint8_t *databuf, uint16_t datalen) |
CSC profile buffer initialization. More... | |
at_ble_status_t | csc_prf_char_changed_handler (at_ble_characteristic_changed_t *char_handle) |
Service characteristic change handler function. More... | |
void | csc_prf_characteristic_found_handler (at_ble_characteristic_found_t *params) |
Handler for characteristic found. More... | |
void | csc_prf_connected_state_handler (at_ble_connected_t *params) |
Handler for connection event. More... | |
void | csc_prf_descriptor_found_handler (at_ble_descriptor_found_t *params) |
Handler for descriptor found. More... | |
void | csc_prf_dev_adv (void) |
CSC profile advertisement function. More... | |
at_ble_status_t | csc_prf_disconnect_event_handler (at_ble_disconnected_t *disconnect) |
CSC device disconnected handler function. More... | |
void | csc_prf_discovery_complete_handler (at_ble_discovery_complete_t *params) |
Handler for discovery complete. More... | |
void | csc_prf_init (void *param) |
CSC profile initialization function. More... | |
void | csc_prf_notification_handler (at_ble_notification_received_t *params) |
Handler for notification. More... | |
void | csc_prf_send_data (uint8_t *databuf, uint16_t datalen) |
CSC profile send data function. More... | |
void | csc_prf_service_found_handler (at_ble_primary_service_found_t *params) |
Handler for service found. More... | |
void | csc_prf_write_notification_handler (void *param) |
Handler for configuring the notification for remote device. More... | |
void | notify_recv_ntf_handler (recv_ntf_callback_t recv_ntf_fn) |
Function call the user defined callback for sending the receive data. More... | |
#define ADV_DATA_128_UUID_TYPE (0x07) |
Advertisement 128bit UUID type.
Referenced by csc_prf_dev_adv().
#define ADV_DATA_APPEARANCE_TYPE (0x19) |
Advertisement appearance type.
#define ADV_DATA_NAME_DATA ("AT-CSC") |
Advertisement name.
Referenced by csc_prf_dev_adv().
#define ADV_DATA_NAME_LEN (6) |
Advertisement data name length.
Referenced by csc_prf_dev_adv().
#define ADV_DATA_NAME_TYPE (0x09) |
Advertisement data type.
Referenced by csc_prf_dev_adv().
#define ADV_TYPE_LEN (0x01) |
Advertisement type length.
#define APP_CSC_ADV_TIMEOUT (1000) |
APP_SPOG_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x3FFF in seconds, 0x0000 disables time-out.
Referenced by csc_prf_dev_adv(), and csc_prf_disconnect_event_handler().
#define APP_CSC_FAST_ADV (100) |
APP_SPOG_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s).
Referenced by csc_prf_dev_adv(), and csc_prf_disconnect_event_handler().
#define AT_DISCOVER_SUCCESS (10) |
Discovery success status.
#define CSC_UUID_128_LEN (16) |
Custom serial chat UUID length.
Referenced by csc_prf_connected_state_handler(), csc_prf_dev_adv(), and csc_serv_init().
#define END_HANDLE (0xffff) |
Referenced by csc_prf_connected_state_handler().
#define SCAN_RESP_LEN (10) |
scan_resp_len is the length of the scan response data
#define START_HANDLE (0x0001) |
start and end handle
Referenced by csc_prf_connected_state_handler().
typedef struct app_csc_data app_csc_data_t |
typedef struct csc_report_ntf csc_report_ntf_t |
SPOG report notification or indication, notify to user.
typedef void(* recv_ntf_callback_t)(csc_report_ntf_t *) |
Receive notification callback.
enum ble_discovery_role |
void csc_prf_buf_init | ( | uint8_t * | databuf, |
uint16_t | datalen | ||
) |
CSC profile buffer initialization.
[in] | databuf | Initialization data pointer |
[in] | datalen | Data length |
CSC profile buffer initialization.
References app_csc_data::buff_len, and app_csc_data::buff_ptr.
at_ble_status_t csc_prf_char_changed_handler | ( | at_ble_characteristic_changed_t * | change_char | ) |
Service characteristic change handler function.
Service characteristic change handler function.
References AT_BLE_SUCCESS.
void csc_prf_characteristic_found_handler | ( | at_ble_characteristic_found_t * | params | ) |
Handler for characteristic found.
[in] | characteristic | found event parameter containing details about the characteristic found |
Handler for characteristic found.
References app_csc_data::csc_char, DISCOVER_DESCRIPTOR, and app_csc_data::discover_role.
void csc_prf_connected_state_handler | ( | at_ble_connected_t * | params | ) |
Handler for connection event.
[in] | connected | event parameter containing details like handle |
Handler for connection event.
References at_ble_primary_service_discover_by_uuid(), AT_BLE_SUCCESS, AT_BLE_UUID_128, app_csc_data::conn_params, app_csc_data::csc_serv, CSC_SERVICE_UUID, CSC_UUID_128_LEN, DBG_LOG, app_csc_data::devicedb, app_csc_data::discover_role, DISCOVER_SERVICE, END_HANDLE, at_ble_connected_t::handle, at_ble_primary_service_found_t::service_uuid, START_HANDLE, status, at_ble_uuid_t::type, and at_ble_uuid_t::uuid.
void csc_prf_descriptor_found_handler | ( | at_ble_descriptor_found_t * | params | ) |
Handler for descriptor found.
[in] | descriptor | found event parameter containing details about the descriptor found |
Handler for descriptor found.
References app_csc_data::csc_desc, DISCOVER_IDLE, and app_csc_data::discover_role.
void csc_prf_dev_adv | ( | void | ) |
CSC profile advertisement function.
CSC profile advertisement function.
References ADV_DATA_128_UUID_TYPE, ADV_DATA_NAME_DATA, ADV_DATA_NAME_LEN, ADV_DATA_NAME_TYPE, ADV_TYPE_LEN, APP_CSC_ADV_TIMEOUT, APP_CSC_FAST_ADV, at_ble_adv_data_set(), AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_GAP_PERIPHERAL_SLV, at_ble_set_dev_config(), AT_BLE_SUCCESS, CSC_SERVICE_UUID, CSC_UUID_128_LEN, DBG_LOG, NULL, and SCAN_RESP_LEN.
at_ble_status_t csc_prf_disconnect_event_handler | ( | at_ble_disconnected_t * | disconnect | ) |
CSC device disconnected handler function.
CSC device disconnected handler function.
References ALL_UNUSED, APP_CSC_ADV_TIMEOUT, APP_CSC_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_GAP_PERIPHERAL_SLV, at_ble_set_dev_config(), AT_BLE_SUCCESS, DBG_LOG, app_csc_data::devicedb, and NULL.
void csc_prf_discovery_complete_handler | ( | at_ble_discovery_complete_t * | params | ) |
Handler for discovery complete.
[in] | discovery | complete event parameter containing details about the descriptor found |
Handler for discovery complete.
References at_ble_characteristic_discover_all(), at_ble_descriptor_discover_all(), AT_BLE_DISCOVERY_SUCCESS, AT_BLE_SUCCESS, at_ble_primary_service_found_t::conn_handle, at_ble_characteristic_found_t::conn_handle, app_csc_data::conn_params, app_csc_data::csc_char, app_csc_data::csc_serv, DBG_LOG, DBG_LOG_DEV, app_csc_data::devicedb, DISCOVER_CHARACTERISTIC, DISCOVER_COMPLETED, DISCOVER_DESCRIPTOR, DISCOVER_IDLE, app_csc_data::discover_role, at_ble_primary_service_found_t::end_handle, at_ble_connected_t::handle, at_ble_primary_service_found_t::start_handle, at_ble_discovery_complete_t::status, and at_ble_characteristic_found_t::value_handle.
void csc_prf_init | ( | void * | param | ) |
CSC profile initialization function.
CSC profile initialization function.
References ALL_UNUSED, app_csc_data::buff_len, app_csc_data::buff_ptr, and csc_serv_init().
void csc_prf_notification_handler | ( | at_ble_notification_received_t * | params | ) |
Handler for notification.
Handler for notification.
References at_ble_notification_received_t::char_len, at_ble_notification_received_t::char_value, csc_report_ntf::conn_handle, at_ble_notification_received_t::conn_handle, csc_report_ntf::recv_buff, csc_report_ntf::recv_buff_len, and recv_ntf_cb.
void csc_prf_send_data | ( | uint8_t * | databuf, |
uint16_t | datalen | ||
) |
CSC profile send data function.
[in] | databuf | Data buffer send to remote device |
[in] | datalen | Data length |
CSC profile send data function.
References app_csc_data::buff_len, app_csc_data::conn_params, csc_serv_send_data(), and at_ble_connected_t::handle.
void csc_prf_service_found_handler | ( | at_ble_primary_service_found_t * | params | ) |
Handler for service found.
[in] | service | found event parameter containing details about the service found |
Handler for service found.
References app_csc_data::csc_serv, DISCOVER_CHARACTERISTIC, and app_csc_data::discover_role.
void csc_prf_write_notification_handler | ( | void * | param | ) |
Handler for configuring the notification for remote device.
Handler for configuring the notification for remote device.
References at_ble_characteristic_write(), AT_BLE_FAILURE, at_ble_descriptor_found_t::conn_handle, app_csc_data::csc_desc, DBG_LOG, at_ble_descriptor_found_t::desc_handle, and UNUSED.
void notify_recv_ntf_handler | ( | recv_ntf_callback_t | recv_ntf_fn | ) |
Function call the user defined callback for sending the receive data.
Function call the user defined callback for sending the receive data.
References recv_ntf_cb.