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?

  • No, those errors are not related to the issue. If I run several copies of the test program on different Windows machines contacting the same peripheral (Android phone), it usually happens on at least one of them within a few hours. That's in my company's office, where there is a lot of BLE traffic due to lots of smart phones. When I ran it at my home, where there are only two smart phones in the vicinity, it ran for a day and a half without reproducing the problem.

  • I suggest you run multiple copies of the test program on the same WIndows 10 machine. Plug in 3 or 4 nRF52840 USB devices, open 3 or 4 command prompts, and run the test program from from each, with different -COMx command-line parameters. I had been running one copy and it didn't repro overnight. I ran three copies, and it happened on two of them in less than an hour.

  • I have now reproduced this problem several times in a very quiet BLE environment (my home).  I plug in in 3 nRF52840 USB devices into one Windows 10 computer, run 3 copies of the test program, all using the UUID of the one Android phone set up as a peripheral. Within a few hours, 2 or 3 have reproduced the problem.

Reply Children
Related