5.
Declare the following static GAP callback structure in “
startup_template.c
” file.
static const ble_gap_event_cb_t app_gap_handle = {
.connected = ble_connected_cb, // AT_BLE_CONNECTED
.disconnected = ble_disconnected_cb, // AT_BLE_DISCONNECTED
};
6.
Add the following "
register_btlc1000_callbacks
" function in "
startup_template.c
".
/* Register GAP callbacks at BLE manager level*/
void register_btlc1000_callbacks(void){
/* Register GAP Callbacks */
printf("\n*** Assignment 2.2: Register ATBTLC1000 callbacks");
ble_status = ble_mgr_events_callback_handler(REGISTER_CALL_BACK,\
BLE_GAP_EVENT_TYPE,&app_gap_handle);
if (ble_status != true)
printf("\n##Error when Registering ATBTLC1000 callbacks");
}
7.
Add the "
register_btlc1000_callbacks
" function call prior to start advertisement in the
application main routine.
int main(void)
{
#if SAMG55 || SAM4S
/* Initialize the SAM system. */
sysclk_init();
board_init();
#elif SAM0
system_init();
#endif
/* Initialize serial console */
serial_console_init();
/* Hardware timer */
hw_timer_init();
/* button initialization */
button_init();
hw_timer_register_callback(timer_callback_fn);
DBG_LOG("Initializing BLE Application");
/* initialize the BLE chip and Set the Device Address */
ble_device_init(NULL);
/* Register ATBTLC1000 Gap Callbacks */
register_btlc1000_callbacks ( ) ;
/* Start Advertising process */
start_advertisement();
/* Register Primary/Included service in case of GATT Server */
while(true)
{
/* Write application task */
}
}
8.
Add the "
ble_event_task
" function call in the project main loop to handle the different incoming
events from ATBTLC1000.
while(true){
ble_event_task();
}
}
9.
Press "
" button <F7> to compile the project and verify that no build error appear in the Atmel
Studio output window.
ATBTLC1000
Establishing Connection with Central Device
©
2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 28