chore(core): expose BLE connection flags to python
What changed, and why it matters
This commit adds read-only functions that expose Bluetooth Low Energy (BLE) connection and pairing status to Python code running on the Trezor device. It does not change how BLE behaves, how it is paired, or how data is protected. It only makes existing internal state information visible to higher-level software.
No security action required. Treat as routine instrumentation. If reviewing a larger feature, confirm that callers using these flags do not make security decisions solely based on connectability or pairing-request state without additional authentication checks.
Security signals we found
No new input parsing or memory allocation beyond a fixed boolean return
No changes to BLE pairing, bonding, or encryption logic
No privilege boundary changes; only read-only state exposure
No changelog entry, consistent with a minor chore/instrumentation change
Evidence from the diff
The patch registers three new MicroPython-callable functions in the trezorble module: is_connectable(), is_pairing(), and is_pairing_requested(). These wrap existing Rust BLE state accessors and return booleans. A companion list-returning function, connection_flags(), is already present. The change is purely informational and adds no new BLE logic, authentication bypass, or cryptographic handling.
Changed components
core/embed/rust/src/trezorhal/ble/micropython.rscore/embed/rust/librust_qstr.hcore/mocks/generated/trezorble.pyiInspect captured patch +54 / −0
diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h
index d4d5c77f3..285f32307 100644
--- a/core/embed/rust/librust_qstr.h
+++ b/core/embed/rust/librust_qstr.h
@@ -361,8 +361,11 @@ static void _librust_qstrs(void) {
MP_QSTR_instructions__view_all_data;
MP_QSTR_instructions_verb;
MP_QSTR_interface;
+ MP_QSTR_is_connectable;
MP_QSTR_is_connected;
MP_QSTR_is_data;
+ MP_QSTR_is_pairing;
+ MP_QSTR_is_pairing_requested;
MP_QSTR_is_type_of;
MP_QSTR_items;
MP_QSTR_joint__title;
diff --git a/core/embed/rust/src/trezorhal/ble/micropython.rs b/core/embed/rust/src/trezorhal/ble/micropython.rs
index a2d35acef..6401b2c7e 100644
--- a/core/embed/rust/src/trezorhal/ble/micropython.rs
+++ b/core/embed/rust/src/trezorhal/ble/micropython.rs
@@ -105,6 +105,18 @@ extern "C" fn py_is_connected() -> Obj {
is_connected().into()
}
+extern "C" fn py_is_connectable() -> Obj {
+ is_connectable().into()
+}
+
+extern "C" fn py_is_pairing() -> Obj {
+ is_pairing().into()
+}
+
+extern "C" fn py_is_pairing_requested() -> Obj {
+ is_pairing_requested().into()
+}
+
extern "C" fn py_connection_flags() -> Obj {
let block = || {
let mut result = List::with_capacity(4)?;
@@ -281,6 +293,24 @@ pub static mp_module_trezorble: Module = obj_module! {
/// """
Qstr::MP_QSTR_is_connected => obj_fn_0!(py_is_connected).as_obj(),
+ /// def is_connectable() -> bool:
+ /// """
+ /// True if a central/host can connect.
+ /// """
+ Qstr::MP_QSTR_is_connectable => obj_fn_0!(py_is_connectable).as_obj(),
+
+ /// def is_pairing() -> bool:
+ /// """
+ /// True if BLE is in pairing mode, waiting for a pairing request.
+ /// """
+ Qstr::MP_QSTR_is_pairing => obj_fn_0!(py_is_pairing).as_obj(),
+
+ /// def is_pairing_requested() -> bool:
+ /// """
+ /// True if BLE pairing request was received.
+ /// """
+ Qstr::MP_QSTR_is_pairing_requested => obj_fn_0!(py_is_pairing_requested).as_obj(),
+
/// def connection_flags() -> list[str]:
/// """
/// Returns current connection state as a list of string flags.
diff --git a/core/mocks/generated/trezorble.pyi b/core/mocks/generated/trezorble.pyi
index 02f26bb8d..89b442dbe 100644
--- a/core/mocks/generated/trezorble.pyi
+++ b/core/mocks/generated/trezorble.pyi
@@ -97,6 +97,27 @@ def is_connected() -> bool:
"""
+# rust/src/trezorhal/ble/micropython.rs
+def is_connectable() -> bool:
+ """
+ True if a central/host can connect.
+ """
+
+
+# rust/src/trezorhal/ble/micropython.rs
+def is_pairing() -> bool:
+ """
+ True if BLE is in pairing mode, waiting for a pairing request.
+ """
+
+
+# rust/src/trezorhal/ble/micropython.rs
+def is_pairing_requested() -> bool:
+ """
+ True if BLE pairing request was received.
+ """
+
+
# rust/src/trezorhal/ble/micropython.rs
def connection_flags() -> list[str]:
"""
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.