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

Question about read operation

Hello! I want to ask about read operation on nrf51822. In your examples, as I understand, BT stack handles Read Request automatically and then sends Read Response. The value that I try to read is Attribute in Service Table (for example only read permission without notify/indicate). To keep this value actual I must call sd_ble_gatts_value_set() when it changes. Can I set attribute value only during processing Read Request? Because I don't want to track all the time this value. I only need send actual value in Read Response after Read Request. Thank you for answer!

Artem Zemlyanuklhin Woodenshark

Parents
  • Hi there,

    Yes, you can.

    You can use the authorization mechanism on any particular attribute to achieve this. Set the read authorization bit (rd_auth in ble_gatts_attr_md_t) when adding your characteristic to the attribute table and you will get a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event every time a remote peer tries to read that characteristic, and you can reply by calling the sd_ble_rw_authorize_reply() with the value you want.

    Refer to the SoftDevice documentation for further details.

    Regards,

    Carles

Reply
  • Hi there,

    Yes, you can.

    You can use the authorization mechanism on any particular attribute to achieve this. Set the read authorization bit (rd_auth in ble_gatts_attr_md_t) when adding your characteristic to the attribute table and you will get a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event every time a remote peer tries to read that characteristic, and you can reply by calling the sd_ble_rw_authorize_reply() with the value you want.

    Refer to the SoftDevice documentation for further details.

    Regards,

    Carles

Children
Related