feat(bt): Add HFP HCI Audio example sketches#12462
Conversation
|
MarcFinns seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
👋 Hello MarcFinns, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
5bc4cea to
a67b9a3
Compare
|
If you need to add custom sdkconfig options, isn't it better to make this example an Arduino as component example ? |
You don't need custom sdk options, there is a matching pull request already accepted. There was an inconsistency, so that an arduino sketch could control the flow of a telephone call, but could not handle the audio. This is now fixed. |
|
@CLAassistant recheck - I’ve signed the CLA! |
|
CLA is a pita sometimes. No worries. I'll merge the libs with your changes and then pull them here for the CI to pass |
|
Would be nice to have the example also use our I2S lib to pass Audio. That would be a realistic example. Also if any buttons are supported, adding those would be nice too. |
Indeed that is how i plan to use the feature, but I have not built the hardware yet! (before wasting time, i wanted to make sure that the software part would be feasible). When done I'll be glad to provide a working example. |
|
You should not need a hardware. The library is pretty basic. Important is to show where and how much to read and write and what should be sample rate, etc. |
|
I will also suggest to make the comments in the code readable by people who are not intimate with HFP/HCI |
|
@me-no-dev Points taken, as soon as i have a minute i will look into it. thanks for your feedback |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
|||||||||||||||||||||||||||||||||||||||
|
Please make sure that the format specifiers follow the rules described in this table: |
Hi @me-no-dev I connected PCM5102A (I2S DAC) and PCM1808 (I2S ADC) Aliexpress breakout boards and a button. |
|
@MarcFinns yes please. Example that runs on actual hardware is always better to have |
Replacing the previous example or adding a new one, then? |
|
replace or make it optional in the example |
@me-no-dev As discussed, I added the example that run on real I2S hardware to the PR #12462 |
There was a problem hiding this comment.
Pull request overview
Adds two new Arduino-ESP32 Bluetooth Classic HFP example sketches demonstrating bidirectional SCO audio over HCI, including a minimal “no hardware” loopback/tone generator and a full I2S audio bridge example for external ADC/DAC hardware.
Changes:
- Added
HFP_HCI_Audioexample sketch with TONE/LOOPBACK modes using anesp_timer+ FreeRTOS buffer to drive HFP SCO TX/RX over HCI. - Added
HFP_HCI_Audio_I2Sexample sketch bridging SCO audio to external I2S hardware (PCM5102A/PCM1808) with automatic codec rate reconfiguration. - Added README + CI metadata for the new examples.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| libraries/ESP32/examples/HFP_HCI_Audio_I2S/README.md | Documents wiring/usage/build requirements for the I2S SCO↔I2S bridge example. |
| libraries/ESP32/examples/HFP_HCI_Audio_I2S/ESP32_HFP_HCI_Audio_I2S.ino | Implements the HFP client + SCO-over-HCI audio path bridged to I2S RX/TX with an ADC capture task and StreamBuffer. |
| libraries/ESP32/examples/HFP_HCI_Audio/ci.yml | Adds CI constraints and required sdkconfig flags for the HFP_HCI_Audio example build. |
| libraries/ESP32/examples/HFP_HCI_Audio/HFP_HCI_Audio.ino | Implements the minimal HFP SCO-over-HCI example with loopback/tone modes and periodic pull triggering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
72db4f6 to
f448a76
Compare
Clarified build requirements for HFP HCI Audio I2S example, specifying that necessary sdkconfig options are enabled in precompiled libraries.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@MarcFinns please sign CLA |
@me-no-dev I did, multiple times. I have 2 email addresses in my profile and i did it with both. It appears signed! |
|
@MarcFinns some syntax errors left to be fixed: https://github.com/espressif/arduino-esp32/actions/runs/24189514220/job/70602927776?pr=12462#step:8:29 |
|
Replace British spellings (initialise/initialisation/behaviour/ minimising/recognisable) with American English equivalents required by the project's codespell pre-commit hook. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@me-no-dev Ahahaha, is this a joke? this side of the pond we use British English..! |
American English is the official spelling used by Espressif: https://mos.espressif.com/general-conventions.html#american-or-british-spelling |
…tions Remove backslash line continuations from // comments inside #define macros — these cause -Werror=comment compilation failures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes
Checklist
Description of Change
Adds two example sketches demonstrating bidirectional SCO audio over HCI using the ESP32 HFP client profile.
HFP_HCI_Audio— Simple example, no external hardware required.Includes a compile-time switch (
AUDIO_MODE) between two modes:AUDIO_MODE_TONE— generates a 1 kHz sine wave and sends it to the phone (TX path test)AUDIO_MODE_LOOPBACK— echoes incoming audio back to the caller (full duplex test)The sketch uses a FreeRTOS StreamBuffer as a ring buffer to decouple the audio producer from the Bluedroid BTA consumer, absorbing scheduling jitter. Both CVSD (8 kHz) and mSBC (16 kHz) codecs are supported transparently.
HFP_HCI_Audio_I2S— Fully functional I2S audio bridge for real hardware.Routes SCO audio between a paired phone and external audio hardware:
The I2S peripheral is reconfigured automatically to match the negotiated codec (CVSD 8 kHz or mSBC 16 kHz). Tested on ESP32 with an iPhone using both codecs.
Test Scenarios
Tested on ESP32 with Arduino-esp32 core using a custom build of the precompiled libraries (see Related links) with an iPhone as the paired phone. Both
AUDIO_MODE_TONEandAUDIO_MODE_LOOPBACKverified working on CVSD and mSBC codecs. The I2S bridge verified working with PCM5102A + PCM1808 on both CVSD and mSBC.Related links
Depends on: espressif/esp32-arduino-lib-builder#360 (merged) — enables
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCIandCONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCIin the precompiled libraries.