I am implementing a BLE peripheral in my firmware with Arduino ESP32.
When the central gets connected to it, I'd like to log the name of the central & its address.
How can I do that?
#include <BLEServer.h>
class ServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
ble.log("ServerCallbacks: Connected");
// ==> how can I add the connected device ID or name in the log?
ble.deviceConnected = true;
#if SUPPORT_LEDS_INDICATOR
// === Show France flag colors
// RGBW = 1,2,3, 4
// CODE : BBWRR
// CODE = 33411
const String code = "BBWRR";
ledIndicator.showAccessCode(code);
#endif
#if SUPPORT_BUZZER
/// BLE connection jingle
buzzer.playBleConnectedMelody();
#endif
};
void onDisconnect(BLEServer* pServer) {
ble.deviceConnected = false;
ble.log("ServerCallbacks: Disconnected");
#if SUPPORT_BUZZER
/// BLE connection jingle
buzzer.playBleDisconnectedMelody();
#endif
}
};
/// Somewhere in the setup:
server = BLEDevice::createServer();
// == Set up our calbacks
server->setCallbacks(new ServerCallbacks());