From a0afc0f0bb20afba79f456d703593d58b351aa3b Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Wed, 12 Mar 2025 14:10:00 +0100 Subject: [PATCH] feat(core): add ble wire interface to interface manager --- core/src/trezor/wire/thp/interface_manager.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/trezor/wire/thp/interface_manager.py b/core/src/trezor/wire/thp/interface_manager.py index a1fecfe7d6..b8d2b6fee6 100644 --- a/core/src/trezor/wire/thp/interface_manager.py +++ b/core/src/trezor/wire/thp/interface_manager.py @@ -1,9 +1,10 @@ from typing import TYPE_CHECKING import usb +import bluetooth _WIRE_INTERFACE_USB = b"\x01" -# TODO _WIRE_INTERFACE_BLE = b"\x02" +_WIRE_INTERFACE_BLE = b"\x02" if TYPE_CHECKING: from trezorio import WireInterface @@ -16,7 +17,11 @@ def decode_iface(cached_iface: bytes) -> WireInterface: if iface is None: raise RuntimeError("There is no valid USB WireInterface") return iface - # TODO implement bluetooth interface + elif cached_iface == _WIRE_INTERFACE_BLE: + iface = bluetooth.iface_ble + if iface is None: + raise RuntimeError("There is no valid BLE WireInterface") + return iface raise Exception("Unknown WireInterface") @@ -24,5 +29,6 @@ def encode_iface(iface: WireInterface) -> bytes: """Encode wire interface into bytes.""" if iface is usb.iface_wire: return _WIRE_INTERFACE_USB - # TODO implement bluetooth interface + if iface is bluetooth.iface_ble: + return _WIRE_INTERFACE_BLE raise Exception("Unknown WireInterface")