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

Determine characteristic handle that caused BLE_GATTS_EVT_HVN_TX_COMPLETE

Our nRF52832 BLE application needs to be able to send large bulk data to a phone app. We have patterned the transfers after the ble_app_att_mtu_throughput example, with data transfer notifications queued up and then the transfer continued in the BLE_GATTS_EVT_HVN_TX_COMPLETE event handler.

This is working well as it stands, however we would like to add an additional "bytes remaining" notification to be periodically sent to the phone app while the bulk data transfer is in progress. The problem we have run into is that there does not seem to be any method for determining the source (e.g., CCCD handle) that caused the HVN_TX_COMPLETE event.

Our BLE_GATTS_EVT_HVN_TX_COMPLETE handler is primarily keeping the bulk data transfer going, but occasionally must ignore the HVN_TX_COMPLETE events that come from "bytes remaining" notifies that are interspersed. Unfortunately, we haven't been able to identify a means for accomplishing this.

How can an app differentiate among multiple, different characteristics that can generate notifications, given that ble_event_t does not seem to contain such information for a BLE_GATTS_EVT_HVN_TX_COMPLETE event?

Parents
  • One way is to keep track of the order you buffer the notifications. So if you buffer one bulk, then one bytes remaining, then one bulk, then one bulk, then one bulk. And then you get a BLE_GATTS_EVT_HVN_TX_COMPLETE with count=3 you know that the first bulk, the bytes remaining and the second bulk is sent.

    Another is to not use notification for the bytes remaining, but use indication instead, then you will not get BLE_GATTS_EVT_HVN_TX_COMPLETE event, but a BLE_GATTS_EVT_HVC event instead.

Reply
  • One way is to keep track of the order you buffer the notifications. So if you buffer one bulk, then one bytes remaining, then one bulk, then one bulk, then one bulk. And then you get a BLE_GATTS_EVT_HVN_TX_COMPLETE with count=3 you know that the first bulk, the bytes remaining and the second bulk is sent.

    Another is to not use notification for the bytes remaining, but use indication instead, then you will not get BLE_GATTS_EVT_HVN_TX_COMPLETE event, but a BLE_GATTS_EVT_HVC event instead.

Children
Related