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

How do I add authorization on read and write characteristics?

I have a created a custom service and a custom characteristics. The characteristics has both read and write properties.  Now I want to authorize the read and write opearations . I have already aded these lines in my code. 

ble_attr_md.rd_auth = 1;
ble_attr_md.wr_auth = 1;

But I am unable to handle the events for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. Please let me know how to handle these events and how and where to set the passwords. I am usig SDK_v16.0 and nRF52832 DK.
Please provide any code example if u have any.
Thanks ..!!

 

  • But I am unable to handle the events for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. Please let me know how to handle these events and how and where to set the passwords. I am usig SDK_v16.0 and nRF52832 DK.
    Please provide any code example if u have any.

    Settings those values to 1 is the only extra thing to initialize the attribute with rd and write authorize flags.

    After that you need to handle the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST when there is an access to the attribute as shown here and here. Unfortunately we do not have any direct example to show this in our sDK

Related