I'm able to successfully pair devices using the SampleServer_authentication_passkey example. But I'd like to add a factory reset button to the device, which should clear all bonding info. I couldn't find any reference to this while looking over the header files. What's the easiest way to do this?
Currently there is no option to wipe bonding info with this library. You can search esp32.com forum and there is info how to do it with esp-idf. Its easiest option for now.
Try:
static void __attribute__((unused)) 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);
}
Try:
static void __attribute__((unused)) 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); }
Not sure why, but esp_ble_get_bond_device_num is returning -1. Do I need to do something before that?
Edit: Nvm, this works. Just have to wait for the server to start up.
Most helpful comment
Try: