In my application an nRF52832 acts as a BLE peripheral device which is sending sensor data to an app on a mobile phone. As long as the phone is interested, notification on the relevant characteristic is enabled, the firmware is adding sensor data to the hvn tx queue by calling sd_ble_gatts_hvx(). When the phone is no longer interested, it disables the notification and the firmware will stop adding sensor data to the buffer.
My problem is that at this time there is already a few sensor data packets waiting in the buffer. When the phone next enables notification on the characteristic, it receives a couple of 'old' data packets before it gets new data. I would really like to flush out the buffer so that when the phone requests data, it will only receive new sensor data.
Is there anyway of doing that?
My stack is configured with a hvn tx queue size of 16: ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 16;
The sensor data characteristic (in a custom service) is setup such that the SDK stack is managing its data memory: cccd_md.vloc = BLE_GATTS_VLOC_STACK;
I realise that one way of resetting the queue would be to simply reset the SDK stack. However, the phone is still connected and able to touch other characteristics at this time so this is not really a solution.
nRF52832 S132 ver 6.0.0