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

rd_auth wr_auth flags

Hi, is there a tutorial or more documentation available for explaining the purpose and how to use rd_auth and wr_auth flags? E.g., if I set rd_auth = 1 do I still have to initialize and use read_perm? 

So should rd_auth and wr_auth be used in conjunction with GAP encryption, MITM, and LESC pairing options? Or is rd_auth and wr_auth redundant if I already implemented passkey pairing and GAP encryption & MITM protection? 

It only says in the official documentation that rd_auth is for "Read authorization and value will be requested from the application on every read operation." I also tried looking in this previous post but it was not helpful in answering the specific question about rd_auth and wr_auth. https://devzone.nordicsemi.com/f/nordic-q-a/14258/time-to-understand-read-write-read_perm-write_perm-rd_auth-wr_auth

  • Hi,

    Attribute permissions are explained more in detail in our Characteristic's tutorial: https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial

    Permissions define how you can interact with a specific attribute, whether the attribute should be readable and/or writeable and what kind of authorization is required to do the operations. Before we set read and write permissions for an attribute the Softdevice does not know what to allow and simply denies any reads and writes of the attribute, so you need to set the permissions to be able to read/write at all.

    If set rd_auth/wr_auth =1 the read/write authorization and value will be requested from the application on every read/write operation, this means that the Softdevice will not sent the value to the central automatically but the application needs to give a confirmation to continue with the procedure. See the message sequence chart for GATTS read request with and without authorization.

    Best regards,

    Marjeris

  • Hi in the Characteristics tutorial they say: "you also have the option to define the permissions with associated authorization requirements. For example if you need Man In The Middle protection (MITM) or a passkey to access your attribute." 

    Nordic documentation says that when rd_auth/wr_auth = 1 there is function call sd_ble_gatts_rw_authorize_reply() with either success or failure to respond to the event BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. But the documentation is unclear as to what causes success or failure for the authorization request. 

    I have already successfully enabled MITM and passkey requirement with my code and it worked with rd_auth/wr_auth = 0. When I set rd_auth/wr_auth = 1, reflash code and bond to Nordic peripheral with correct passkey, I try to read and write value to custom characteristic through nrf_connect app. But I get an error 133(0x85) GATT ERROR. This is strange because before when using passkey and rd_auth/wr_auth = 0, I can read and write without any error. 

    So I am still confused as to whether I am supposed to use "rd_auth/wr_auth = 1" for another purpose/case?

Related