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)

  • Thanks for your suggestions. BLE_GAP_EVT_DISCONNECTED i just pull down is_connected flag. So what i expect is during connection i continue sending new values consequtively inside BLE_EVT_TX_COMPLETE "loop", and when suddenly disconnect takes place i just have to not get BLE_EVT_TX_COMPLETE any more, so to_send_index shouldn't increment during disconnected. On next connect just my timer handler triggers new transfer and i get to this event again. So TX_COMPLETE is the only place where my buffer index increases, and it seems to continue doing that short time after disconnection or at connection establishment before subscription to the characteristic. I tried organize my stream with indications instead of notification with the same timing intervals and obtain similare results with losing packets.

Reply
  • Thanks for your suggestions. BLE_GAP_EVT_DISCONNECTED i just pull down is_connected flag. So what i expect is during connection i continue sending new values consequtively inside BLE_EVT_TX_COMPLETE "loop", and when suddenly disconnect takes place i just have to not get BLE_EVT_TX_COMPLETE any more, so to_send_index shouldn't increment during disconnected. On next connect just my timer handler triggers new transfer and i get to this event again. So TX_COMPLETE is the only place where my buffer index increases, and it seems to continue doing that short time after disconnection or at connection establishment before subscription to the characteristic. I tried organize my stream with indications instead of notification with the same timing intervals and obtain similare results with losing packets.

Children
No Data
Related