} else {
printf("\n*** Assignment 4.1:Sending Notification over the air failed");
}
return AT_BLE_SUCCESS;
}
static at_ble_status_t custom_char_changed_app_event(void *param)
{
at_ble_characteristic_changed_t *char_changed_param_handle = (at_ble_characteristic_changed_t
*)param;
if((environment_service_characs[0].client_config_handle == char_changed_param_handle-
>char_handle) && (char_changed_param_handle->char_new_value[0]))
{
timer_flag = false;
hw_timer_start(10);
printf("\n*** Assignment 4.1:Characteristic changed event");
}
return AT_BLE_SUCCESS;
}
static const ble_gatt_server_event_cb_t app_gatt_server_handle = {
.notification_confirmed= custom_notification_confirmation_handler,
.characteristic_changed = custom_char_changed_app_event,
};
/* Register GATT callbacks at BLE manager level*/
void register_gatt_server_callbacks(void){
/* Register GAP Callbacks */
printf("\n*** Assignment 4.1: Register GATT Server callbacks");
ble_status = ble_mgr_events_callback_handler(REGISTER_CALL_BACK,\
BLE_GATT_SERVER_EVENT_TYPE,&app_gatt_server_handle);
if (ble_status != true)
printf("\n##Error when Registering ATBTLC1000 callbacks");
}
void start_advertisement (void){
printf("\n*** Assignment 2.1: Start Advertisement");
/*Set advertisement data*/
ble_status = at_ble_adv_data_set(adv_data,sizeof(adv_data), NULL, 0);
/*Start Advertisement*/
ble_status = at_ble_adv_start(AT_BLE_ADV_TYPE_UNDIRECTED,\
AT_BLE_ADV_GEN_DISCOVERABLE,NULL,AT_BLE_ADV_FP_ANY,1600,655,0);
if(ble_status != AT_BLE_SUCCESS)
printf("\n*** Failed to start advertisement");
}
/* 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;
}
/* 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;
}
static const ble_gap_event_cb_t app_gap_handle = {
.connected = ble_connected_cb, // AT_BLE_CONNECTED
.disconnected = ble_disconnected_cb, // AT_BLE_DISCONNECTED
};
/* Register GAP callbacks at BLE manager level*/
void register_btlc1000_callbacks(void){
ATBTLC1000
Appendix B: Software Solution - Custom Service
©
2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 50