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

Parents
  • I have created a test program that reproduces this problem: failure to receive events after a write or read request.  I have posted test program ImprivataTestNordicEventsNotReceived.zip and the main source file NordicTest-pc-ble-driver.cpp.   My intention is that you use the test program binaries, as described in the README.txt n the zip file. I included the source just so you can see what I'm doing, but I didn't include all headers to make it buildable.

  • Thanks for providing the example and detailed instructions. I have managed to run the test, and I have observed a few errors:

    2020-02-05 17:18:11.814: sd_ble_gattc_read failed during characteristic_metadata_discovery_start error 0x0008 NRF_ERROR_INVALID_STATE, conn_handle = 0
    2020-02-05 17:20:07.410: current GATTC read/write timed out
    2020-02-05 17:20:07.410: sd_ble_gattc_read to keep connection alive got BLE_GATTC_EVT_TIMEOUT (which is allowable), so we must disconnect
    2020-02-05 17:20:07.439: ERROR: sd_ble_gap_disconnect failed handle 0 error 0x3002 BLE_ERROR_INVALID_CONN_HANDLE
    2020-02-05 17:20:43.446: current GATTC read/write timed out
    2020-02-05 17:20:43.446: sd_ble_gattc_read to keep connection alive got BLE_GATTC_EVT_TIMEOUT (which is allowable), so we must disconnect
    2020-02-05 17:20:43.507: ERROR: sd_ble_gap_disconnect failed handle 0 error 0x3002 BLE_ERROR_INVALID_CONN_HANDLE
    2020-02-05 17:22:03.067: current GATTC read/write timed out
    2020-02-05 17:22:03.067: sd_ble_gattc_write for characteristic notification got BLE_GATTC_EVT_TIMEOUT (which is allowable), so we must disconnect
    2020-02-05 17:22:06.154: sd_ble_gattc_read failed during characteristic_metadata_discovery_start error 0x0008 NRF_ERROR_INVALID_STATE, conn_handle = 0
    2020-02-05 17:22:39.167: current GATTC read/write timed out
    2020-02-05 17:22:39.167: sd_ble_gattc_read to keep connection alive got BLE_GATTC_EVT_TIMEOUT (which is allowable), so we must disconnect
    2020-02-05 17:22:39.254: ERROR: sd_ble_gap_disconnect failed handle 0 error 0x3002 BLE_ERROR_INVALID_CONN_HANDLE

    I'm not sure if any of these are related to the issues you are seeing? How long does it normally take before the issue occurs with a single connection?

  • Sorry, I thought I had seen the log from you before but I missed it when I read through the post this time. This is strange, I'm not able to get into the state you describe. I have run two kits over the weekend, but I still receive events. I'm now testing with 3 additional dongles, no issues so far today. I will keep running the applications to try and reproduce the issue.

  • You wrote on Feb. 19 "I get the error and your program exits". Is somebody debugging to find/fix this? The test program exits when I do a read/write and get no events in response. That's the bug I need fixed. Everything that occurs after that failure to produce an event is secondary.

  • I also said that I always see a BLE_GAP_EVT_DISCONNECTED event in the log after the last GATTC_READ/WRITE, but before the expected GATTC_TIMEOUT. As I understood your next comment, you do not get any DISCONNECTED events, and the connectivity FW stops sending packets entirely? To me, this indicated that you are seeing a different behavior and that I have not managed to reproduce the same issue.

  • I do not receive a DISCONNECTED event.   I'll clean up and attach a revised test program that waits for either the GATTC timeout or the DISCONNECT event.

  • In a moment I'll upload new test program in 2020-02-24-TestProgramUploadedToNordicSupport.zip. When trying to connect, if it doesn't get the CONNECTED event or BLE_GAP_TIMEOUT_SRC_CONN, it will exit. When trying to read or write, if it doesn't get the read/write event, or the GATTC timeout or a DISCONNECT, it will try to disconnect, then exit.

Reply Children
Related