Skip to content

Commit

Permalink
feat(ble): add command to erase bond belonging to currently connected…
Browse files Browse the repository at this point in the history
… device

[no changelog]
  • Loading branch information
TychoVrahe committed Jan 14, 2025
1 parent 4d60508 commit 10706f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions west/trezor/trezor-ble/src/ble/ble_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions west/trezor/trezor-ble/src/ble/bonds.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <zephyr/types.h>

#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>

#include <zephyr/logging/log.h>

Expand Down Expand Up @@ -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;
}

0 comments on commit 10706f8

Please sign in to comment.