Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]
Posted: Thu Mar 26, 2020 12:05 am
I've been working with the Bluetooth a2dp_source example in the stable esp-idf-v4.0 branch.
It works okay with an OontZ Angle Bluetooth Speaker, but it doesn't work at all with an Amazon Echo Dot Bluetooth Speaker. The failure scenarios vary depending on the order of initialization of the ESP32 and the Dot, and whether the Dot was previously paired with the ESP32.
For example, with the latest version of the a2dp_source example (modified to replace "ESP_SPEAKER" with the name of the device), I get this (I've attached the rest of the log output):
assertion "a2dp_source_local_param.btc_aa_src_cb.media_alarm == NULL" failed: file "home/esp/esp-idf-v4.0/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c", line 1496, function: btc_a2dp_source_aa_start_tx
When it reboots following the assertion, it enters another of the failure scenarios.
In this particular case, I guessed that the assertion failure was due to executing btc_a2dp_source_aa_start_tx a second time without an intervening call to btc_a2dp_source_aa_stop_tx.
I was able to get past the assertion failure by setting m_media_state to APP_AV_MEDIA_STATE_STOPPING instead of APP_AV_MEDIA_STATE_IDLE. That prevented the assertion failure, but still did not result in a connection, with messages of the following form appearing in the log every 10 seconds:
I (101217) BT_AV: bt_app_av_sm_hdlr state 5, evt 0xff00
I (111217) BT_AV: bt_app_av_sm_hdlr state 5, evt 0xff00
I (121217) BT_AV: bt_app_av_sm_hdlr state 5, evt 0xff00
Note that I can connect to the Echo Dot using Bluetooth without any issues from both my HP Ubuntu laptop and my Android phone. The Echo Dot is a current third generation model. FWIW, the Bluetooth name of the OontZ Angle is "OontZ Angle 3 920" and the Bluetooth name of the Echo Dot is "Echo Dot-4VS".
I can also connect to the Echo Dot using an older version of the a2dp_source example. A version that works is commit 7e268ada with esp-idf-v3.2.2. It does not have the Secure Simple Pairing support nor the AVRCP support that are present in the later version.
I also tried building that older example with the esp-idf-v4.0 and it fails in much the same way as the latest version of the example. This leads me to believe the issue is in the underlying Bluetooth support, not the example itself. All I needed to build the older version of the example with the newer version of esp-idf was to change esp_bt_gap_set_scan_mode to the two argument version due to the API change. I also changed ESP_BT_MODE_BTDM to ESP_BT_MODE_CLASSIC_BT.
Can anyone offer any suggestions on how I might proceed with debugging this?
It works okay with an OontZ Angle Bluetooth Speaker, but it doesn't work at all with an Amazon Echo Dot Bluetooth Speaker. The failure scenarios vary depending on the order of initialization of the ESP32 and the Dot, and whether the Dot was previously paired with the ESP32.
For example, with the latest version of the a2dp_source example (modified to replace "ESP_SPEAKER" with the name of the device), I get this (I've attached the rest of the log output):
assertion "a2dp_source_local_param.btc_aa_src_cb.media_alarm == NULL" failed: file "home/esp/esp-idf-v4.0/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c", line 1496, function: btc_a2dp_source_aa_start_tx
When it reboots following the assertion, it enters another of the failure scenarios.
In this particular case, I guessed that the assertion failure was due to executing btc_a2dp_source_aa_start_tx a second time without an intervening call to btc_a2dp_source_aa_stop_tx.
I was able to get past the assertion failure by setting m_media_state to APP_AV_MEDIA_STATE_STOPPING instead of APP_AV_MEDIA_STATE_IDLE. That prevented the assertion failure, but still did not result in a connection, with messages of the following form appearing in the log every 10 seconds:
I (101217) BT_AV: bt_app_av_sm_hdlr state 5, evt 0xff00
I (111217) BT_AV: bt_app_av_sm_hdlr state 5, evt 0xff00
I (121217) BT_AV: bt_app_av_sm_hdlr state 5, evt 0xff00
Note that I can connect to the Echo Dot using Bluetooth without any issues from both my HP Ubuntu laptop and my Android phone. The Echo Dot is a current third generation model. FWIW, the Bluetooth name of the OontZ Angle is "OontZ Angle 3 920" and the Bluetooth name of the Echo Dot is "Echo Dot-4VS".
I can also connect to the Echo Dot using an older version of the a2dp_source example. A version that works is commit 7e268ada with esp-idf-v3.2.2. It does not have the Secure Simple Pairing support nor the AVRCP support that are present in the later version.
I also tried building that older example with the esp-idf-v4.0 and it fails in much the same way as the latest version of the example. This leads me to believe the issue is in the underlying Bluetooth support, not the example itself. All I needed to build the older version of the example with the newer version of esp-idf was to change esp_bt_gap_set_scan_mode to the two argument version due to the API change. I also changed ESP_BT_MODE_BTDM to ESP_BT_MODE_CLASSIC_BT.
Can anyone offer any suggestions on how I might proceed with debugging this?