My steps to show the problem. I won't mention pairing, as that doesn't seem related. So after I have a paired esp32 to my android phone, here is what I do:
android bluetooth is on, paired to a ble audio device (logitech speakers for music) and paired to this esp32 as a keyboard (for media controls)
esp32 is on, and is sending "bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);" every 5 seconds. This is inside a check for "if(bleKeyboard.isConnected())"
everything is working great.
power cycle the est32 by hitting reset button
devices reconnect to each other after just a few seconds over bluetooth, and per logging I see that the isConnected check passes.
KEY_MEDIA_PLAY_PAUSE presses are being logged but are NOT working
After a few logs showing the failure, I turn off bluetooth on android, and turn it back on after just a second or two.
it reconnects again, and now it works for KEY_MEDIA_PLAY_PAUSE
Here is the simple code:
include
BleKeyboard bleKeyboard;
void setup() {
Serial.begin(115200);
Serial.println("Starting BLE work!");
bleKeyboard.begin();
}
void loop() {
if(bleKeyboard.isConnected()) {
delay(1000);
Serial.println("Sending Play/Pause media key...");
bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
delay(1000);
My steps to show the problem. I won't mention pairing, as that doesn't seem related. So after I have a paired esp32 to my android phone, here is what I do:
Here is the simple code: