Open ftab opened 5 months ago
W (2354) BT_HCI: hcif conn complete: hdl 0x81, st 0xb
The reason for this problem is that the mobile phone rejected the connection of esp32 through LMP_NOT_ACCEPT. The error code is 0xb (connection already exists). It is speculated that the restart speed of esp32 is too fast, and the mobile phone has not yet disconnected; Then ESP32 initiated the connection again and was rejected by the phone. There is no good solution, I think you can try delaying a period of time before connecting.
try delaying a period of time before connecting.
@shangke1112 I added a five second delay before trying to connect initially, and it seems to be connecting more often, but then that means there's a longer wait at startup before it's connected in all cases, not just when restarting. This may be an acceptable workaround for now. But if I can avoid that 5 second delay I'd prefer to. It seems like the status response HCI_ERR_CONNECTION_EXISTS should cause the esp_a2d_sink_connect to fail right away, instead it takes 60 seconds. Is there no way to cancel that?
I suggest that you can add a reset flag to control whether there is a delay .
We will confirm how to solve this problem later.
Answers checklist.
IDF version.
v5.1.2-691-g7380f96017
Espressif SoC revision.
ESP32-D0WD rev 1
Operating System used.
macOS
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-LyraT v4.3
Power Supply used.
USB
What is the expected behavior?
Connect to my device or give an error message right away
What is the actual behavior?
Takes a minute to fail out sometimes
Steps to reproduce.
I tested with LyraT v4.3 board and an iPhone 15 Pro
I modified the pipeline_a2dp_sink_and_hfp example in esp-adf to have a connect loop that calls esp_a2d_sink_connect
From scratch without any existing copy of esp-adf:
cd ~/esp
git clone https://github.com/radiosound-com/esp-adf -b esp-bt-connect-bug --recursive
esp-adf/esp-idf/install.sh
export ADF_PATH=~/esp/esp-adf
source esp-adf/esp-idf/export.sh
cd esp-adf/examples/get-started/pipeline_a2dp_sink_and_hfp
idf.py menuconfig
and set flash size to 4 MB or larger, set Bluetooth debug logs onidf.py build flash monitor
If you have esp-adf and esp-idf already set up:
cd esp-adf/examples/get-started/pipeline_a2dp_sink_and_hfp
idf.py menuconfig
and set flash size to 4 MB or larger, set Bluetooth debug logs onidf.py build flash monitor
Debug Logs.
More Information.
Some resets it will reconnect after a few seconds, sometimes it will take a minute before reporting
BTA_AV_OPEN_EVT::FAILED status: 2
and allowing another attempt to connect. The latter is the problem. It is annoying to the end user if the device resets and then takes more than a minute to reconnect. This happens up to 50% of the time in our tests so far (on our custom board, but with the same connection attempt method I added to this example)