ble_event_callback_t conn_parameter_update_done;
/// Connection parameter update request from peer device. Refer \ref
at_ble_conn_param_update_request_t
ble_event_callback_t conn_param_update_request;
/// Pair complete event as part of end of pairing process. Refer \ref at_ble_pair_done_t
ble_event_callback_t pair_done;
/// Pair request event from Central device. Refer \ref at_ble_pair_request_t
ble_event_callback_t pair_request;
/// Slave security request received from peer Peripheral device. Refer \ref
at_ble_slave_sec_request_t
ble_event_callback_t slave_sec_request;
/// Pair Key request event from Peer central device. Refer \ref at_ble_pair_key_request_t
ble_event_callback_t pair_key_request;
/// encryption request comes from the peer device. Needs to supply the bonding information,
which is stored earlier \ref at_ble_encryption_request_t
ble_event_callback_t encryption_request;
/// encryption status changed event received from SMP, once the encryption is started \ref
at_ble_encryption_status_changed_t
ble_event_callback_t encryption_status_changed;
/// Event triggered once the Resolve random address is resolved using supplied IRK's. \ref
at_ble_resolv_rand_addr_status_t
ble_event_callback_t resolv_rand_addr_status;
/// Event is triggered once the connection signature information indication received. \ref
at_ble_sign_counter_t
ble_event_callback_t sign_counters_ind;
/// Peer attribute information indication received Event. \ref at_ble_peer_att_info_ind_t
ble_event_callback_t peer_att_info_ind;
/// Peer device channel map received indication. \ref at_ble_channel_map_t
ble_event_callback_t con_channel_map_ind;
}ble_gap_event_cb_t;
Note:
Callback definition is application-specific. If the application layer requires a specific event callback,
then the specific member of the structure is to be assigned with the address of the callback function.
In this assignment, two callback functions on "Connected" and "Disconnected" GAP events are used.
This allows the application to restart the advertising process on "Disconnect", manage connection
information, and start/stop of sensor data update.
3.2.1
Handling of "Connected" and "Disconnected" GAP Events
1.
Open the
startup_template.c
file.
2.
Define the following software flags as global variables in
startup_template.c
file.
volatile
bool timer_flag = false;
and
volatile bool connected_flag = false
.
3.
Declare and implement the following "
ble_connected_cb
" function in the
"
startup_template.c
" file.
/* Callback registered for AT_BLE_CONNECTED event*/
static at_ble_status_t
ble_connected_cb
(void *param)
{
printf("\n*** Assignment 2.2: Application connected ");
connected_flag = true;
ALL_UNUSED(param);
return AT_BLE_SUCCESS;
}
4.
Declare and implement the following "
ble_disconnected_cb
" function in
"
startup_template.c
" file.
/* Callback registered for AT_BLE_DISCONNECTED event */
static at_ble_status_t ble_disconnected_cb (void *param)
{
printf("\n*** Assignment 2.2: Application disconnected ");
connected_flag = false;
start_advertisement();
ALL_UNUSED(param);return AT_BLE_SUCCESS;
}
ATBTLC1000
Establishing Connection with Central Device
©
2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 27