ESP32 connects to a BT headset, receives audio from BT headset (CVSD codec), however, it is not sending audio to the same BT headset. Callback bt_app_hf_outgoing_cb (see here) almost never gets called. If it ever does, it is followed by a crash exactly like described in #4794 .
Callback bt_app_hf_outgoing_cb is expected to get called to play the sine wave in the headphones.
Callback bt_app_hf_outgoing_cb is not run at all except very rarely and randomly, followed by crashes exactly like described in #4794 .
ESP_LOGI("..."); statement to both bt_app_hf_outgoing_cb and bt_app_hf_incoming_cbBluedroid Options --> Wide Band Speech offBR/EDR Sync(SCO/eSCO) Max Connections to 1 or more (default is 0)make flash monitor (runs HFP AG example)hf con; (if not connected yet)hf cona;Example code for callbacks in bt_app_hf.c:
static uint32_t bt_app_hf_outgoing_cb(uint8_t *p_buf, uint32_t sz)
{
ESP_LOGE(BT_HF_TAG, "bt_app_hf_outgoing_cb");
int sine_phase = esp_random();
for (int i = 0; i < TABLE_SIZE_CVSD; i++) {
p_buf[i * 2] = sine_int16[sine_phase];
p_buf[i * 2 + 1] = sine_int16[sine_phase];
++sine_phase;
if (sine_phase >= TABLE_SIZE_CVSD) {
sine_phase -= TABLE_SIZE_CVSD;
}
}
return sz;
}
static void bt_app_hf_incoming_cb(const uint8_t *buf, uint32_t sz)
{
ESP_LOGE(BT_HF_TAG, "bt_app_hf_incoming_cb, buf size: %d", sz);
// direct to i2s
esp_hf_outgoing_data_ready();
}
I am using Sony SBH20 and Sony WH-1000XM3 headsets, both have the same behaviour.
Thank you.
@pavestru Thanks for reporting, we will look into.
Hi, is there any news on this issue?
Hi. I got the same issue on the newest master. What is the status here? Is it a work in progress?
Same issue here. The outgoing callback hasn't been called once, but the incoming is firing as expected.
Just tested on latest pull from release v4.2 and still got the issue.
My log is just being flooded with the following. Incoming audio (from HFP client) seems ok, but a little glitchy. Certainly nowhere near as stable as A2DP.
W (22802) BT_APPL: bta_ag_sco_read_cback: status(2)
From what I can see this is a warning that there is no data in the SCO layer? Not surprising since the callback isn't being called to retrieve the data.
Just tested on 4.3 and still not working. Is this issue being looked into at Espressif?
Hi @Alvin1Zhang! Have made any progress on this issue?
Thanks for the updates, and sorry for slow turnaround, we are still debugging this issue, will share updates once available. Thanks.
Hi, @pavestru and other users!
I offer a patch to fix this problem, you can have a try. Please let me know if it still has problems. By the way, it is not recommended to print too much information in the callback function.
Hi @boblane1!
I applied the patch you shared to release v4.1 ESP-IDF and this is the result that I got - https://www.youtube.com/watch?v=peONupbGCGs. I don't know if this is what should be expected but it is definitely a step up.
Thank you very much!
For everyone else. To reproduce this effect checkout the ESP-IDF at v4.1, apply the patch from the @boblane1's post, change the SCO path to HCI, disable the Wide Band Speech and change the BR/EDR Sync(SCO/eSCO) Max Connections to 1. Compile, flash, voila!
Most helpful comment
Just tested on 4.3 and still not working. Is this issue being looked into at Espressif?