Hardware: ESP32-WROOM-32E module (ESP32-D0WD-V3 + 16MB flash)
https://espressif.com/sites/default/fil ... eet_en.pdf
I'm using the Bluetooth HFP AG profile in IDF v4.3.2 to connect a headset with WBS audio. In my application I'm getting very choppy outgoing audio which appears to be caused by the SCO link missing data. The logs show excessive SCO errors in the ag read callback:
BT_APPL: bta_ag_sco_read_cback: status(2)
BT_APPL: bta_ag_sco_read_cback: status(1)
Note: incoming data works flawlessly. Audio from the headset microphone has no problems.
I suspect the SCO link has timing issues or is just dropping the data. Is this a know problem with the ESP Bluetooth stack or HFP profile? Are there any settings or workarounds to fix audio data loss here?
Note, this is NOT the same issue as BT-776. In that case, the bt_app_hf_outgoing_cb was not being triggered. I have verified that my hf outgoing callback is being called and that I am delivering audio consistently from the application. Once delivered to the SCO layer it is just getting dropped.
viewtopic.php?f=13&t=15288&hilit=bta_ag_sco_read_cback
Additional Notes and testing to isolate the problem:
Project: examples\bluetooth\bluedroid\classic_bt\hfp_ag
To rule out my application code, I'm using the example hfp_ag project. I have tried IDF versions 4.3.2 + 4.4.1, and both still show many bta_ag_sco_read_cback errors with minor but noticeable popping and glitching in the audio. I have tested using multiple headsets from different manufacturers and all show the same behavior.
My target application also uses WiFi and has moderate CPU load for additional audio processing, which exacerbates the problem. In my application I typically see >20% data loss resulting in very poor audio quality.
SDK Config is set to enable 1 Sync SCO connection and enables HCI data path in controller and bluedroid:
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI=y
CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y
CONFIG_BT_HFP_WBS_ENABLE=y
CONFIG_HFP_AUDIO_DATA_PATH_HCI=y
Log from running esp-idf-v4.4.1\examples\bluetooth\bluedroid\classic_bt\hfp_ag, with HCI path enabled.
Code: Select all
I (20683) BT_APP_HF: APP HFP event: AUDIO_STATE_EVT
I (20683) BT_APP_HF: --Audio State connected_msbc
W (20723) BT_APPL: bta_ag_sco_read_cback: status(2)
W (20723) BT_APPL: bta_ag_sco_read_cback: status(2)
W (20733) BT_APPL: bta_ag_sco_read_cback: status(2)
W (20743) BT_APPL: bta_ag_sco_read_cback: status(2)
W (20753) BT_APPL: bta_ag_sco_read_cback: status(2)
W (20753) BT_APPL: bta_ag_sco_read_cback: status(2)
W (20763) BT_APPL: bta_ag_sco_read_cback: status(2)
W (22163) BT_APPL: bta_ag_sco_read_cback: status(1)
W (22703) BT_APPL: bta_ag_sco_read_cback: status(1)
W (22813) BT_APPL: bta_ag_sco_read_cback: status(2)
W (23683) BT_APPL: bta_ag_sco_read_cback: status(1)
I (23703) BT_APP_HF: speed(20.176652s ~ 23.177224s): 250.192291 kbit/s
W (24243) BT_APPL: bta_ag_sco_read_cback: status(1)
I (26703) BT_APP_HF: speed(23.177224s ~ 26.177318s): 255.991989 kbit/s
W (27523) BT_APPL: bta_ag_sco_read_cback: status(1)
W (28263) BT_APPL: bta_ag_sco_read_cback: status(2)
W (28643) BT_APPL: bta_ag_sco_read_cback: status(2)
W (29013) BT_APPL: bta_ag_sco_read_cback: status(2)
W (29393) BT_APPL: bta_ag_sco_read_cback: status(2)
I (29703) BT_APP_HF: speed(26.177318s ~ 29.177335s): 255.998566 kbit/s
W (29763) BT_APPL: bta_ag_sco_read_cback: status(2)
W (30143) BT_APPL: bta_ag_sco_read_cback: status(2)
W (30513) BT_APPL: bta_ag_sco_read_cback: status(2)
W (30893) BT_APPL: bta_ag_sco_read_cback: status(2)
W (31263) BT_APPL: bta_ag_sco_read_cback: status(2)