Open bobsupercow opened 2 years ago
Tested following addition successfully. Could be significantly more robust since this only handles a single connection handle.
Call from my code:
bluemicro_hid.disconnectBLE();
void HID_Queues::disconnectBLE()
{
uint16_t connectionHandle = 0;
BLEConnection* connection = NULL;
connectionHandle = Bluefruit.connHandle();
connection = Bluefruit.Connection(connectionHandle);
delay(2000);
connection->disconnect();
Bluefruit.Advertising.stop();
Bluefruit.Advertising.clearData();
Bluefruit.ScanResponse.clearData(); // add this
Bluefruit.Periph.clearBonds();
Bluefruit.Central.clearBonds();
delay(2000);
setupBLE(_manufacturer,_model,_power);
}
I want to split this in different issues. this one for forcing a disconnect. A new one for pairing to multiple devices.
I have functionality in my BlueMicro_BLE firmware here I want to move to this library so that multiple profiles can be used.
Note that clearbonds completely disconnects and "forgets" the connection details on the device but not on the computer. Reconnecting to the computer might need to go through the process of "forgetting" on the computer and re-connecting/re-pairing. Using profiles, you don't loose the pairing information, you just create a new pair to use with another computer. This would be a better experience for most people.
With the current setup, I cannot trigger a BLE disconnect to trigger pairing mode, or swap to another, already paired device.
Use case is an NRF52840 that is sealed up in a case and not easily accessible. Ideally, we should be able to trigger either a swap or disconnect/pairing programmatically, or even via a particular keycode.
Can you present the underlying Bluefruit.connection for this.
Similar code using Bluefruit library directly: