Custom Serial Chat Profile.
Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "string.h"
#include "ble_utils.h"
#include "ble_manager.h"
#include "cscp.h"
#include "cscs.h"
Functions | |
void | csc_prf_buf_init (uint8_t *databuf, uint16_t datalen) |
buffer initialization function More... | |
at_ble_status_t | csc_prf_char_changed_handler (at_ble_characteristic_changed_t *change_char) |
characteristic change handler function More... | |
void | csc_prf_characteristic_found_handler (at_ble_characteristic_found_t *params) |
characteristic found handler invoked by ble manager More... | |
void | csc_prf_connected_state_handler (at_ble_connected_t *params) |
Connection handler invoked by ble manager. More... | |
void | csc_prf_descriptor_found_handler (at_ble_descriptor_found_t *params) |
client descriptor found handler invoked by ble manager More... | |
void | csc_prf_dev_adv (void) |
device advertisement handler function More... | |
at_ble_status_t | csc_prf_disconnect_event_handler (at_ble_disconnected_t *disconnect) |
device disconnected handler function More... | |
void | csc_prf_discovery_complete_handler (at_ble_discovery_complete_t *params) |
Discovery Complete handler invoked by ble manager. More... | |
void | csc_prf_init (void *param) |
profile initialization function More... | |
void | csc_prf_notification_handler (at_ble_notification_received_t *params) |
invoked by ble manager on receiving notification More... | |
void | csc_prf_send_data (uint8_t *databuf, uint16_t datalen) |
profile send data function More... | |
void | csc_prf_service_found_handler (at_ble_primary_service_found_t *params) |
Service found handler invoked by ble manager. More... | |
void | csc_prf_write_notification_handler (void *param) |
invoked by ble manager for setting the notification More... | |
void | notify_recv_ntf_handler (recv_ntf_callback_t recv_ntf_fn) |
to user about the new data received More... | |
Variables | |
app_csc_data_t | app_csc_info |
recv_ntf_callback_t | recv_ntf_cb |
uint8_t | scan_rsp_data [SCAN_RESP_LEN] = {0x09,0xff, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8} |
void csc_prf_buf_init | ( | uint8_t * | databuf, |
uint16_t | datalen | ||
) |
buffer initialization function
CSC profile buffer initialization.
Referenced by ble_csc_init(), and main().
at_ble_status_t csc_prf_char_changed_handler | ( | at_ble_characteristic_changed_t * | change_char | ) |
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 | ) |
characteristic found handler invoked by ble manager
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 | ) |
Connection handler invoked by ble manager.
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 | ) |
client descriptor found handler invoked by ble manager
Handler for descriptor found.
References app_csc_data::csc_desc, DISCOVER_IDLE, and app_csc_data::discover_role.
void csc_prf_dev_adv | ( | void | ) |
device advertisement handler function
CSC profile advertisement function.
Referenced by app_disconnected_event_handler(), and main().
at_ble_status_t csc_prf_disconnect_event_handler | ( | at_ble_disconnected_t * | disconnect | ) |
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 | ) |
Discovery Complete handler invoked by ble manager.
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 | ) |
void csc_prf_notification_handler | ( | at_ble_notification_received_t * | params | ) |
invoked by ble manager on receiving 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 | ||
) |
void csc_prf_service_found_handler | ( | at_ble_primary_service_found_t * | params | ) |
Service found handler invoked by ble manager.
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 | ) |
invoked by ble manager for setting the notification
Handler for configuring the notification for remote device.
void notify_recv_ntf_handler | ( | recv_ntf_callback_t | recv_ntf_fn | ) |
to user about the new data received
Function call the user defined callback for sending the receive data.
Referenced by ble_csc_init(), and main().
app_csc_data_t app_csc_info |
recv_ntf_callback_t recv_ntf_cb |
Referenced by csc_prf_notification_handler(), and notify_recv_ntf_handler().
uint8_t scan_rsp_data[SCAN_RESP_LEN] = {0x09,0xff, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8} |