1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-21 04:41:18 +00:00

driver: pairing cancel

This commit is contained in:
tychovrahe 2024-11-08 13:11:20 +01:00
parent aef254c92f
commit a754ed0280
3 changed files with 20 additions and 4 deletions

View File

@ -44,6 +44,7 @@ typedef enum {
BLE_CONNECTED = 1, // Connected to a device
BLE_DISCONNECTED = 2, // Disconnected from a device
BLE_PAIRING_REQUEST = 3, // Pairing request received
BLE_PAIRING_CANCELLED = 4, // Pairing was cancelled by host
} ble_event_type_t;
typedef struct {

View File

@ -191,6 +191,17 @@ static void ble_process_rx_msg_pairing_request(const uint8_t *data,
tsqueue_insert(&drv->event_queue, (uint8_t *)&event, sizeof(event), NULL);
}
static void ble_process_rx_msg_pairing_cancelled(const uint8_t *data,
uint32_t len) {
ble_driver_t *drv = &g_ble_driver;
if (!drv->initialized) {
return;
}
ble_event_t event = {.type = BLE_PAIRING_CANCELLED, .data_len = 0};
tsqueue_insert(&drv->event_queue, (uint8_t *)&event, sizeof(event), NULL);
}
static void ble_process_rx_msg(const uint8_t *data, uint32_t len) {
switch (data[0]) {
case INTERNAL_EVENT_STATUS:
@ -199,6 +210,9 @@ static void ble_process_rx_msg(const uint8_t *data, uint32_t len) {
case INTERNAL_EVENT_PAIRING_REQUEST:
ble_process_rx_msg_pairing_request(data, len);
break;
case INTERNAL_EVENT_PAIRING_CANCELLED:
ble_process_rx_msg_pairing_cancelled(data, len);
break;
default:
break;
}

View File

@ -43,6 +43,7 @@ typedef struct {
typedef enum {
INTERNAL_EVENT_STATUS = 0x01,
INTERNAL_EVENT_PAIRING_REQUEST = 0x04,
INTERNAL_EVENT_PAIRING_CANCELLED = 0x05,
} InternalEvent_t;
typedef enum {