Skip to content

Commit 045344e

Browse files
committed
[Bugfix] Delete all bonds does not allow re-pairing.
This change iterates through each bond and unpairs it rather than just deleting the bond data in nvs, allowing a connected peer to rebond.
1 parent 3c4ec51 commit 045344e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/NimBLEDevice.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,13 @@ int NimBLEDevice::getNumBonds() {
632632
* @returns True on success.
633633
*/
634634
bool NimBLEDevice::deleteAllBonds() {
635-
int rc = ble_store_clear();
636-
if (rc != 0) {
637-
NIMBLE_LOGE(LOG_TAG, "Failed to delete all bonds; rc=%d", rc);
638-
return false;
635+
int numBonds = NimBLEDevice::getNumBonds();
636+
for (int i = numBonds - 1; i >= 0; i--) {
637+
auto addr = NimBLEDevice::getBondedAddress(i);
638+
if (!NimBLEDevice::deleteBond(addr)) {
639+
NIMBLE_LOGE(LOG_TAG, "Failed to delete bond for address: %s", addr.toString().c_str());
640+
return false;
641+
}
639642
}
640643
return true;
641644
}

0 commit comments

Comments
 (0)