|
|
7 лет назад | |
|---|---|---|
| .. | ||
| main | 7 лет назад | |
| CMakeLists.txt | 7 лет назад | |
| Makefile | 7 лет назад | |
| README.md | 7 лет назад | |
| sdkconfig.defaults | 7 лет назад | |
Demo of A2DP audio source role
This is the demo of using Advanced Audio Distribution Profile APIs to transmit audio stream. Application can take advantage of this example to implement portable audio players or microphones to transmit audio stream to A2DP sink devices.
This example is able to run on any commonly available ESP32 development board. And is supposed to connect to A2DP sink example in ESP-IDF.
make menuconfig
Set serial port under Serial Flasher Options.
Enable Classic Bluetooth and A2DP under Component config --> Bluetooth --> Bluedroid Enable
Build the project and flash it to the board, then run monitor tool to view serial output.
make -j4 flash monitor
(To exit the serial monitor, type Ctrl-].)
For the first step, this example performs device discovery to search for a target device(A2DP sink) whose device name is "ESP_SPEAKER" and whose "Rendering" bit of its Service Class field is set in its Class of Device. If a candidate target is found, the local device will initiate connection with it.
After connection with A2DP sink is established, the example performs the following running loop 1-2-3-4-1:
The example implements an event loop triggered by a periodic "heart beat" timer and events from Bluetooth protocol stack callback functions.
After the local device discovers the target device and initiates connection, there will be logging message like this:
I (4090) BT_AV: Found a target device, address 24:0a:c4:02:0e:ee, name ESP_SPEAKER
I (4090) BT_AV: Cancel device discovery ...
I (4100) BT_AV: Device discovery stopped.
I (4100) BT_AV: a2dp connecting to peer: ESP_SPEAKER
If connection is set up successfully, there will be such message:
I (5100) BT_AV: a2dp connected
Start of audio transmission has the following notification message:
I (10880) BT_AV: a2dp media ready checking ...
...
I (10880) BT_AV: a2dp media ready, starting ...
...
I (11400) BT_AV: a2dp media start successfully.
Stop of audio transmission, and disconnection with remote device generate the following notification message:
I (110880) BT_AV: a2dp media stopping...
...
I (110920) BT_AV: a2dp media stopped successfully, disconnecting...
...
I (111040) BT_AV: a2dp disconnected