-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
v5.3.1
Espressif SoC revision.
ESP32-S3-MINI-1 (rev 0.1)
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-S3-DevKitM-1 v1.0
Power Supply used.
USB
What is the expected behavior?
Every time I connect over Bluetooth using nRF Connect on a phone, I should receive the GAP connected event in my application and the LED should turn blue, then back to red on disconnect.
What is the actual behavior?
Sometimes and frequently, I do not receive the GAP connected event in my application even though the Bluetooth connection has been successfully established and nRF Connect is showing as connected to the device. The LED remains red.
Steps to reproduce.
See attached a heavily stripped down version of the project which still exhibits the issue.
- Open the project in VSCode and build, flash and run it on the mentioned devkit board (the onboard LED is used). The LED should start red.
- Use a phone with the nRF Connect app to discover the device named "DEMO" and connect to it. No pairing is necessary. Note that you will see the advertisement flashing between DEMO and no name as the device is emitting two sets of extended advertising on the same address.
- The LED should turn red to indicate reception of the "connect" GAP event.
- Disconnect and the LED should turn blue to indicate reception of the "disconnected" GAP event.
- Repeatedly connect and disconnect (not specifically quickly, just waiting for the LED to change first)
- Eventually nRF should connect but the LED will still be red. This usually happens after only a couple of tries.
Debug Logs.
Diagnostic report archive.
No response
More Information.
I have a project which makes use of extended advertising, multiple advertising sets, connectable and non-connectable advertisements, advertising on different PHYs, and is frequently switching and enabling/disabling different advertisement sets. I have encountered a frequent issue in the Bluetooth controller which results in the GAP connected event sometimes not being raised at the application level despite the controller having successfully made the connection.
I have looked into the NimBLE stack and done some debugging. When the Host receives a connection complete HCI event (BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE
), it then waits to receive an advertising set terminated HCI event (BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED
) before continuing on to raise the GAP connected event at the application level. Sometimes, the adv_handle
of the latter event will have the wrong advertising set ID number. In this case, the value refers to the other, non-connectable advertising set instead of the connectable set that was actually used to initiate the connection. This confuses the stack and results in a connection being formed and remaining active without a connected event being raised. When the same connection is then disconnected, no disconnect event is raised either, despite being received from the controller.
For now the solution for us is to modify the stack and hard-code 0 instead of the reported value from the controller.