How to properly track hvn_tx_queue count?

Hello,

I'm using nRF52840 with Softdevice S140 7.0.1 and SDK 16 for my BLE application in which I send data via notifications. I'm interested in tracking the hvn_tx_queue count, so I followed the note as specified for SD_BLE_GATTS_HVX inside ble_gatts.h which says:

* @note The application can keep track of the available queue element count for notifications by following the procedure below:
* - Store initial queue element count in a variable.
* - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS.
* - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event.

This procedure works great until there's a sudden disconnect. After reconnection, the count initially reflects the number of packets in the queue before the disconnect and eventually exceeds the configured hvn_tx_queue size. I'm assuming on disconnect the queue empties since I'm not encountering NRF_ERROR_RESOURCES, is that correct? If so, what is the accurate way to reflect that behavior with my count variable? Is it just a matter of resetting the count when there's a disconnect event?

Thanks

Parents Reply Children
No Data
Related