Skip to content

add A2DP audio source support to board that have a compatible ESP32 - #2

Draft
gagarinlg wants to merge 8 commits into
developfrom
A2DP
Draft

gagarinlg wants to merge 8 commits into
developfrom
A2DP

Conversation

@gagarinlg

Copy link
Copy Markdown
Member

No description provided.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Console contention and ambiguous PCM command detection can corrupt protocol traffic and interrupt playback.

8 open findings
What changed in this PR

Adds Classic Bluetooth A2DP audio output to the existing BLE emulator on compatible ESP32 boards, enabled for RM Pico.

Changes:

  • Adds A2DP connection, discovery, playback, and volume controls.
  • Streams UART PCM through a mono-to-stereo resampler.
  • Adds sender tooling, host tests, build configuration, and documentation.
File Description
tools/​uart_audio_sender.py Adds WAV streaming over UART.
test/​test_main.c Registers resampler tests.
test/​test_audio_resampler.c Tests interpolation and empty input.
test/​test_at_command.c Tests new commands and baud selection.
src/​terminal.c Integrates audio commands and PCM routing.
src/​CMakeLists.txt Includes audio modules in builds.
src/​bt.h Declares Classic Bluetooth initialization.
src/​bt.c Supports switching Bluetooth stacks.
src/​bt_a2dp.h Defines A2DP interfaces.
src/​bt_a2dp.c Implements audio streaming and sink control.
src/​board.h Adds audio baud and Bluetooth roles.
src/​audio_resampler.h Defines the resampling interface.
src/​audio_resampler.c Implements streaming PCM resampling.
src/​at_command.h Adds Bluetooth command identifiers.
src/​at_command.c Parses new Bluetooth commands.
sdkconfig.RM_pico Enables Classic Bluetooth and changes console routing.
README.md Documents audio setup and commands.
platformio.ini Defaults to RM Pico and adds a tone-test build.
doc/​BENCH.md Updates baud command expectations.
AGENTS.md Documents revised UART baud behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdkconfig.RM_pico
Comment on lines +1307 to +1311
CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
# CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_1 is not set
CONFIG_ESP_CONSOLE_UART_NUM=0
CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0
CONFIG_ESP_CONSOLE_UART_TX_GPIO=1
Comment thread src/terminal.c
Comment on lines +527 to +530
} else if (c == '+') {
atPrefixLen = 0;
atcommandlen = 0;
atcommand[atcommandlen++] = '+';
Comment thread src/terminal.c
break;

case AT_CMD_BLEON: {
role_t role = lastBleRole == ROLE_BLE_PERIPHERAL ? ROLE_BLE_PERIPHERAL : ROLE_BLE_CENTRAL;
Comment thread src/terminal.c
case AT_CMD_BLEON: {
role_t role = lastBleRole == ROLE_BLE_PERIPHERAL ? ROLE_BLE_PERIPHERAL : ROLE_BLE_CENTRAL;
write_str("OK+BLEON\r\n");
setRole(role);
Comment thread src/terminal.c
Comment on lines +363 to +364
write_str("OK+A2DPCON\r\n");
a2dp_connect(cmd.argument);
Comment thread src/terminal.c
Comment on lines +509 to +511
} else if (atPrefixLen == 0) {
if (c == 'A') {
atPrefix[atPrefixLen++] = c;
Comment thread src/terminal.c
Comment on lines +766 to +771
bt_addr_t address;
while (bt_a2dp_get_discovery_result(address)) {
char address_text[BT_ADDR_STR_LEN];
write_fmt("OK+DISC:%s\r\n", bt_addr_to_str(address_text, address));
}
if (bt_a2dp_discovery_complete()) {
deadline = time.monotonic() + timeout
received = bytearray()
while time.monotonic() < deadline:
chunk = port.read(256)
@gagarinlg
gagarinlg marked this pull request as draft October 16, 2026 10:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants