Hi,
I´m using nrf52840 with softdevice S132 and set ble_gattc_conn_cfg_t::write_cmd_tx_queue_size to larger than 1. I´m count number of queued writes by increasing a counter each time I receive NRF_SUCCESS back from sd_ble_gattc_write and decerasing the counter on BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event with p_ble_evt->evt.gattc_evt.params.write_cmd_tx_complete.count.
But it happens sometimes that the counter wraps around on the negative side so that it becomes 255 or 254. How is this possible?
This must mean that BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event was fired before actually increasing the counter at some point.
The counter is not used any where else, and is set to 0 when connection is established.
I have measured that the amount of times I manage to queue write with NRF_SUCCESS is equal to number of BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE events.