Bluetooth binding/bonding/pairing list of devices

#1

Hi,
When security is enabled and the Mongoose-OS enabled ESP32 device pairs with another device, this device’s address is saved somewhere.
There can be a group of devices.
If for some reason one device is compromised or demised, it needs to be blocked from further actions, then it has to be removed from that list.
If one has more than one device bound/bonded/paired, one would want to retain that database and only remove the affected device in particular.
Flashing erases all devices

My goals are
a) erase only one device from the table/database.
b) preserve that table along firmware updates.
For that, I need to know where the table/db is and/or how to manipulate it.

Anyone with BT/BLE expertise that could save me some time digging in the SDK and source code ?
Thanks.

#2

Information is here:
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/esp_gap_ble.html#functions

include with

#include "esp32_bt_gap.h"

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include "esp_bt.h"
#include "esp_bt_defs.h"
#include "esp_bt_device.h"
#include "esp_gap_ble_api.h"

(taken from bt-common/blob/master/src/esp32/esp32_bt_gap.c)
in particular, I’m interested in these guys:

esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr)
    Removes a device from the security database list of peer device. It manages unpairing event while connected.
    Return
        - ESP_OK : success
            other : failed
    Parameters
            bd_addr: : BD address of the peer device

int esp_ble_get_bond_device_num(void)
    Get the device number from the security database list of peer device. It will return the device bonded number immediately.
    Return
        - >= 0 : bonded devices number.
            ESP_FAIL : failed

esp_err_t esp_ble_get_bond_device_list(int *dev_num, esp_ble_bond_dev_t *dev_list)
    Get the device from the security database list of peer device. It will return the device bonded information immediately.
    Return
        - ESP_OK : success
            other : failed
    Parameters
            dev_num: Indicate the dev_list array(buffer) size as input. If dev_num is large enough, it means the actual number as output. Suggest that dev_num value equal to esp_ble_get_bond_device_num().
            dev_list: an array(buffer) of esp_ble_bond_dev_t type. Use for storing the bonded devices address. The dev_list should be allocated by who call this API.

and will probably post something when and if it works… so far I got a proper device count from esp_ble_get_bond_device_num()