Do I need to clear bonded devices?
-
- Posts: 3
- Joined: Fri Jul 13, 2018 7:31 am
Do I need to clear bonded devices?
Hi,
When using ble with encryption a bond is made and the long term keys are stored in NVS.
First question: How many bonds can be stored?
Seconds question: What happens when we reach that limit, does it delete the oldest bond to make room for the new one or do I need to clear the bonds with the "esp_ble_remove_bond_device" command?
In the example below it looks like you never need to call the remove bond function. But I can't find anything else about it.
https://github.com/espressif/esp-idf/bl ... emo.c#L537
Thank you.
When using ble with encryption a bond is made and the long term keys are stored in NVS.
First question: How many bonds can be stored?
Seconds question: What happens when we reach that limit, does it delete the oldest bond to make room for the new one or do I need to clear the bonds with the "esp_ble_remove_bond_device" command?
In the example below it looks like you never need to call the remove bond function. But I can't find anything else about it.
https://github.com/espressif/esp-idf/bl ... emo.c#L537
Thank you.
Re: Do I need to clear bonded devices?
I cant answer with 100% accuracy and provide source but if i remember esp32 can store about 12 bonded devices (or whitelisted devices).
esp-idf examples dont implement each single command from API to show how to use it, but as you suspect the oldest bonded device keys should be erased to store new one (not tested myself).
esp-idf examples dont implement each single command from API to show how to use it, but as you suspect the oldest bonded device keys should be erased to store new one (not tested myself).
-
- Posts: 3
- Joined: Fri Jul 13, 2018 7:31 am
Re: Do I need to clear bonded devices?
Ok, thank you.
Re: Do I need to clear bonded devices?
Folks anyone have any pointers on an issue to do with removing bonded devices
I use the esp_bt_gap_remove_bond_device call and it returns ESP_OK for each esp_bd_addr_t
but if I reset the device the bonds are still there
The bonds can be removed If I do the above and then try connect a previous bt device and fail it
So if the "Save gattc cache datato nvs flash" is ticked do I have to deinit the Bt module then reinitialise it to delete the bond
settings in nvs ?
Or have I missed something ?
I use the esp_bt_gap_remove_bond_device call and it returns ESP_OK for each esp_bd_addr_t
but if I reset the device the bonds are still there
The bonds can be removed If I do the above and then try connect a previous bt device and fail it
So if the "Save gattc cache datato nvs flash" is ticked do I have to deinit the Bt module then reinitialise it to delete the bond
settings in nvs ?
Or have I missed something ?
Re: Do I need to clear bonded devices?
It suppose to be fixed already, but if you still have this issue then it is not:
https://github.com/espressif/esp-idf/is ... -434152212
https://github.com/espressif/esp-idf/is ... -434152212
Re: Do I need to clear bonded devices?
Thanks for your response
To help put this more in context of how I am using the commands.
I have written code in C to make the esp32 behave similar to a Bluegiga wt12 modules ASCII commands.
The Esp32 module is run as a classic BT SPP device.
There is a WT12 command eg "SET PAIR *\r\n" that is supposed to clear all pairings. e.g.
so I call
So far every time I have run the code i get the debug msg
Paired device 1 Removed\r\n
Paired device 2 Removed\r\n
Paired device 3 Removed\r\n
etc
I also then have an ascii reset command that calls esp_restart();
When the Esp32 restarts the ram data array with the wt12 emulation is cleared. When the Esp32 BT module is enabled again and I then call
esp_bt_gap_get_bond_device_list() to see if there are paired devices and if there repopulate the pairing array.
Thanks
Dan
To help put this more in context of how I am using the commands.
I have written code in C to make the esp32 behave similar to a Bluegiga wt12 modules ASCII commands.
The Esp32 module is run as a classic BT SPP device.
There is a WT12 command eg "SET PAIR *\r\n" that is supposed to clear all pairings. e.g.
so I call
Code: Select all
/***********************************************************
* Get the numbers of bonded/paired devices to the BT module
* to update the WT12 emulation
************************************************************/
wPairedDevices = esp_bt_gap_get_bond_device_num();
if (wPairedDevices)
{
/************************************************************
* Sanity check so not busting array
******************************************************************************/
if (C_PAIR_MAX_DEVICE < wPairedDevices)
{
wPairedDevices = C_PAIR_MAX_DEVICE;
}
tError = esp_bt_gap_get_bond_device_list(&wDeviceToGet, &tPairedDeviceBtAddr);
if (ESP_OK == tError)
{
[ for (wDeviceToGet = 0; wDeviceToGet < wPairedDevices; wDeviceToGet++)
{
tError = esp_bt_gap_remove_bond_device(tPairedDeviceBtAddr[wDeviceToGet]);
#if C_SHOW_DEBUG_MSGS
if(ESP_OK == tError)
{
ESP_LOGI(BT_TAG, "Paired device %d Removed\r\n", wDeviceToGet); //__func__
}
else //if(ESP_FAIL == tError)
{
ESP_LOGI(BT_TAG, "Paired device %d not accepted by wt12 Emulation \r\n", wDeviceToGet); //__func__
}
#endif
}
}
Paired device 1 Removed\r\n
Paired device 2 Removed\r\n
Paired device 3 Removed\r\n
etc
I also then have an ascii reset command that calls esp_restart();
When the Esp32 restarts the ram data array with the wt12 emulation is cleared. When the Esp32 BT module is enabled again and I then call
esp_bt_gap_get_bond_device_list() to see if there are paired devices and if there repopulate the pairing array.
Thanks
Dan
-
- Posts: 29
- Joined: Wed Aug 09, 2017 6:16 am
Re: Do I need to clear bonded devices?
ESP32 can store 15 bonded devices, it will delete the oldest bonded device to make room for the new one when the device reaches the limit.
Re: Do I need to clear bonded devices?
Weijian-Espressif
Thanks for your clarification 15 is far more than I need.
But in my case I deliberately want to delete all bonding's at a time of my choosing.
So is this a clarification that the function esp_bt_gap_remove_bond_device() and NVS data associated with bonding is suffering from "Unintended behaviour" or have I missed a step ?
Dan
Thanks for your clarification 15 is far more than I need.
But in my case I deliberately want to delete all bonding's at a time of my choosing.
So is this a clarification that the function esp_bt_gap_remove_bond_device() and NVS data associated with bonding is suffering from "Unintended behaviour" or have I missed a step ?
Dan
-
- Posts: 29
- Joined: Wed Aug 09, 2017 6:16 am
Re: Do I need to clear bonded devices?
`esp_bt_gap_remove_bond_device()` is used to remove the classic bluetooth encryption key from flash.
`esp_ble_remove_bond_device()` is used to remove the BLE encryption key from flash.
`esp_ble_remove_bond_device()` is used to remove the BLE encryption key from flash.
Re: Do I need to clear bonded devices?
neither of these calls work correctly I have tried both calls
esp_bt_gap_remove_bond_device()` is used to remove the classic bluetooth encryption key from flash.
esp_ble_remove_bond_device()` is used to remove the BLE encryption key from flash.
When the esp32 device is reset the previous pairings are restored.
So is there another way to overcome this problem eg erase all the NVM associated with the Bluetooth functionality ?
esp_bt_gap_remove_bond_device()` is used to remove the classic bluetooth encryption key from flash.
esp_ble_remove_bond_device()` is used to remove the BLE encryption key from flash.
When the esp32 device is reset the previous pairings are restored.
So is there another way to overcome this problem eg erase all the NVM associated with the Bluetooth functionality ?
Who is online
Users browsing this forum: Bing [Bot] and 132 guests