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

Scan doesn't work after receiving BLE_GAP_EVT_TIMEOUT with timeout.src = BLE_GAP_TIMEOUT_SRC_CONN

I'm doing this:

1. Start a scan, with these parameters:

#define SCAN_INTERVAL           0x00A0                                  /**< Determines scan interval in units of 0.625 millisecond. */
#define SCAN_WINDOW             0x0050                                  /**< Determines scan window in units of 0.625 millisecond. */
#define SCAN_TIMEOUT            0x0002                                  /**< Timout when scanning. 0x0000 disables timeout. */

  .active   = 0,
  .scan_phys = BLE_GAP_PHY_AUTO,
  .interval = SCAN_INTERVAL,
  .window   = SCAN_WINDOW,
  .timeout  = SCAN_TIMEOUT,
  .scan_phys         = BLE_GAP_PHY_1MBPS,
  .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,

2. Looking for a suitable peripheral in BLE_GAP_EVT_ADV_REPORT using the COMPLETE_LOCAL_NAME and MANUFACTURER_SPECIFIC_DATA fields.

3. Calling sd_ble_gap_connect a suitable peripherical is found

Sometimes for some reason the connection process witll timeout and I will get a BLE_GAP_EVT_TIMEOUT event with timeout.src set to BLE_GAP_TIMEOUT_SRC_CONN. As far as I understand this means the connection process timed out. I try to restart scanning in that case. But from that point onward the scanning will be pretty erratic and will most likely not find the pheriperical, even when I can see it advertising in my cell phone using NRF Connect with a ~23ms interval.

It behaves as if the connection was somehow still using resources, even when the calls to sd_ble_gap_scan_start() do not fail and they timeout appropriately without finding anything.

I had this problem using the old s140_nrf52840_5.0.0-2.alpha soft device and I migrated to SDK 15 in hopes this will go away, but I'm still seeing the problem with s140 6.0 SD.

Any ideas?

  • Hi,

    Can you capture a sniffer trace and send it to me to see what is happening over the air?

  • Ok, this is the capture, what I found and what this capture is:

    1. e2:1a:5b:69:be:c7 is continuously advertising this is a nrf52840 running sd140 v6

    2. 43:e5:2d:c0:ed:d4 is scanning but not getting any BLE_GAP_EVT_ADV_REPORT events (this is also a nrf52840 sd140v6)

    3. This goes for quite a bit until I use NRF Connect on my android phone (for some reason this doesn't appear in the capture) to connect to e2:1a:5b:69:be:c7, this succes as seen in my phone and in the nrf log.

    4. At the exact same time the android manages to connect, suddenly the nrf52840 also manages to connect and works fine for the rest of the connection.

    This happens randomly, but once it starts happening it will continue to work very weird for quite a while, and at other times I can go on working for quite a while without failing.

  • Just to clarify, so after the timeout from the first connection, you won't get any BLE_GAP_EVT_ADV_REPORT events when trying to scan again?

    Didn't quite understand what you meant by "This happens randomly, but once it starts happening it will continue to work very weird for quite a while, and at other times I can go on working for quite a while without failing."

    It works fine sometimes and sometimes you have to connect with your phone first?

    Can you upload the whole sniffer trace? and if possible upload your project with a step by step procedure so I can try to reproduce this?

  • I am also seeing a problem similar to this.   My peripheral is attempting to connect then disconnect.

    10 Seconds later repeat this action.

    For the first 20+ attempts it appears to be working fine (longest has been 3 days) then suddenly stops on the Connect.  
    This is then timed out and the scanning from that point forward fails.

    I have attempted to restart the BLE at this point and this does not resolve the issue.

    A full restart sees the peripheral connect immediately and start working again

    Any further information

  • Sorry further clarification

    On the central the following is occurring

    1.  Scan for advertising

    2.  On receipt of advertising from a specific device connect

    2a    Restarting Scanning 

    2b.  Wait Disconnect

    3  On receipt of Disconnect repeat from 1.


    When it fails the Connect (to the same device) times out.  

    1.   Attempt to scan for advertising

    2.   No advertising is received from any device

Related