This is my setup.
- An ESP32 running as BLE Server
- An nRF52840 mbed board (XIAO BLE Sense) running as BLE Client
The problem is on the Client
Everything seems to work apart for the Disconnected event...
This is the code I almost copy/pasted from the documentation:
// BLE initialization
if (!BLE.begin()) {
Serial.println("Starting Bluetooth® Low Energy module failed!");
while (1);
}
MAC = BLE.address().c_str();
Serial.print("BLE MAC: "); Serial.println(MAC.c_str());
BLE.setEventHandler(BLEConnected, bleCentralConnectHandler);
BLE.setEventHandler(BLEDisconnected, bleCentralDisconnectHandler);
Here there are the actual callback functions:
void bleCentralConnectHandler(BLEDevice peripheral) {
// central connected event handler
Serial.print("Connected event, peripheral: ");
Serial.println(peripheral.address());
}
void bleCentralDisconnectHandler(BLEDevice peripheral) {
// central disconnected event handler
Serial.print("Disconnected event, peripheral: ");
Serial.println(peripheral.address());
startScanning();
}
I let them connect and then powering off the ESP32... I expected to see "Disconnected event, peripheral:...." but nothing shows up...
P.S. The connected event fires correctly
What could be ?