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

How can I know how many queued packets I loose on disconnection when connected to multiple peripherals?

Hi,

I´m using nrf52840 with softdevice S132, SDK version 15.2 as ble central. I´m using the write_cmt_tx_queue by setting ble_gattc_conn_cfg_t::write_cmd_tx_queue_size to larger than 1, and counting queued writes by increasing a counter when receiving NRF_SUCCESS on sd_ble_gattc_write and decreasing same counter on BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event.

I wonder how it is supposed to solve following scenario:

I have 2 connected peripherals and queuing writes without responses to both of them. If one of the peripherals disconnects before finishing all writes, how am I supposed to know which packets have been delivered and which have been lost for each connection? Is there any way to know how many packets I loose on disconnect event for each connection?

Parents
  • Hi,

    Not really no (even ideal best case there would be an inaccuracy of 1 packet since the peer might always have receive a packet that is not ack'ed yet on the link layer). I would instead consider using ack on the application layer, for instance send 10 packets (by regular write or notification), wait for a packet (by write or notification) in reverse direction, before transmitting the next 10 packets and so on. Upon (re-)connection you can always inquire how many packets have been received and continue from there.

    Best regards,
    Kenneth

Reply
  • Hi,

    Not really no (even ideal best case there would be an inaccuracy of 1 packet since the peer might always have receive a packet that is not ack'ed yet on the link layer). I would instead consider using ack on the application layer, for instance send 10 packets (by regular write or notification), wait for a packet (by write or notification) in reverse direction, before transmitting the next 10 packets and so on. Upon (re-)connection you can always inquire how many packets have been received and continue from there.

    Best regards,
    Kenneth

Children
Related