I have an ESP32 device and an Arduino-IDE project working. I am looking to have the device play sound effects (either .wav or .mp3) to a normal Bluetooth speaker. I have found many examples where the device was the receiver (SINK) and some where data was just streamed from the ESP, but I have not found any libraries or examples that PAIR with an external speaker and send sounds/music. Any help would be appreciated. This is all new territory for me
Am looking at both the ble and Bluetooth serial example sets. I see a Bluetooth serial example that removes “bonded” (with I assume means paired) devices but I must be missing the code that adds a bonded device. Can you point me in the right direction ?
I have made a bunch of progress... Using A2DP_source, I can now successfully play a wav file (once) to the speaker. The wav is just a bell ringing twice. Plays fine. When I try to play it again, only half of the file plays (can't tell which half since both are the same). Any ideas? If I disconnect and reconnect, then it takes forever! Want to keep it connected but just have it go silent until the next event.
How does it go if you play your bell track more simply?
Without all the buttonAction jazz?
I see that you're using delay() and millis().
(delay() messes up millis(), BTW.)
With your loop()
polling for a pushbutton click.
If you get a click play the test track.
If I play the bell continuously, then it sounds correct. It's when I stop and restart that it messes up.
I have tried:
Looping within the callback until it's time to play again
Returning zero frames from the callback until it's time to play
Returning 1 frame with zeros
Returning all frames with zeros
All seem to give the same results. I have also tried a different bluetooth speaker and it doesn't connect at all. I suspect it needs a more involved pair/bind implementation.