How to enable CCCD automatically in NCS(zephry)

Hi

Develop peripherals.nrf devices do slave machines.

Due to project requirements. The standard (notification) operation process needs to be changed (In the absence of binding).The following blogs have confirmed that the project needs can be achieved in the SDK:

https://devzone.nordicsemi.com/f/nordic-q-a/15571/automatically-start-notification-upon-connection-event-manually-write-cccd---short-tutorial-on-notifications#post-id-90507

https://devzone.nordicsemi.com/f/nordic-q-a/63606/enabling-notification-by-default/259329

SDK added as follows:

The SDK test meets the requirements.

But eventually I need to implement this functionality in NCS, so I want to know how to implement it in NCS. Currently, I can't find an API like sd_ble_gatts_sys_attr_set in the NCS list of GATT layer apis:

I need your help. Thank you very much!

Best regards

Stars

  • Hello,
    I am sorry, but we are short staffed this week due to Public Holidays in Norway. We will be back on Monday 22nd and hope to be able to answer all incoming requests within a couple of days, depending on the backlog. I am sorry for the inconvenience.

    Best regards,
    Edvin

  • Hi,

    In the nRF5 SDK bonding was handled by the application, and for bonded devices, the CCCD value is kept across connections. So there was a need for support for this in the SoftDevice APIs. With Zephyr it is different, as bonds are handled in the Bluetooth stack, and therefor there was no need for such an API, and it is not present. Note it is not allowed in Bluetooth to send notifications to a GATT client that has not enabled that in the CCCD.

  • Hi,

    One thing I do know is that the two bond devices can indeed communicate without cccd being enabled. But in the previous implementation method. Without binding, communication can be carried out without enabling CCCD (although this method is not standard, but it can meet the application scenario and is an acceptable way).

    Is there a way to use the protocol stack stack in the SDK in zephyr? The functionality is then implemented through the sd_ble_gatts_sys_attr_set function.

    Best regards

    Stars

  • stars said:
    One thing I do know is that the two bond devices can indeed communicate without cccd being enabled.

    Yes, certainly (by reads and writes), but not by notifications or indications. Or rather, with the SoftDevice it would be possible, but it is not allowed per Bluetooth specification.

    stars said:
    Is there a way to use the protocol stack stack in the SDK in zephyr?

    No, the SoftDevice is not compatible with Zephyr.

  • Hi,

    Thank you very much for your reply.

    After the above communication, can I understand that using zephyr's ble stack, the two bound devices still cannot be set up to transfer data in notifications or indications when the host does not enable cccd?

    If I understand it wrong, it can be done. Can you give me some reference on how to set up auto-enable cccd when there is binding? Thank you very much!

    Best regards

    Stars

Related