bluekitchen / btstack

Dual-mode Bluetooth stack, with small memory footprint.
http://bluekitchen-gmbh.com
Other
1.74k stars 618 forks source link

how to configure pcm format ? #482

Closed zhou88mang closed 1 year ago

zhou88mang commented 1 year ago

hello ! I have successfully implemented the Bluetooth function using btstack + esp-hosted, but there was one problem, on esp32 menuconfig ,i set BR/EDR Sync(SCO/eSCO) default datapath PCM . By measuring the output pin of the pcm, I found that the format of these signals were i2s format , but the signal I really want is PCM format( mode A or mode B), is there any way to configure the format of these output signals?

I would like to know if it is possible to set the format of pcm data output from the esp32 controller through hci command , if possible, what i need to do ?

mringwal commented 1 year ago

There's no standard HCI command to configure default SCO output path. On other Controllers, this is possible via vendor-specific commands. On the ESP32 with esp-hosted, you could configure it locally. If you look at esp-idf Bluetooth API https://github.com/espressif/esp-idf/blob/dc016f5987/components/bt/include/esp32/include/esp_bt.h there are a few PCM related options. Maybe this helps/

There are also newer HCI commands to setup an SCO connection that allow to configure PCM. I don't know if they are supported by esp-hosted. BTstack currently does not use these newer command (Enhanced Setup Synchronous Connection and Enhanced Accept Synchronous Connection).

Alternatively, as SCO over HCI works well on the ESP32, you could configure it for that and then output audio over I2S in a modified version of esp-hosted - by this, you're in full control of the PCM/I2S signal.