T-vK / ESP32-BLE-Keyboard

Bluetooth LE Keyboard library for the ESP32 (Arduino IDE compatible)
2.28k stars 379 forks source link

How to force a RESET to DEFAULT settings and clear pairing? #177

Open creepscompilation opened 1 year ago

creepscompilation commented 1 year ago

Is there a way to force the ESP32 BLE Keyboard code to CLEAR out any pairing that is saved?

Right now, there is only one way to clear out the pairing once the BLE keyboard is paired and connected, The Bluetooth host must disconnect.

I am hoping to allow a user to CLEAR the current connection that is paired without needing the host device.

Guillemete commented 1 year ago

Found this solution not long ago, Worked for me

void remove_all_bonded_devices(void) { int dev_num = esp_ble_get_bond_device_num(); esp_ble_bond_dev_t dev_list = (esp_ble_bond_dev_t )malloc(sizeof(esp_ble_bond_dev_t) * dev_num); esp_ble_get_bond_device_list(&dev_num, dev_list); for (int i = 0; i < dev_num; i++) { esp_ble_remove_bond_device(dev_list[i].bd_addr); }

free(dev_list); }