This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How can I enable gatt_cccd notification automatically?

I've searched for enabling notification, but there are some points that I can't understand.

GATT characteristic attributes and characteristic cccd values are dedicated to GATT_S.

Q1. To Enable my GATT_S characteristic notification, which device is responsible for enabling this? (automatically)

-> does GATT_C have to enable it just after db_search assigns handle ?
(like Central device set's connection interval update duration just after establish connection with peripheral)

-> or GATT_S have to enable it just after GATT_C has connected?

Q2. If both can do, how can I accomplish it? (automatically)

-> if GATT_C is responsible for enabling notification, How can I enable notification?
(In this case, Just like MCP connects device and enable services -> I really want to know how to accomplish this MCP's enable services in my Firmware code. S130)

-> if GATT_S is responsible for enabling notification, How can I enable notification?

Q3. I've actually find for ble_app_hrs_rscs_relay nRF5_SDK_12.2.0\examples\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay

cause this example automatically enable's peripheral notification and routes peripheral's data to it's connected Central.

But In this example, I really can't find any code that enables notification automatically.

I thought there might be any single code such as sd_ble_gatts_sys_attr_set() or sd_ble_gatts_value_set() but, there wern't such code that enable's notification.

how this example enable's notification and automatically routes?

(I'm using nrf51, nrf51-dk, s130, sdk12.2.0)

(ps. IS there any appropriate template or example for this notification enabling?)

  • 1 and 2. The gatt client is responsible for enabling notifications. If you don't bond this has to be done on every reconnect. But when reconnecting to a bonded peer the cccd state has to be restored, so no need to enable notifications again.

    3: there is a function called cccd_configure, this is called from the (rscs_c_evt_handler, see ble_rscs_c_rsc_notif_enable) or the (hrs_c_evt_handler, see ble_hrs_c_hrm_notif_enable) this will be called after the particular service is discovered on the peer.

Related