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

nRF52810 S112 background reconnect issue

Hi,

I'm working through a number of the PCA10040e examples (SDK16 | S112 | nRF52810 - mouse and keyboard to be specific) and have noticed some irregular behavior when waking the peripheral from sleep.  After bonding, if you put the peripheral to sleep, and let the central go to sleep as well (screen locked/off, no audio playing, etc.) and then wake the peripheral, the connection is not reestablished.  To restore the connection, you have to restart the peripheral with the central awake (i.e. being moved, screen on, audio playing, etc.)  However, if the central is "awake" when the peripheral is woken up, the connection is restored as expected.

I tried this with a nRF52832 (same examples in PCA10040 with S132) and the issue does not present itself.  The connection is able to be reestablished with the central sleeping.  Is this something to do with the Soft Device?  I plan on running a set of sniffer traces this afternoon and will post the results.

Thanks

p.s. central is an iOS device at this time.

Parents
  • Not sure if it helps, but I did find that if I make a call to advertising_start() sometime after the peripheral is running, with the central still sleeping, it does connect. 

  • You can find in chapter 35 in the Apple Bluetooth guidelines some recommendations to parameters that should be used: https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf

    For instance I believe the advertising_start() may start by doing directed advertisement, this is not recommended by apple, see chapter 35.3. So you may need to init advertisement module without directed advertisement enabled.

    Apple also have some suggestions for advertisement intervals.

  • I have a hex word printing from a debug terminal that I can enter into the passkey field.  Is this what you are looking for?

  • The LTK should be:
    uint8_t   ltk[BLE_GAP_SEC_KEY_LEN];   /**< Long Term Key. */

    You may set a breakpoint in your project just to read out the LTK, since it doesn't change you only need to read it once and it will be valid until you re-bond. After reading out the LTK you can then disconnect the debugger and run the application as normal with the nRF Sniffer.

  • Finally got this working.  Lines 11659-12577 represent a failed reconnect effort.  Lines 12642-13580 represent a successful one.  The firs obvious difference is that an MTU exchange is not happening.  Beyond that, I'm unsure where to look for clues as to what is not working properly.20200925 - full capture.pcapng

  • Please comment out pm_handler_secure_on_connection(), since that break with the apple guidelines chapter 35.10.

    I am not sure if I understand what is actually failing, because both instances show that the peers do connect, they encrypt, and for instance the battery level is notified from the peripheral to the central every 2 seconds. So I guess the question is, what is not working here? What happens if you for instance press a key?

    There is nothing in the logs that indicate an issue with the peripheral, so if the phone behave differently then I suggest contacting apple on this issue.

    The logs do show that the phone for one of the connections do also execute a write to the CCCD's, however the application on the peripheral do not require this, as the CCCD's are already stored from previous connection and thereby restored on connection (which is why the battery level notification works in both cases).

    Best regards,
    Kenneth

  •  pm_handler_secure_on_connection()

    was commented out in peer_manager_handler.c for the build associated with that trace.

    When I wake the central after waking the peripheral, the peripheral shows as "not connected" in the central's Bluetooth devices list.  As expected, pressing a key yields no response from the central. 

    If I compile and build this to a nRF52832 using S112, the same behavior is observed.  If I build with S132, the peripheral reconnects in the background without an issue. By elimination, it looks like the differences in S112 and S132 somehow contribute to the difference in behavior.   Thoughts?

    And yes, I'll reach out to Apple, too.

Reply
  •  pm_handler_secure_on_connection()

    was commented out in peer_manager_handler.c for the build associated with that trace.

    When I wake the central after waking the peripheral, the peripheral shows as "not connected" in the central's Bluetooth devices list.  As expected, pressing a key yields no response from the central. 

    If I compile and build this to a nRF52832 using S112, the same behavior is observed.  If I build with S132, the peripheral reconnects in the background without an issue. By elimination, it looks like the differences in S112 and S132 somehow contribute to the difference in behavior.   Thoughts?

    And yes, I'll reach out to Apple, too.

Children
Related