-
Notifications
You must be signed in to change notification settings - Fork 240
Open
Description
My use case requires full control over the BLE lifecycle:
- When a device is connected, I need to stop advertising.
- When the user requests it, the device should be able to disconnect cleanly.
- Later, the user should be able to restart advertising and allow a new connection.
I could not find any way to achieve this with the current API.
I tried calling NimBLE APIs directly, but ESP32-BLE-Gamepad automatically reconnects the device as soon as I disconnect it. Also, BleGamepad::end() does not stop the server, does not stop advertising, and does not disconnect the client.
Here is a minimal example of what I attempted:
if (bleGamepad.isConnected()) {
NimBLEServer* server = NimBLEDevice::getServer();
if (server) {
NimBLEAdvertising* advertising = server->getAdvertising();
if (advertising) {
advertising->stop();
}
NimBLEConnInfo connInfo = bleGamepad.getPeerInfo();
server->disconnect(connInfo, BLE_ERR_REM_USER_CONN_TERM);
}
}
bleGamepad.end();
Thank you.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels