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

Why can notifications get sent before they are enabled if devices have been previously Bonded?

I'm developing a Peripheral with a rather intricate connection process and doing a lot of testing.

I find that if a Central connects, and then the Peripheral tries to send a notification via sd_ble_gatts_hvx() before the Central has enabled notifications, and before it has ever Bonded with that Central, the call fails with BLE_ERROR_GATTS_SYS_ATTR_MISSING.

However, if the devices have previously Bonded the Central immediately encrypts the link once it connects. Then if the Peripheral tries to send the notification before the Central enables notifications, the call succeeds! I've confirmed this with a Bluetooth sniffer.

Is this expected behavior for the SoftDevice? What information is used to allow the SD to not return an error in the second case?

I am using s132 v5.1.0, SDK v14.2, nRF52832.

  • The server needs to remember if a bonded client has enabled notifications earlier. So if the central left the notification enabled when it last disconnected, then it will be enabled automatically upon re-connecting.

    Here is the relevant snippet from the BLE core specification:

    The Client Characteristic Configuration descriptor value shall be
    persistent across connections for bonded devices. The Client Characteristic
    Configuration descriptor value shall be set to the default value at each
    connection with non-bonded devices.

Related