•
handle [in/out]
– Pointer to Characteristic handle to be changed
•
value [in]
– New value
•
len [in]
– Value length, in bytes
Return
– Execution Status
5.2.2
Sending a Notification (at_ble_notification_send)
Prototype
–
at_ble_status_t at_ble_notification_send(
at_ble_handle_t conn_handle,
at_ble_handle_t attr_handle);
Description
– Sends a Notification
Parameters
–
•
conn_handle[in]
– handle of the connection to be notified
•
attr_handle [in]
– handle of the attribute originating the notification
Return
– Execution Status
5.2.3
Sending Temperature Information Once in Every 10 Seconds to Central
1.
Modify the following “
timer_callback_fn
” callback function from the "
startup_template.c
"
file.
static void timer_callback_fn(void)
{
timer_flag = true;
}
2.
hw_timer_init()
in main routine of "
startup_template.c
" initializes the hardware timer.
3.
If a client (Central) enables the notifications for a server, the server (Peripheral) receives an
AT_BLE_CHARACTERISTIC_CHANGED
event callback, then start the periodic 10 second timer for
sending the notification. Add the following code in previously defined
custom_char_changed_app_event
function.
/* Callback registered for char changed event*/
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;
}
4.
Declare the following
Temperature_value
global variable in
startup_template.c
.
static
uint8_t Temperature_value = 25;
as static.
5.
Add the following
send_temperature_notification
function in
startup_template.c
to
send temperature every 10 seconds.
/* Register GATT callbacks at BLE manager level*/
void send_temperature_notification(void){
/* Register GAP Callbacks */
printf("\n*** Assignment 4.2: Send temperature update notification");
/* Dummy temperature value */
Temperatur+;
ATBTLC1000
Setting up and Handling Custom Service
©
2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 44