hi, I an trying to enable notification from server. According to spec. i have to write 0x01 to the CCCD handle in heart rate characteristic in ble_app_hrs. In the BLE_GATTS_EVT_WRITE event they have called a fn on_hrm_cccd_write().
static void on_hrm_cccd_write(ble_hrs_t * p_hrs, ble_gatts_evt_write_t * p_evt_write)
{
if (p_evt_write->len == 2)
{
// CCCD written, update notification state
if (p_hrs->evt_handler != NULL)
{
ble_hrs_evt_t evt;
if (ble_srv_is_notification_enabled(p_evt_write->data))
{
evt.evt_type = BLE_HRS_EVT_NOTIFICATION_ENABLED;
}
else
{
evt.evt_type = BLE_HRS_EVT_NOTIFICATION_DISABLED;
}
p_hrs->evt_handler(p_hrs, &evt);
}
}
}
But in the init function ble_hrs_init, p_hrs->evt_handler is set to NULL. And I could not find anywhere the handler is set. Then how the event handler specified in the last statement get called? Where is the actual write to CCCD is implemented? Am I making any wrong assumptions? I think I am missing something. Can anybody help me to find where I made mistake??
Thanks in advance.