diff --git a/west/trezor/trezor-ble/src/ble/ble_internal.h b/west/trezor/trezor-ble/src/ble/ble_internal.h index 232659656a7..4cb2d641487 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 7725e10ebb0..e9ec70e77de 100644 --- a/west/trezor/trezor-ble/src/ble/bonds.c +++ b/west/trezor/trezor-ble/src/ble/bonds.c @@ -21,6 +21,7 @@ #include <zephyr/types.h> #include <zephyr/bluetooth/bluetooth.h> +#include <zephyr/bluetooth/conn.h> #include <zephyr/logging/log.h> @@ -57,3 +58,26 @@ 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; +}