1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-23 15:08:19 +00:00

fix(core/bootloader): close booloader BLE pairing mode dialog on disconnect

[no changelog]
This commit is contained in:
tychovrahe 2025-06-25 10:27:49 +02:00 committed by TychoVrahe
parent a4ea85bd75
commit f966119817
5 changed files with 25 additions and 0 deletions

View File

@ -142,6 +142,9 @@ bool ble_issue_command(ble_command_t *command);
// available. // available.
bool ble_get_event(ble_event_t *event); bool ble_get_event(ble_event_t *event);
// Flushes the BLE event queue
void ble_event_flush(void);
// Retrieves the current state of the BLE module // Retrieves the current state of the BLE module
// //
// Obtains the current operational state of the BLE module. // Obtains the current operational state of the BLE module.

View File

@ -712,6 +712,20 @@ bool ble_get_event(ble_event_t *event) {
return result; return result;
} }
void ble_event_flush(void) {
ble_driver_t *drv = &g_ble_driver;
if (!drv->initialized) {
return;
}
irq_key_t key = irq_lock();
tsqueue_reset(&drv->event_queue);
irq_unlock(key);
}
void ble_get_state(ble_state_t *state) { void ble_get_state(ble_state_t *state) {
const ble_driver_t *drv = &g_ble_driver; const ble_driver_t *drv = &g_ble_driver;

View File

@ -179,6 +179,8 @@ bool ble_iface_start_pairing(void) {
return false; return false;
} }
ble_event_flush();
ble_command_t cmd = { ble_command_t cmd = {
.cmd_type = BLE_PAIRING_MODE, .cmd_type = BLE_PAIRING_MODE,
.data = {.adv_start = .data = {.adv_start =

View File

@ -74,6 +74,9 @@ impl Component for PairingMode {
if let Event::BLE(BLEEvent::PairingCanceled) = event { if let Event::BLE(BLEEvent::PairingCanceled) = event {
return Some(PairingMsg::Cancel); return Some(PairingMsg::Cancel);
} }
if let Event::BLE(BLEEvent::Disconnected) = event {
return Some(PairingMsg::Cancel);
}
None None
} }

View File

@ -74,6 +74,9 @@ impl Component for PairingModeScreen {
if let Event::BLE(BLEEvent::PairingCanceled) = event { if let Event::BLE(BLEEvent::PairingCanceled) = event {
return Some(PairingMsg::Cancel); return Some(PairingMsg::Cancel);
} }
if let Event::BLE(BLEEvent::Disconnected) = event {
return Some(PairingMsg::Cancel);
}
None None
} }