-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluetooth Controller: How to send/receive SCO audio packets? (IDFGH-97) #1118
Comments
Hi @mringwal , let me try to answer the first question first. For ESP32 bluetooth controller, SCO packets can be configured with two data path: HCI and PCM, the latter is the path routed to PCM hardware, which is the default setting. I can change the default data path setting to HCI for you. Can you give me some instructions to use your test example so that I can verify my modication? |
hi @mywang-espressif SCO via PCM makes sense (same with all standalone HCI Controllers). If SCO is configured for PCM, can the PCM data be read by the CPU, too? At what pins is the SCO data as PCM/I2S available? To test with SCO via HCI, you could run the hfp_hf example and pair from a mobile phone. With packet log enabled, you should see SCO packets in the log (but the logging will slow you down). Maybe just print a "SCO received" instead in the hfp_hf_demo to make sure that SCO receiving works. hfp_hf example will send a 441 Hz sine wave, so if you call yourself, you should hear a sine. Sending requires SCO Flow Control to work, though. If possible, it would be great to have an esp_... call to configure SCO to either specify the GPIO or select "SCO via HCI" during/after init. |
Hi! How can I configure SCO to get routed over HCI? |
Hello @mywang-espressif, may I know if there is any update on this issue? For your information, here is the log after I'm testing the hfp_hf example.
|
Any progress on this? We've got a few more commercial inquiries about using HSP/HFP with ESP32, but so far that's no possible even with our Bluetooth stack as SCO is not accessible. |
Hi @mringwal, I am sorry for the late response. I have studied this case and there are some issues in the use of SCO/eSCO link. According to our plan, we to resolve the issues within next month, to support such profile as HFP. |
hi @mywang-espressif Thanks for the current status. So, in theory SCO could be routed to GPIOs and works there. How is this configured? Some ideas:
|
Hi @mringwal . The HFP Hands Free Unit is now merged into ESP-IDF master: Audio data path can be set as either: 1.PCM interface or 2. VoHCI. We have provide the menuconfig options in ESP32 bluedroid host, which actually invokes If 1. PCM interface is used, the internal PCM signals from bluetooth IP can be "matrix"ed to GPIO pins, related signals include PCMFSYNC_OUT_IDX, PCMCLK_OUT_IDX, PCMDOUT_IDX, PCMDIN_IDX etc as shown in components/soc/esp32/include/soc/gpio_sig_map.h Currently, some known issues I have found during development are left:
Those are the issues of current state. I am sorry for the incomplete work but we will try to resolve the issues. Suggestions from you are highly valued. |
Hello @mywang-espressif Thanks for the update! From your description it already sounds possible to use HSP/HFP/SCO now. As for the known issues:
I'll give it a try soon. |
hi @mywang-espressif - sorry, it took me so long to give this a try. I've added a call to esp_bredr_sco_datapath_set(ESP_SCO_DATA_PATH_HCI) after esp_bt_controller_enable(ESP_BT_MODE_BTDM): When opening an SCO connection, I don't see SCO packets getting received. What am I missing? Could you do a quick check with the BTstack hfp_hf_demo? If needed, the SCO payload can be set to 120 by setting sco_packet_length to 123 in example/sco_demo_util.c:578. Thanks! |
Just updated to current esp-idf master. Right now, I get this crash on btstack's develop branch for an incoming SCO connection in hfp_hf_demo. ... A10 : 0x3ffbd600 A11 : 0x3ffb824c A12 : 0x03ffffff A13 : 0x02ee03ba Backtrace: 0x4002faf5:0x3ffc0550 0x40030d4b:0x3ffc0570 0x4003a7e5:0x3ffc05a0 0x40087992:0x3ffc05c0 0x400883ab:0x3ffc05e0 0x400820ee:0x3ffc0600 0x4000bfed:0x00000000 0x400883ab: r_rwbtdm_isr_wrapper at intc.c:? 0x400820ee: _xt_lowint1 at /Projects/esp32/esp-idf/components/freertos/xtensa_vectors.S:1105 ================= CORE DUMP START ================= |
I have a need for HFP as well. I will begin testing the code with my setup an report any issues. Thanks for working on this feature! |
So what is the current status? |
Any update for this? |
Any update? |
I just tried again, and while it doesn't crash, I don't seem to receive any SCO packets via HCI ( I did not try sending). Is this a consequence of "The controller-to-host SCO packet flow control does not yet work."? Btw is there an example that uses Bludroid to compare to? |
I really need HFP/HSP profiles... sco data to & from a headset. I need to receive the packets via HCI. Is this being worked on? Is there an ETA on a solution? Any examples planned? |
I am sorry for the late response. There is an error in the comment of function "esp_bredr_sco_datapath_set". This function should be used after an HCI reset command is set to the controller and before (e)SCO link is established. I will fix this issue then. Currently the HFP example using bluedroid is not merged into ESP-IDF. The example will be added later. |
Okay, I may have been unclear in my previous comment. I want functionality similar to VOIP except the routing would be static. A smart phone would facilitate the devices association. Each ESP32 will have a BT headset connected. The mic voice data ((e)sco) would be sent via WIFI to the other device and played on it's headset ((e)sco) and vice versa. The volume and general buttons events would be needed also. The ESP32 would function as a "gateway" of sorts. I understand that there is a problem receiving data from the headset mic and/or sending that data to the host from the controller via HCI. Am I correct? Has that headset-mic->controller->host issue been resolved. Will there be an example illustrating receiving & sending packets to a BT headset via HCI? |
@mywang-espressif Thanks Karl for the hint. When calling "esp_bredr_sco_datapath_set" after HCI Reset, SCO data is sent and received. Excellent! Follow up question: how I can send SCO correctly/optimally? If you try hfp_hf_demo (with SCO_DEMO_MODE = SCO_DEMO_MODE_SINE in sco_demo_util.c) from BTstack's develop branch, there are small glitches on the receiver. The current code monitors the SCO RX packets, does some averaging and then uses a timer to decide when to send the next one - this was done to work with CSR or Broadcom H4 Controllers. It would be easiest/best, when the ESP32 Link Layer could implement the SCO Flow Control from Host to Controller would be supported as with the TI CC2564 - there, BTstack just sends as many packets as there are SCO buffers and gets an HCI Num Complete Event when a packet was sent. Could I just send 'num total sco packets ' - 1 SCO packets initially and then assume that one was sent out whenever I receive an SCO packet? |
Hi! I have a project with HFP profile aimed to use, but there is a problem establishing a bidirectional audio transfer. Either the HF can receive the audio data from AG or the AG can receive them from HF, but not in both directions when the audio connection has been established, and the working direction is set unpredictably. The situation is identical with SCO over HCI and PCM. When the HCI is set as data path, the in and outgoing data callbacks seams to work, they are called at least, but one of them always carry no information tough it should present. |
@mringwal Where did you place the call to esp_bredr_sco_datapath_set( ESP_SCO_DATA_PATH_HCI ) in the file (hfp_hf.c or sco_demo_util.c)? Thanks. |
Any news on HSP working, please? |
@igrr Is anybody looking at this from your side? Looks like @mywang-espressif is no longer active in this thread. The ticket has been open for 2 years, any thing we can do to help out getting this solved? |
Hi all. Sorry for the late reply. We are working on an example which introduces how to use HF, such as connection, sending data and etc. The codes are now under internal reviewing, and will be merged into master. Will update once it gets merged. Thanks. |
Thanks! From the view of BTstack, explaining how to send SCO packets correctly would already be enough to move on as we already have HFP examples for AG and HF. |
Hi all, Confirmed news. The HF example code and AG component with AG example code will be soon available on the Github IDF master branch. Please pay attention to it if you need. Thanks |
@AbnerFederer Thanks for the update! How was the outgoing SCO Flow Control solved? (see original question above). |
Hi @mringwal Please take a look of esp_hf_client_outgoing_data_ready(); API. Thanks |
@AbnerFederer esp_hf_client_outgoing_data_ready() just calls BTA_HfClientCiData(); I'd like to know how to send SCO correctly at VHCI level. I guess I'll try the example and if it works, I'll take a deep dive into Bluedroid sources to see if there are any changes. Thanks. |
Hi @mringwal I just finished HFP AG components and the demo. Plan to dive into it too to do some optimization. Thanks. |
Hi @AbnerFederer, Good news, please keep us informed as soon as you make updates to idf. Thanks. |
Hi all, HFP Unit and AG (components and demo) are available on master branch now. Thanks |
@mringwal Thanks for reporting, feel free to reopen if you still have the issue or create another ticket if you have more issues, thanks. |
Hi, i have similar issue. In HFP_AG example the bt_app_hf_outgoing_cb is not called and bt_app_hf_incoming_cb works properly. |
|
@KollarRichard How is the audio on the receiving side - that was my initial problem here. In BTstack, I've tried to send a constant sine tone to be able to spot any audio problems. |
Hi
Thank you for your support. |
Hi @gaso1111 There is already a Merge Request to enable PCM configuration to Thanks |
Hi @Wth-Esp Thank you very much! |
Hi, @gaso1111 The lib above is for the Master branch. So there might be some updates the host doesn't have. And because of HF-AG is a new feature for release/v4.1, we might not backport the PCM configuration to the release branch pre-to release/v4.1 branch. Thanks |
Hello @ Wth-Esp With best regards |
Hi @gaso1111 Shall I build a lib for you base on the latest release/v4.0? Thanks |
Hello @ Wth-Esp |
Hi @gaso1111 Please help yourself config the PCM mode in menuconfig like photos By the way, I think your question is another issue, so, the next time, please start another issue thread for a new issue. Thanks |
Hello @Wth-Esp I have integrated everything as you have recommended. I was able to start and configure menuconfig. But with build (compiling) it didn't work. You can see the errors in the attachment. What is the problem and how can I get it to work? Best regards |
Hello @ Wth-Esp |
@gaso1111 Here is my commit log for your reference: Thanks |
Hello @Wth-Esp Thank you very much |
This might be more of a 'how can I..?' question then an actual issue (well, I could say my issue is that I cannot find the necessary documentation...)
Does the ESP32 Bluetooth Controller support sending/receiving of SCO packets for Hands-free Profile?
I did a quick test with BTstack's HFP AG example and was able to open an SCO connection.
A connected speaker did receive some noise for a bit (it should have been a sine wave though), but I didn't see a single SCO packet getting received from the Bluetooth Controller via the VHCI interface.
If SCO is supported, what is needed to receive SCO packets via the VHCI interface?
As a follow up: Is there an easy way to track the speed of outgoing SCO packets? The HCI interface defines the HCI_Write_Synchronous_Flow_Control_Enable (which BTstack sends), but I didn't see no Number Completed Packets for the SCO connection.
HCI_Write_Synchronous_Flow_Control_Enable Overview:
Thanks for reading this far!
The text was updated successfully, but these errors were encountered: