I had a really hard time figuring this out but if you modify the BleKeyboard.cpp file and edit void BleKeyboard::end(void) { } with void BleKeyboard::end(void) { BLEDevice::deinit(); } Now you should be able to disconect ble. Right now, the program will auto reconnect so comment out advertising->start(); with //advertising->start(); in the function
void BleKeyboard::onDisconnect(BLEServer* pServer) {
To use this, you have to start advertizing the service with bleKeyboard.begin();. To stop BLE, run bleKeyboard.end();.
To restart BLE simply run bleKeyboard.begin(); again.
I think this would be a good addition to the main code.
I had a really hard time figuring this out but if you modify the BleKeyboard.cpp file and edit
void BleKeyboard::end(void) { }
withvoid BleKeyboard::end(void) { BLEDevice::deinit(); }
Now you should be able to disconect ble. Right now, the program will auto reconnect so comment outadvertising->start();
with//advertising->start();
in the functionvoid BleKeyboard::onDisconnect(BLEServer* pServer) {
To use this, you have to start advertizing the service with
bleKeyboard.begin();
. To stop BLE, runbleKeyboard.end();
. To restart BLE simply runbleKeyboard.begin();
again.I think this would be a good addition to the main code.