I have custom service, where I have declared 2 handles inside BLE Service structure, one for button action and the other for custom battery ADC measurement, each identified by its characteristic's UUID:
ble_gatts_char_handles_t button_char_handles; /**< Handles related to the Button Characteristic. */
ble_gatts_char_handles_t battery_char_handles; /**< Handles related to the LiPo Characteristic. */
I successfully initialize both handles and add them to my service. Now I like to send regular updates only to battery characteristic after BLE client (=my phone) connects, therefore I added app_timer, which repeatedly fires each n seconds:
err_code = app_timer_start(m_start_sending_data_timer_id, START_SENDING_DATA_DELAY, NULL);
APP_ERROR_CHECK(err_code);
...and sends 4-byte long float inside BLE_GATT_HVX_NOTIFICATION:
uint32_t ble_send_on_battery_level_change(ble_skiwatt_t * p_skiwatt, float voltage)
{
ble_gatts_hvx_params_t params;
uint16_t len = sizeof(voltage);
memset(¶ms, 0, sizeof(params));
params.type = BLE_GATT_HVX_NOTIFICATION;
params.handle = p_skiwatt->battery_char_handles.value_handle;
params.p_data = (uint8_t*)&voltage;
params.p_len = &len;
return (sd_ble_gatts_hvx(p_skiwatt->conn_handle, ¶ms));
}
Whatsoever, if I connect my board with "Android nRF Connect APP" on my phone, I get NRF ERROR 0x3401 in case I do not set gatt.setCharacteristicNotification() for this characteristic on my phone BEFORE first notification takes place. Therefore, I wait for GATT Client Event BLE_GATTC_EVT_CHAR_DISC_RSP (0x50) in main.c inside function static void on_ble_evt(ble_evt_t * p_ble_evt), before start sending notification packets.
Now I wonder:
how can I detect for which handle (button_char_handles or battery_char_handles) the notification status was changed?