1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-04 12:56:25 +00:00

chore(core): hide ble interface when not supported

This commit is contained in:
M1nd3r 2025-04-29 12:55:11 +02:00
parent a567f47102
commit 961a405387

View File

@ -1,7 +1,11 @@
from typing import TYPE_CHECKING
import trezorble as ble
import usb
from trezor import utils
if utils.USE_BLE:
import trezorble as ble
_WIRE_INTERFACE_USB = b"\x01"
_WIRE_INTERFACE_BLE = b"\x02"
@ -17,11 +21,13 @@ def decode_iface(cached_iface: bytes) -> WireInterface:
if iface is None:
raise RuntimeError("There is no valid USB WireInterface")
return iface
elif cached_iface == _WIRE_INTERFACE_BLE:
iface = ble.interface
if iface is None:
raise RuntimeError("There is no valid BLE WireInterface")
return iface
if utils.USE_BLE:
if cached_iface == _WIRE_INTERFACE_BLE:
iface = ble.interface
if iface is None:
raise RuntimeError("There is no valid BLE WireInterface")
return iface
raise Exception("Unknown WireInterface")
@ -29,6 +35,7 @@ def encode_iface(iface: WireInterface) -> bytes:
"""Encode wire interface into bytes."""
if iface is usb.iface_wire:
return _WIRE_INTERFACE_USB
if iface is ble.interface:
return _WIRE_INTERFACE_BLE
if utils.USE_BLE:
if iface is ble.interface:
return _WIRE_INTERFACE_BLE
raise Exception("Unknown WireInterface")