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

disconnecting while operations are in progress never gives BLE_GAP_EVT_DISCONNECTED event

2020-01-24-092119EST-ProductStoppedGettingEventsFromNordicDK.txtImprivataTestNordicEventsNotReceived.zipCalls_to_pc_ble_driver.cpp0285.2020-02-24-TestProgramUploadedToNordicSupport.zipFeb25TestProgramUploadedToNordicSupport.zipImprivata_bgTestApp.zipbgSDKTestAppMay4.zip2020-05-05-035347-NordicDK_USB840M_200505_ClockInternal_2in1.hex.txt.txtbgSDKTestAppMay6.zipI’m developing an application based on pc-ble-driver to talk to an nRF52840-based dongle (from Fanstel).

I’m having trouble disconnecting cleanly when a connection has operations in progress.  For example, I call ‘sd_ble_gattc_write’, which returns NRF_SUCCESS, but I don’t receive event BLE_GATTC_EVT_WRITE_RSP (after waiting 60 seconds), so I decide to disconnect. When this happens, sd_ble_gap_disconnect returns NRF_SUCCESS, but I do not receive BLE_GAP_EVT_DISCONNECTED even after waiting 30 seconds. The connection supervision timeout is 4 seconds.  What could cause the disconnect to not generate any BLE_GAP_EVT_DISCONNECTED event?

What I’m trying to accomplish here: if a connection is not responsive, I want to end that connection, without disturbing other connections I have open.

Thanks,

Paul Bradford

  • Hi,

    Which device are you interfacing? Can you provide an example code that can be used to reproduce the issue?

    Can you provide a sniffer trace of the communication between the two devices? You can use our nRF Sniffer for this purpose (please make sure you use v2).

    Are you sure that the connection is still enabled when you try to disconnect? If the device is unresponsive, I would have expected the disconnect to happen earlier.

    Best regards,
    Jørgen

  • I will work on gathering more information.

    I have a logging mechanism that shows all the operations I'm doing and all the events I receive. Before this incident occurs, the connection is operating and is not disconnected.

    Two operations on this connection succeeded, but never generated the proper event afterward
    1. sd_ble_gattc_write(with BLE_GATT_OP_WRITE_REQ) never generated event BLE_GATTC_EVT_WRITE_RSP
    2. sd_ble_gap_disconnect never generated event BLE_GAP_EVT_DISCONNECTED

    My assumptions for those two operations is that if they return NRF_SUCCESS, they will always be followed by the corresponding event.

    1. Is there any situation at all where those operations return NRF_SUCESS but don't generate the corresponding event? 

    2. What is the upper limit on the time these operations can take to generate those events? I assume it's related to the supervision timeout (which is 4 seconds).

    Thanks,

    Paul

  • I have captured three instances of this problem in trace here: drive.google.com/open
    This is trace from Ellisys Bluetooth Analyzer. If you can't read this, I think I can find an MSI to install the analyzer.
    The three instances where we do a write, fail to get event BLE_GATTC_EVT_WRITE_RSP, then do a disconnect and fail to get event BLE_GAP_EVT_DISCONNECTED are at these UTC times on Dec. 5:
    4:47:25
    4:53:08
    5:07:35

    I filtered the trace by the MAC of the nRF52840: *F5:5D:B3:C6:4E:2E

    In all cases, the Ellisys trace shows the master sending a write request, the slave does send a response to the write request, but my tracing shows that this never percolates up to give me event BLE_GATTC_EVT_WRITE_RSP. (Just because the sniffer sees the response doesn't prove the nRF52840 saw the response).
    After that, I do a disconnect, and the Ellisys trace shows the disconnect request LL_TERMINATE_IND, and in all cases shows no response from the slave. I don't know if a response is expected. I search other disconnect attempts and don't see a response to any of them.

    Thanks,

    Paul

  • Were you able to read the traces I sent on Dec. 5?

    Also, do you have any information on the questions I asked on Dec. 4?

  • I was able to read the trace, but unfortunately, it did not provide more details on why this happens.

    1. Are you able to provide a project that we can use to reproduce this behavior? 
    2. What slave device are you interfacing? Are you seeing this with other devices or only with this one?
    3. Is the nRF52840 Dongle responsive after the GATT write/disconnect functions are triggered?
    4. Which version of pc-ble-driver are you using, and which softdevice API version?

    Regarding your questions:

    1. If you do not get a response to the GATTC procedure API call, you should get a BLE_GATTC_EVT_TIMEOUT event after 30 seconds (see GATTC Timeout).
    2. For DISCONNECTED, the event should come right after connection supervision timeout at latest (see BT 5.0 Core spec Vol 6, Part B - 5.1.6)

Related