ArduinoBLE icon indicating copy to clipboard operation
ArduinoBLE copied to clipboard

Disconnected Event does not fire

Open Sladerix opened this issue 2 years ago • 0 comments

Hi everyone. This is my setup.

An ESP32 running as BLE Server An nRF52840 mbed board (XIAO BLE Sense) running as BLE 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);
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 ?

Sladerix avatar Oct 26 '22 14:10 Sladerix