Central connection attempt times out the peripheral connection

We have an nRF5340 device that maintains a peripheral connection to a central device and then makes several of its own central connections to other peripherals.  We ran into a strange issue where this device attempted to form a central connection, but after 1 second (CONFIG_BT_CREATE_CONN_TIMEOUT) a connection failure was reported with reason 0x02 (BT_HCI_ERR_UNKNOWN_CONN_ID).  Three seconds later (4 seconds after the initial connection attempt which is our supervisor timeout), we got notified that our peripheral connection disconnected with reason 0x08 (BT_HCI_ERR_CONN_TIMEOUT).  The central device also reported the reason as 0x08 (BT_HCI_ERR_CONN_TIMEOUT).  After this timeout, the device was able to advertise and regain its peripheral connection quickly.  There were no radio errors reported in the log.

Each time we see this issue, it happens with the same pattern: a central connection is requested, is unsuccessful and then the peripheral connection times out.  It does not happen with every connection attempt.  Sometimes it happens quickly and other times it can take 30min to reproduce it.

Since we are not actively trying to close the connection we think the issue must be lower in the radio code.  One item we wanted to double check was the behavior of the CLOCK_CONTROL_NRF_ACCURACY_PPM setting.  As I understand it, this setting is used to determine the sleep time and receive window for peripheral connections  For a device that just connects to a central it is easy to visualize the impact.  However, for a device that also behaves as a central while maintaining a peripheral connection it is harder to understand the impact of this setting and how it is used by the scheduler?  Can you shed some light on that?  Could an incorrect PPM setting result in the behavior we are seeing?

Most crystals have a 20ppm accuracy at 25C, but then lose accuracy considerably at temperature up to 150ppm.  Should we be using the nominal accuracy for the PPM configuration, or should we be taking into account the worst case ppm over temperature and with crystal aging?

Thanks.

Parents Reply Children
  • Hi Edvin, we will work on getting you the sniffer traces.

  • I wanted to circle back around to this issue.  We have been trying to reproduce it in a controlled fashion, but have not had much success.  Our attempts to capture a trace have so far been unsuccessful.  We have run tests where the device makes and destroys central connections, even in low signal environments, for days without issue.  So there definitely appears to be some sort of order of operations or timing issue that we have not quite isolated.

    In the testing we are doing, it is possible that multiple central connections are being attempted at the same time.

    Is there any assistance you can give us while we continue to troubleshoot?

    • Are there any scenarios you know of where the software device will just release connections without alerting the upper layers, such that it just looks like they disconnected naturally?
    • Are there any logs we could enable to give us more information?
    • Are there more details we could get by running a modified soft device from your side with more debug data?

    Some thoughts on potential causes:

    • Clock issue that causes the connections to get out of sync.  I don't think it is this case because we relaxed the PPM accuracy quite a bit and still see the issue.  Also, if it was a crystal issue I would expect to see it be more reproducible.
    • Soft device error where the radio is reset, but without a corresponding net core assert.
    • Soft device bug where the connection information gets corrupted resulting in the scheduler not working as expected and the connection naturally dying due to no connection intervals occurring or being out of sync.

    Any help trying to prove/disprove these hypothesis would be helpful.  Thanks.

  • Hello,

    I am sorry for the late reply. 

    I don't recall seeing this behavior in this SDK version (v2.6.6). The first thing that comes to mind was anomaly 165. It may sound like you want to try the network core monitor. 

    Enable it with CONFIG_NET_CORE_MONITOR=y on both cores.
    By default, the __weak handler only prints information about the event. To react to a reset or freeze, for example by recovering or rebooting, you must override ncm_net_core_event_handler().

    One example is to add this to main:

    #include "net_core_monitor.h"
    ...
    /* This is the override for the __weak handler. */
    void ncm_net_core_event_handler(enum ncm_event_type event, uint32_t reset_reas)
    {
       switch (event) {
       case NCM_EVT_NET_CORE_RESET:
          printk("The network core reset.\n");
          /* do something */
          break;
       case NCM_EVT_NET_CORE_FREEZE:
          printk("The network core is not responding.\n");
          /* do something */
          break;
       }
    }

    Both /*do something*/ should be replaced by full device resets, as there is no real graceful recovery from this kind of events. But first and foremost, it would be interesting to see whether you see these events at all.

    Best regards,

    Edvin

  • We do have CONFIG_NET_CORE_MONITOR enabled in our project already since we have had net core asserts in the past that have been hard to reproduce.  This particular issue does not cause any assert from the net core.  It looks like the connection just goes away.  From what we can tell, all active connections get disconnected, and then it has no problem reconnecting after that without special intervention.

    It does not appear to occur if the connections are made and static.  It seems to occur mostly when a new connection is being made, but we believe we have seen it also occur when a connection was forcefully disconnected.

    We have a test setup where we constantly make and break connections, and have not been able to reproduce the issue that way, so there is some sort of additional component and not just connecting and disconnecting.

  • It does sound like you are already doing this, but just to make sure, you are monitoring the ncm_net_core_event_handler() events, right?

    umr_engnr said:
    It does not appear to occur if the connections are made and static.

    What do you mean by this? 

    Best regards,

    Edvin

Related