refactor(core): deduplicate BLE_MAX_BONDS
What changed, and why it matters
This commit is a simple code cleanup: it removes a duplicate definition of the Bluetooth pairing limit (BLE_MAX_BONDS) from a Python file and exposes the existing Rust constant to Python instead. There is no security issue here.
No action needed. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change deduplicates the BLE_MAX_BONDS constant. Previously it was defined as 8 in both core/src/apps/homescreen/device_menu.py (Python) and the Rust BLE module. The commit removes the Python-side constant and exposes the Rust BLE_MAX_BONDS as trezorble.MAX_BONDS so both sides use the same source of truth. The value remains unchanged.
Changed components
Trezor Core firmwareBluetooth LE bonding/Paired devices UIInspect captured patch +5 / −2
diff --git a/core/embed/rust/librust_qstr.h b/core/embed/rust/librust_qstr.h
index fd02653fd..8fee1c872 100644
--- a/core/embed/rust/librust_qstr.h
+++ b/core/embed/rust/librust_qstr.h
@@ -34,6 +34,7 @@ static void _librust_qstrs(void) {
MP_QSTR_LayoutObj;
MP_QSTR_LayoutState;
MP_QSTR_MAX;
+ MP_QSTR_MAX_BONDS;
MP_QSTR_MESSAGE_NAME;
MP_QSTR_MESSAGE_WIRE_TYPE;
MP_QSTR_MessageType;
diff --git a/core/embed/rust/src/trezorhal/ble/micropython.rs b/core/embed/rust/src/trezorhal/ble/micropython.rs
index 90bbf563c..5349d6c32 100644
--- a/core/embed/rust/src/trezorhal/ble/micropython.rs
+++ b/core/embed/rust/src/trezorhal/ble/micropython.rs
@@ -282,6 +282,9 @@ static BLE_INTERFACE_OBJ: SimpleTypeObj = SimpleTypeObj::new(&BLE_INTERFACE_TYPE
pub static mp_module_trezorble: Module = obj_module! {
Qstr::MP_QSTR___name__ => Qstr::MP_QSTR_trezorble.to_obj(),
+ /// MAX_BONDS: int
+ Qstr::MP_QSTR_MAX_BONDS => Obj::small_int(BLE_MAX_BONDS as u16),
+
/// class BLEIF:
/// """
/// BLE interface wrapper.
diff --git a/core/mocks/generated/trezorble.pyi b/core/mocks/generated/trezorble.pyi
index bd483a4f1..c91dab08c 100644
--- a/core/mocks/generated/trezorble.pyi
+++ b/core/mocks/generated/trezorble.pyi
@@ -1,5 +1,6 @@
from typing import *
from buffer_types import *
+MAX_BONDS: int
# rust/src/trezorhal/ble/micropython.rs
diff --git a/core/src/apps/homescreen/device_menu.py b/core/src/apps/homescreen/device_menu.py
index 2af4ccb30..8ed4697a0 100644
--- a/core/src/apps/homescreen/device_menu.py
+++ b/core/src/apps/homescreen/device_menu.py
@@ -15,8 +15,6 @@ if TYPE_CHECKING:
from trezor.messages import ThpPairedCacheEntry
-BLE_MAX_BONDS = 8
-
# Must be in sync with the DeviceMenuId in device_menu.ui
class SubmenuId:
Why this scored 15/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.