NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

Connection Negotiation fails from iOS Device

Open arturdev opened this issue 8 months ago • 4 comments

I'm having an issue connecting the iOS Device (central) to the ESP32-s3-mini (peripheral). Sometimes, the iOS device fails to connect to the peripheral, and an Apple engineer claims that it is solely a firmware issue. More is here: https://developer.apple.com/forums/thread/775811?page=1#827665022

More specifically, the Apple Engineer stated:

iOS requires a specific set of connection parameters, and will reject anything that does not comply.

These rules are described in Accessory Design Guidelines for Apple Products Connection parameter requests may be rejected if they do not meet the guidelines in this section. General connection parameter request guidelines:

Peripheral Latency ≤ 30 connection intervals. Supervision Timeout from 6 seconds to 18 seconds. Interval Min ≥ 15 ms. Interval Min ≤ 2 seconds. Interval Min is a multiple of 15 ms. One of the following: Interval Max at least 15 ms greater than Interval Min. Interval Max and Interval Min are both 15 ms. Interval Max * (Peripheral Latency + 1) of 6 seconds or less. Supervision Timeout greater than Interval Max * (Peripheral Latency + 1) * 3.

Any clue? Is there anything I can do from my cpp code to make it work? Or is it a limitation in NimBLE stack? Or maybe something else?

I tried the same thing with another BLE peripheral device, and everything was good. So the issue is not with the central side, but with the peripheral side utilizing NimBLE. The peripheral rejects the connection from the iOS Device (central) when it is in a low power mode and requests a different set of connection parameters.

arturdev avatar Mar 05 '25 19:03 arturdev

There is no limitation in the stack, what error messages are you seeing? Have you adjusted your connection parameters as suggested?, though in my experience I have never needed to worry about these with iOS.

Try a different module, some have bad radios/xtals and cause issues with connection timing.

h2zero avatar Mar 06 '25 17:03 h2zero

@h2zero That's the thing that on NimBLE side I don't see any errors. I have enabled debug logs, and when the iOS device (when in locked state) initiates a connection, in the SerialMonitor I don't see any connection requests/attempts at all. I even added some logs in ble_gap.c to check if something is happening in lower level... but no results. nothing is being called. However, on iOS side, the system delegate events of a successful connection, and right after a disconnection, reasoning that the peripheral initiated the disconnection..

arturdev avatar Mar 07 '25 06:03 arturdev

Do you have bonding enabled? This can happen if the bond is deleted.

h2zero avatar Mar 12 '25 16:03 h2zero

No, I intentionally disabled the bonding because otherwise, mobile devices would have remembered the peripheral and it would have appeared in the Bluetooth list.. and the users would have ended up with hundreds of Bluetooth devices in their list, haha

arturdev avatar Mar 13 '25 10:03 arturdev