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?

  • You're responding to Leo Chen's comment, but I'll add my observations: In my Jan. 22 comment I wrote "I never receive another event for that connection, as shown by USB capture." So after I do a write (or a read), I do not get an event to end that write (or read). In the product, I go ahead and call sd_ble_gap_disconnect, but never receive the disconnect event.   Once I get in this state, I don't receive any more events. (In the test program I don't bother to call sd_ble_gap_disconnect, I exit as soon as the error is detected).

  • Ok, in that case, I do not think I have managed to reproduce the issue properly at all. When I get the error and your program exits, I still see a lot of scan/advertising and events happening in the log (I guess for the next 65 seconds until the error is detected).

    I will keep working on it and see if I can get into the state you are describing.

  • When I am using SamSung S7 to test.

    I always got the similar result.

    The READ/WRITE, then far end disconnected after couple hour testing.

    The tool exit after 1 minute later.

    I bough a new SamSung Note 10 to test.

    I can't reproduce this problem with Note 10 so far.

    I installed 6 dongle and running about 20 hours testing.

    The difference is Note 10 has more powerful CPU maybe can handle more connection at the same time.

    I need to find other phones to compare.

    Still trying.

    Paul, Would you please also upload your log to Nordic to analysis.

  • I performed my tests with a Huawei P30 Pro, so I'm not sure the CPU speed is the limiting factor. However, phone HW/SW can certainly make an impact.

    Which phone model(s) did you do the test with Paul? I'm asking this to be able to reproduce the issue, not to blame the phone vendor.

    Also, as Leo suggested, please upload your full debug logs from the connectivity FW.

  • It sounds like you have mostly reproduced the problem, which is that after a read/write request, we get no event all, not the event saying the read/write completed nor a GATT timeout event.   You can investigate that and find out why no event is sent from the chip to pc-ble-driver.

Reply Children
No Data
Related