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

When to enable notifications, when using secure bonding and Pairing?

Hi,

nRF52 SDK Version: 16.0

Example: examples/ble_central_and_peripheral/experimental/ble_app_multirole_lesc

File: main.c

I made two different binaries of this code:

  1. Works as Peripheral (Commented scan start related stuff)
  2. Works as Central      (Commented advertising start related stuff)

I got them paired by pressing 'Button 1'. After this when I pressed 'Button 1' on peripheral device to send out notification, it did not work.

Error code is 'BLE_ERROR_GATTS_SYS_ATTR_MISSING'. I went trough this thread related to the mentioned error.

But when I reconnected them, and it worked, was able to send and receive notifications.

So after looking up, what I found out is, In Central, if the notifications is enabled before the bonding data is stored in flash, it is causing the error.

In Central I enabled notification after pressing the `Button 3` and was able to send/receive the notification.

In example, notifications are enabled in event 'BLE_HRS_C_EVT_DISCOVERY_COMPLETE'. On first connection, bonding data is not stored in flash so, we get the error. But on next connection it works because notifications are enabled after the flash update logs.

Now I worked around by putting notifications on button press, but I want to start notifications after the bonding data is stored in flash.

I can do this by using a timer to delay enabling notifications. But I would like to know if there is any event which would tell that bonding is complete and now I can enable the notifications.

-Shubham

Parents Reply Children
No Data
Related