Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]

tonystuart
Posts: 4
Joined: Wed Mar 25, 2020 10:59 pm

Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]

Postby tonystuart » 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?
Attachments
log.txt
(31.12 KiB) Downloaded 39 times

ESP_Alvin
Posts: 121
Joined: Thu May 17, 2018 2:26 am

Re: Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]

Postby ESP_Alvin » Thu Mar 26, 2020 2:46 am

Moderator's note: edit the topic title for issue tracking, thanks.

tonystuart
Posts: 4
Joined: Wed Mar 25, 2020 10:59 pm

Re: Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]

Postby tonystuart » Fri Apr 10, 2020 12:09 am

Finally getting a chance to look at this again and figured I would start with the first warning message I get in the log output:

W (2285) BT_BTC: btc_avrc_tg_set_rn_supported_evt failed: AVRC TG not yet initialized

I think this occurs because main.c in the A2DP source example calls bt_av_hdl_stack_evt to set the event notification capabilities on the local AVRCP target without ever invoking esp_avrc_tg_init to initialize the bluetooth AVRCP target module:

Code: Select all

esp_avrc_rn_evt_cap_mask_t evt_set = {0};
esp_avrc_rn_evt_bit_mask_operation(ESP_AVRC_BIT_MASK_OP_SET, &evt_set, ESP_AVRC_RN_VOLUME_CHANGE);
assert(esp_avrc_tg_set_rn_evt_cap(&evt_set) == ESP_OK);
I see that similar code exists in the A2DP sink example (where it does call esp_avrc_tg_init), so perhaps this is an artifact of copy and paste.

On the other hand, devices (e.g. either an A2DP source or sink) can play the role of both an AVRCP controller and a target (i.e. one to handle play/pause the other to handle volume up/down).

However it looks like the A2DP source example isn't really set up to demonstrate being an AVRCP target. If this is the case, then I think those three lines of code could be removed.


KBFEDE
Posts: 4
Joined: Sun Apr 26, 2020 8:56 am

Re: Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]

Postby KBFEDE » Sun Apr 26, 2020 9:55 am

Have you ever tried add the esp_avrc_tg_init(); ?

tonystuart
Posts: 4
Joined: Wed Mar 25, 2020 10:59 pm

Re: Connectivity issue with Bluetooth a2dp_source example and Echo Dot [BT-717]

Postby tonystuart » Sun Apr 26, 2020 1:53 pm

Thanks for your suggestion. I did try it. It makes the warning go away, but the connection problem still exists, starting at commit 603d293. See this issue for more info:

https://github.com/espressif/esp-idf/issues/5134

Who is online

Users browsing this forum: Majestic-12 [Bot] and 16 guests