diff --git a/core/embed/trezorhal/ble.h b/core/embed/trezorhal/ble.h index 894a42b8ef..844b065220 100644 --- a/core/embed/trezorhal/ble.h +++ b/core/embed/trezorhal/ble.h @@ -40,10 +40,11 @@ typedef enum { } ble_command_t; typedef enum { - BLE_NONE = 0, // No event - BLE_CONNECTED = 1, // Connected to a device - BLE_DISCONNECTED = 2, // Disconnected from a device - BLE_PAIRING_REQUEST = 3, // Pairing request received + BLE_NONE = 0, // No event + 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 { diff --git a/core/embed/trezorhal/stm32f4/ble/ble.c b/core/embed/trezorhal/stm32f4/ble/ble.c index 8bd8a1d15f..072e232078 100644 --- a/core/embed/trezorhal/stm32f4/ble/ble.c +++ b/core/embed/trezorhal/stm32f4/ble/ble.c @@ -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; } diff --git a/core/embed/trezorhal/stm32f4/ble/ble_comm_defs.h b/core/embed/trezorhal/stm32f4/ble/ble_comm_defs.h index 4adbe21784..0aceb7db63 100644 --- a/core/embed/trezorhal/stm32f4/ble/ble_comm_defs.h +++ b/core/embed/trezorhal/stm32f4/ble/ble_comm_defs.h @@ -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 {