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

Are notifications always sent before disconnecting?

Hi,

In our code we would like to respond to a write with a notification and then disconnect. So we first we call sd_ble_gatts_rw_authorize_reply to reply to the write, then sd_ble_gatts_hvx for the notification and then sd_ble_gap_disconnect. Now I was wondering if the write response and the notification are always sent before the disconnection occurs, or do I have to wait for BLE_EVT_TX_COMPLETE (for 2 packets) to know for sure that they are sent?

Regards,

Thiemo van Engelen

Parents
  • FormerMember
    +1 FormerMember

    No, there is no guarantee that the sd_ble_gatts_rw_authorize_reply() and the notifications will be sent before the disconnect command.

    So yes, to be sure that sd_ble_gatts_rw_authorize_reply() and the notifications are transmitted before the disconnect command, you should wait for BLE_EVT_TX_COMPLETE/BLE_GATTS_EVT_HVN_TX_COMPLETE (S132 v. 4.x.x)

  • Well it's completely unclear how you handle disconnection here and it's also unclear what happens with packets which were prepared to be sent over GATT in Soft Device. There were indications by Nordic team on similar questions here on the forum that buffers should get flushed and that sounds logical. So once you get event DISCONNECTED how you treat the restart of procedure? How you make sure in your logs about what went from APP layer FW to BLE stack GATT layer through SD API and what really went through? It's even possible that packets went over the link on LL and L2CAP layers but then didn't make it through Android stack and APIs to your Android app before it got disconnect event. Etc. without logs about what is happening on the radio link you can hardly claim anything.

Reply
  • Well it's completely unclear how you handle disconnection here and it's also unclear what happens with packets which were prepared to be sent over GATT in Soft Device. There were indications by Nordic team on similar questions here on the forum that buffers should get flushed and that sounds logical. So once you get event DISCONNECTED how you treat the restart of procedure? How you make sure in your logs about what went from APP layer FW to BLE stack GATT layer through SD API and what really went through? It's even possible that packets went over the link on LL and L2CAP layers but then didn't make it through Android stack and APIs to your Android app before it got disconnect event. Etc. without logs about what is happening on the radio link you can hardly claim anything.

Children
No Data
Related