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

  • The developer has managed to reproduce the issue, but have not found any root cause of the issue yet. I will be out of the office for the rest of the week, but my colleague will follow up on this thread if there are any updates.

  • Update on the two problems in this case:

    1. I’ve found the cause of the error “never got BLE_GAP_EVT_CONNECTED or BLE_GAP_EVT_TIMEOUT(BLE_GAP_TIMEOUT_SRC_CONN)”.   ble_gap_scan_params_t.timeout  in the call to sd_ble_gap_connect was set to zero, meaning never timeout.   When setting this to a non-zero value, I do get BLE_GAP_EVT_TIMEOUT(BLE_GAP_TIMEOUT_SRC_CONN).   I had just used the same ble_gap_scan_params_t values from passive scanning, where I really did not want to timeout.
    2. I have not seen the GATTC_READ or GATTC_WRITE problem in my test program in 13 days (Feb 27). However, I am seeing it in my product, so I need to investigate the differences between the two.  When I started this support case GATTC_READ was waiting only for event BLE_GATTC_EVT_READ_RSP and GATTC_WRITE was waiting only for event BLE_GATTC_EVT_WRITE_RSP/BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE. Since then I’ve added checks for events BLE_GAP_EVT_DISCONNECTED and BLE_GATTC_EVT_TIMEOUT.  These changes seemed to almost entirely eliminate this problem from the test program. I have two unexplained facts: a) after making those changes, I did see this problem once, on Feb. 27, with the test program;  b) the logging from debug firmware (attachment 2020-01-24-092119EST-ProductStoppedGettingEventsFromNordicDK.txt) that shows a call to SD_BLE_GATTC_READ with no response event afterwards (BLE_GATTC_EVT_READ_RSP   or BLE_GATTC_EVT_TIMEOUT or BLE_GAP_EVT_DISCONNECTED).  

     

    Until I can reproduce this second problem again in a test program, I don’t expect that Nordic can investigate further.   

  • Thanks for the update! Let me know if you are able to reproduce the second issue again and what we need to do to reproduce/investigate it.

  • My product intermittently fails to receive an event after a GATTC read/write, but so far my test program does not fail. I'm making the test program incorporate more of the product code, while still being a self-contained test. Still working on it.

  • I have attached a new test program Imprivata_bgTestApp.zip. There is a file called README with instructions, and a description of the problem.   I suggest you try this on a Dell 64-bit Windows 10 laptop that has not had Nordic dev tools installed on it. Usually the problem occurs with in an hour or two.

    This test program reproduces the problem on two 64-bit Windows 10 laptops and does not reproduce this on one 64-bit Windows 10 laptop. I don't know what difference between these laptops causes two to fail and one to succeed. All have the same driver usbser.sys 10.0.18362.1 winbuild 160101.0800. Problem has occurred when plugged into USB 2.0 and USB 3.0 ports.

    Failing laptops: both Dell, one Windows 10 version 1903 build 18362.657, another Windows 10 version 1909 build 18363.752 (the latest public Windows 10 build)

    Laptop that does not reproduce the problem: Lenovo ThinkPad, Windows 10 version 1903 build 18362.657 (exactly the same as one failing laptop). This one has had Nordic tools like nRF Connect installed. One consequence is that when I plugged in an nRF52840 it would show in Device Manager as 'nRF Connect USB CDC ACM (COMx)'. To make it like my other laptops that do not have Nordic tools, I uninstalled the driver so that the nRF52840 would show up as 'USB Serial Device (COMx)'

Related