Bluetooth Speaker Relay
Experimental ESP32 SBC relay over Bluetooth Classic L2CAP. Two-board relay tested with phone A2DP maintained; acoustic alignment remains unverified.
- Stars
- 0
- Forks
- 0
- Updated
- 2 mo ago
- Created
- Sep 28, 2026
An experimental Bluetooth Classic audio relay for ESP32 speakers. A phone sends audio over A2DP to one speaker; that speaker forwards the encoded SBC packets to another over L2CAP. Each speaker decodes for its own I2S output. The firmware also contains runtime source election, peer discovery, piconet-clock mapping, and presentation-time playback code. The default audio path does not use Wi-Fi.
phone --A2DP--> source speaker --L2CAP--> peer speaker
encoded SBC + presentation timeThis is research firmware, not a finished synchronized-speaker product. A two-board encoded relay and simultaneous phone/peer Bluetooth connections were observed on hardware. Electrical or acoustic phase alignment of the speaker outputs has not been verified. Three-board branching and connectionless broadcast experiments are documented separately from the default L2CAP path; they should not be read as a demonstrated production audio topology.
What is in this repository
main/: A2DP ingress, SBC forwarding and decoding, runtime role election, piconet-clock conversion, I2S playback, peer management, and optional radio experiments.components/: the controller interface and radio research components used by the project.test/: host-side tests for clock arithmetic, election, packet handling, and research utilities.tools/: build setup and bench-analysis scripts. Historical scripts may require device-specific setup or captures that are not published.idf-overlay/: the 26 local ESP-IDF file versions that differ from the pinned SDK snapshot in ESP32-A2DP-SINK-WITH-CODECS-UPDATED.patches/: a readable unified diff of those SDK changes.docs/andevidence/: research status and selected written experiment notes. Raw serial logs, firmware backups, device memory dumps, generated binaries, and machine-specific build trees are excluded.
Historical bench Bluetooth addresses and user-specific filesystem paths are anonymized in this public snapshot; the original local research tree is kept separately.
The SDK baseline is commit f4eb12517438a486af9e33987114c4823af40aca
of the linked codecs repository. IDF_CHANGES.md explains
why the SDK was modified and how the exact overlay is recorded. The overlay
is applied to a separate checkout; the baseline repository is never rewritten.
Build from source
Use Windows PowerShell, Git, Python 3.11+, and the ESP-IDF prerequisites for
the original ESP32. The setup script fetches the pinned public SDK snapshot
into .deps/ and checks every file hash before applying the overlay.
./tools/setup_idf.ps1
$env:IDF_PATH = (Resolve-Path ./.deps/codec-base/esp-idf).Path
. "$env:IDF_PATH/export.ps1"
python "$env:IDF_PATH/tools/idf.py" buildThe first setup may need the ESP32 toolchain installed with
./.deps/codec-base/esp-idf/install.ps1 esp32. The source project uses
sdkconfig.defaults; per-machine sdkconfig and all build* directories are
ignored. This public source snapshot was built successfully for ESP32 with
the pinned SDK and overlay. Review GPIO definitions in main/bt_relay.c for
the target DAC before flashing. Build success does not prove synchronized
audio on hardware.
Hardware evidence and limits
- The two-board L2CAP relay sent encoded SBC without a decode/re-encode step at the source. The bench status notes report a full-rate synthetic run with zero sender drops and receiver gaps in the captured interval.
- A speaker held a phone A2DP connection and an L2CAP peer connection at the same time for more than 40 seconds in a bench run.
- Runtime election and cross-piconet timestamp translation are implemented; multi-speaker live-phone failover and audible phase alignment still need dedicated hardware measurements.
- The optional CSB experiments have separate build flags and unresolved controller/airtime limits. They are not a claim of scalable broadcast audio.
See STATUS.md for the exact interpretation of the results.
Provenance
Ngoc Viet (William) Ho developed this relay and controller research in a
local Decompiled IDF workspace. This public repository records a curated
source snapshot and its SDK delta. The repo does not contain proprietary
controller binaries; ESP-IDF and codec dependencies come from the pinned
public SDK repository. See THIRD_PARTY_NOTICES.md.
Related
ESP32-S31 Multi-Codec Sink
Multi-codec Bluetooth A2DP audio sink for the ESP32-S31 on ESP-IDF v6.1 — LDAC, aptX/HD/LL, LHDC-v5, Opus, LC3plus, AAC, SBC. Runs entirely on internal SRAM
ESP32 Hi-Fi A2DP Sink
ESP32 hi-res Bluetooth speaker firmware: A2DP sink + AVRCP with LDAC, LHDC V5 (192 kHz/24-bit), aptX, aptX HD, AAC, SBC, Opus and Samsung SSC decoders. Own BT host stack, ESP-IDF 6.1.
BDK Speaker Firmware
ESP32 A2DP speaker firmware on its own Bluetooth host: LHDC V5 up to 192 kHz/24-bit, LDAC, aptX HD/LL, Opus, AAC, an integer-only DSP and a 16×16 LED matrix.
Live demoWalkthrough