Repository navigation
Conversation
Co-authored-by: gagarinlg <54738901+gagarinlg@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Console contention and ambiguous PCM command detection can corrupt protocol traffic and interrupt playback.
8 open findings
Separate UART console from radio data and emit media readiness · New Prevent raw PCM bytes from being misinterpreted as AT commands · New Preserve the active BLE role when enabling BLE · New Restore central trainer-data forwarding on BLEON · New Validate Bluetooth addresses before acknowledging connection requests · New Flush abandoned AT prefixes after UART input stops · New Drain final discovery results before completing the scan · New Preserve partial responses across A2DP setup waits · New
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 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 on lines
+527
to
+530
| } else if (c == '+') { | ||
| atPrefixLen = 0; | ||
| atcommandlen = 0; | ||
| atcommand[atcommandlen++] = '+'; |
| break; | ||
|
|
||
| case AT_CMD_BLEON: { | ||
| role_t role = lastBleRole == ROLE_BLE_PERIPHERAL ? ROLE_BLE_PERIPHERAL : ROLE_BLE_CENTRAL; |
| 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 on lines
+363
to
+364
| write_str("OK+A2DPCON\r\n"); | ||
| a2dp_connect(cmd.argument); |
Comment on lines
+509
to
+511
| } else if (atPrefixLen == 0) { | ||
| if (c == 'A') { | ||
| atPrefix[atPrefixLen++] = 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
marked this pull request as draft
October 16, 2026 10:18
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.