400ms delay between ATT Write request and response

Hi, 

On a nrf52840 running SDK 17.0.2 and Softdevice 7.2, while being connected to two devices in central and peripheral role, I observe that on the connection 
where the nrf is in peripheral role, a whopping 400ms delay between an ATT write request and its response (detected and measured with wireshark)

In the Message sequence diagram "GATTS write request without authorization"  I get the impression that the response is sent "immediately"  by the softdefice,
where that immediately intuitively is in the 20ms range rather than 400ms..

My questions are:

- What influences the observed delay (I suspect connection parameters a bit..)

- Can I have influence on this in such way that the delay is reduced?

I can see that if I disconnect the peer in peripheral role (where the nrf is central) the delay drops to some 20-50ms.

Thank you, jmr.

  • Hej Torbjørn,

    It seems a bit odd that using a connection interval on the central link that is a multiple of the connection interval on the peripheral link will make such a big difference. Have you done testing to verify that using 400ms over 437.5ms provides a significant and consistent improvement?

    Yes, I have done some testing. While with 400ms I get 10% failure rate, 437.5ms yields 100% failure rate with peer2. Odd is the fact that with 202.5ms interval I get a low 5% failure rate on communications with peer2..

    interval 375ms,   latency 3, timeout = 6000ms  --> 20% failure, NRF_ERROR_TIMEOUT in sd_ble_gatts_hvx
    interval 400ms,   latency 3, timeout = 6000ms  --> 10% failure, no answer from peer2
    interval 250ms,   latency 3, timeout = 6000ms  --> 15% failure, NRF_ERROR_TIMEOUT in sd_ble_gatts_hvx
    interval 200ms,   latency 3, timeout = 6000ms  --> 15% failure, NRF_ERROR_TIMEOUT in sd_ble_gatts_hvx
    interval 202.5ms, latency 3, timeout = 6000ms  --> 5% failure, NRF_ERROR_TIMEOUT in sd_ble_gatts_hvx
    interval 437.5ms, latency 3, timeout = 6000ms  --> 100% failure, no answer from peer2
    interval 420ms,   latency 3, timeout = 6000ms  --> 10% failure, no answer from peer2
    interval 420ms,   latency 0, timeout = 6000ms  --> 5% failure, no answer from peer2
    interval 202.5ms, latency 0, timeout = 6000ms  --> 20% failure, NRF_ERROR_TIMEOUT in sd_ble_gatts_hvx

    Packets should never get lost when using the SoftDevice, unless you get a disconnect (which is what happens if you have a total communications breakdown). 

    I apologize for not having made that clear: what I observe with peer2 (and ONLY peer2) is a "communications breakdown" on a higher level. My app communicates with peer2 using a service just like your NUS. And that application-level-communication breaks down.Depending on the chosen interval with peer1, I get either no answer from peer2 where I expect one (while seeing with the sniffer that packets have been sent though delayed) or I get a NRF_ERROR_TIMEOUT when calling sd_ble_gatts_hvx for the tx-part of my NUS-alike service.

    Also if there is no peer1 connected (and I do no scanning), I have no problems with peer2 and observe no delays beyond what I would expect changing connection parameters. Also varying connection parameters in single peer2-only mode have no negative effects.

    One thing that is interesting is the fact that the remote peripheral requests a slave latency of 3. 

    With a connection interval of 437.5ms and a slave latency of 3 the peripheral is allowed to only send a packet once every 4 connection intervals, or every 1.75 seconds. 

    Could this be related to the issues you are seeing?

    Not really, because I have no issues with peer1 at all. That peer1 is kind of a environmental sensor with very little data to send at low frequency. So that latency settings is just fine..

    Could you try a new test where you accept the min and max connection interval set by the peer, but simply set the slave latency to 0, and see if it works better?

    I did some latency=0 testing (see above) with little improvement. Again, I have issues with peer2 but I do alter connection parameters for the connection with peer1..

    Could it possibly be that i might have misconfigured the Softdevice in a way that the two connections are interferring with each other? Do I need to have a separate configuration tag for each connection?

    thanks and best regards, Jørn

  • Hi Jørn

    These are very strange findings. With the central link running at such a long interval there should be plenty of room for the peripheral connection running with a 20ms connection interval to send and receive data, regardless of whether or not the long connection interval is a multiple of the short one. 

    Could you let me know what kind of hardware is used for the three devices involved (the nRF device, and peer1 and 2)?

    Is the nRF52840 device using a DK, or a custom board?

    Have you reproduced the issue on multiple sets of hardware, or just a single set?

    Do you think there is any way you could assemble some kind of test that I can run locally on my side, using DK's only, so I can reproduce the issue here?

    Best regards
    Torbjørn

Related