Disconnect latency after calling bt_conn_disconnect()

Hi,

Our application is running in the central role connected to a peripheral.  The app disconnects from the peripheral by calling the bt_conn_disconnect() function.  It appears to take from 1 to 2 seconds before the "disconnected" callback handler is called.  There is no data being pushed out over the link prior to calling the disconnect function. The connection interval is 1 second, 0 latency with a 4 second supervision timeout.  I would expect the worst case latency would be 1 second.  Is this expected?

nrf Connect SDK 2.4.4
nrf5340

Thank you

Parents Reply Children
  • Kurt, 

    Thanks for your patience in waiting for me.

    kpreiss said:
    1) latency between calling bt_conn_disconnect() function and transmitting the LL_TERMINATE_IND packet. 

    I think you are trying to understand why I said the worst case here is ~2 CI (connection interval) as you might already seem to understand the best (immediately) and typical cases (< 1 CI) here. If the request reaches the controller after the controller’s scheduling cutoff for the immediately upcoming event, for example the event width is too small and there are already some packets scheduled to be transmitted in that next event,  it slips one more event: < 2·CI. I think it is not such hard to imagine that the LL scheduler can be in some scenarios decide that the request to schedule a command in outgoing packet will not be fit in the next event? Do you think this breaks the BLE Spec? Even though the typical delay should be ~1.CI , worst can be in those corner cases about ~2.CI

    kpreiss said:
    2) latency between peripheral receiving the LL_TERMINATE_IND packet and the  disconnect callback being invoked.

    there is no valid CI-based worst-case bound for the callback. Earlier I seem to have indirectly implied that the callback timing should follow the connection interval. That is not correct, the callback timing is dominated by host-side scheduling once the controller has terminated the link. The application disconnect callback is invoked only after the controller reports “Disconnection Complete” to the host and the Zephyr Bluetooth RX context gets CPU time to process it. Since callbacks are executed from that RX context, the time to the callback is not governed by connection interval and has no CI-based worst-case bound

Related