1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-20 09:09:02 +00:00

feat(nordic): add pairing complete/canceled messages

[no changelog]
This commit is contained in:
tychovrahe 2025-04-10 20:08:44 +02:00
parent bb00144e05
commit 55fea7ebcb
3 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,7 @@ typedef enum {
INTERNAL_EVENT_PAIRING_REQUEST = 0x04,
INTERNAL_EVENT_PAIRING_CANCELLED = 0x05,
INTERNAL_EVENT_MAC = 0x06,
INTERNAL_EVENT_PAIRING_COMPLETED = 0x07,
} internal_event_t;
typedef enum {
@ -112,6 +113,8 @@ void ble_management_send_status_event(void);
void ble_management_send_pairing_request_event(uint8_t *data, uint16_t len);
// Send Pairing Cancelled event
void ble_management_send_pairing_cancelled_event(void);
// Send Pairing Completed event
void ble_management_send_pairing_completed(void);
// Bonds
// Erase all bonds

View File

@ -96,6 +96,14 @@ void ble_management_send_pairing_request_event(uint8_t *data, uint16_t len) {
trz_comm_send_msg(NRF_SERVICE_BLE_MANAGER, tx_data, sizeof(tx_data));
}
void ble_management_send_pairing_completed(void) {
uint8_t tx_data[1] = {0};
tx_data[0] = INTERNAL_EVENT_PAIRING_COMPLETED;
trz_comm_send_msg(NRF_SERVICE_BLE_MANAGER, tx_data, sizeof(tx_data));
}
static void management_send_mac(uint8_t *mac) {
uint8_t tx_data[1 + BT_ADDR_SIZE] = {0};
tx_data[0] = INTERNAL_EVENT_MAC;

View File

@ -85,6 +85,8 @@ void pairing_complete(struct bt_conn *conn, bool bonded) {
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
ble_management_send_pairing_completed();
LOG_INF("Pairing completed: %s, bonded: %d", addr, bonded);
}
@ -93,6 +95,8 @@ void pairing_failed(struct bt_conn *conn, enum bt_security_err reason) {
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
ble_management_send_pairing_cancelled_event();
LOG_INF("Pairing failed conn: %s, reason %d", addr, reason);
}