mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-01 15:52:02 +00:00
feat(ble): add command to erase bond belonging to currently connected device
[no changelog]
This commit is contained in:
parent
acd841c9fa
commit
cb4d062e7c
@ -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
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/conn.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user