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

about BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event

Hi,

My application has several characteristics that require read/write authorization. But for some peer I only want them to have access to some certain characteristics (not all). So is there anywhere in the ble event that I can check for which characteristic they are requesting reading, and how should I accept/reject the request properly?

Thanks for any help!

Parents
  • All the information is in the request, look up the ble_gatts_evt_read_t structure in the documentation to see all the fields. If you have an event pointer for a rw auth event corresponding to a read rw authorize request, evt_ptr, the stuff you want is at

    evt_ptr->gatts_evt.authorize_request.read.context
    

    you can also get handle as well as context, which is what I use to figure out what's being requested as I know which handle -> which value. The context will give you the actual uuids and other information about the characteristic. It's all there.

    to accept/reject you fill in a ble_gatts_rw_authorize_reply_params_t structure with the correct type (read) and fill the read.gatt_status field in with BLE_GATT_STATUS_SUCCESS to allow or BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED to disallow, then call sd_ble_gatts_rw_authorize_reply() to send it.

    Remember to memset the structure to zero to start with so all it's doing is sending back the reply, I've forgotten that in the past and bad things have happened!

Reply
  • All the information is in the request, look up the ble_gatts_evt_read_t structure in the documentation to see all the fields. If you have an event pointer for a rw auth event corresponding to a read rw authorize request, evt_ptr, the stuff you want is at

    evt_ptr->gatts_evt.authorize_request.read.context
    

    you can also get handle as well as context, which is what I use to figure out what's being requested as I know which handle -> which value. The context will give you the actual uuids and other information about the characteristic. It's all there.

    to accept/reject you fill in a ble_gatts_rw_authorize_reply_params_t structure with the correct type (read) and fill the read.gatt_status field in with BLE_GATT_STATUS_SUCCESS to allow or BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED to disallow, then call sd_ble_gatts_rw_authorize_reply() to send it.

    Remember to memset the structure to zero to start with so all it's doing is sending back the reply, I've forgotten that in the past and bad things have happened!

Children
Related