diff --git a/west/trezor/trezor-ble/src/ble/ble_internal.h b/west/trezor/trezor-ble/src/ble/ble_internal.h index 232659656a..4cb2d64148 100644 --- a/west/trezor/trezor-ble/src/ble/ble_internal.h +++ b/west/trezor/trezor-ble/src/ble/ble_internal.h @@ -98,6 +98,8 @@ void management_send_pairing_cancelled_event(void); bool bonds_erase_all(void); // Get number of bonded devices int bonds_get_count(void); +// Erase current bond +bool bonds_erase_current(void); // Advertising functions // Initialization diff --git a/west/trezor/trezor-ble/src/ble/bonds.c b/west/trezor/trezor-ble/src/ble/bonds.c index 7725e10ebb..c07c9f6840 100644 --- a/west/trezor/trezor-ble/src/ble/bonds.c +++ b/west/trezor/trezor-ble/src/ble/bonds.c @@ -21,6 +21,7 @@ #include #include +#include #include @@ -31,8 +32,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include "ble_internal.h" - - bool bonds_erase_all(void) { int err = bt_unpair(BT_ID_DEFAULT, BT_ADDR_LE_ANY); if (err) { @@ -57,3 +56,24 @@ int bonds_get_count(void) { return bond_cnt; } + +bool bonds_erase_current(void) { + int err; + struct bt_conn *current = connection_get_current(); + + if (current == NULL) { + return false; + } + + struct bt_conn_info info; + + err = bt_conn_get_info(current, &info); + if (err) { + LOG_ERR("Failed to get connection info (err %d)", err); + return false; + } + + err = bt_unpair(BT_ID_DEFAULT, &info.le.dst); + + return err == 0; +}