Esp32-snippets: Can you wipe all bonding info?

Created on 2 Feb 2019  路  3Comments  路  Source: nkolban/esp32-snippets

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?

enhancement

Most helpful comment

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);
}

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Smeedy picture Smeedy  路  5Comments

Tavo7995 picture Tavo7995  路  7Comments

Lakoja picture Lakoja  路  8Comments

vicatcu picture vicatcu  路  4Comments

frankipl picture frankipl  路  8Comments