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

Can call to sd_ble_gatts_rw_authorize_reply() be deferred?

Working with SDK 15 on an nRF52832:

I have a peripheral applicatin where I'm computing the value of a BLE read on the fly.

Currently I do that by:

  • Setting up a BLE observer
  • When it sees a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event
  • If the operation is read and the attribute is the one in question
  • It computes the new value and
  • Calls sd_ble_gatts_rw_authorize_reply() to update the value and authorize the read.

But now I want to use data on an external flash to compute the value.  Because I'm on a nRF52832 rather than a nRF52840 I don't have the SPIM to memory-map the external flash for read.  So I need to kick off some SPI operations to read the data.  Those will take a while.  So doing them before returning from the event observer is not practical.

Question:

  • Does the sd_ble_gatts_rw_authorize_reply() have to be called before the observers have all handled the authorize request BLE event?
  • Or can I have:
    • my event handler kick off a background process (string of SPI driver calls and callbacks) and return, then
    • the background process do the SPI reads, compute the value, and call sd_ble_gatts_rw_authorize_reply() once this is complete?

If the latter doesn't work, how SHOULD I do such an operation?

Parents
  • Hi,

    After the EVENT BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST has been generated, the peripheral has 30 seconds to end the transaction with a ATT Read Response. Which means that you should have enough time for calculating the value and call sd_ble_gatts_rw_authorize_reply().

    From the Bluetooth specification Version 5.1 | Vol 3, Part F

    "A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed and the local higher layers shall be informed of this failure. No more Attribute protocol requests, commands, indications or notifications shall be sent to the target device on this ATT bearer".

    regards

    Jared 

Reply
  • Hi,

    After the EVENT BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST has been generated, the peripheral has 30 seconds to end the transaction with a ATT Read Response. Which means that you should have enough time for calculating the value and call sd_ble_gatts_rw_authorize_reply().

    From the Bluetooth specification Version 5.1 | Vol 3, Part F

    "A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed and the local higher layers shall be informed of this failure. No more Attribute protocol requests, commands, indications or notifications shall be sent to the target device on this ATT bearer".

    regards

    Jared 

Children
Related