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:
parent
a567f47102
commit
961a405387
@ -1,7 +1,11 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import trezorble as ble
|
|
||||||
import usb
|
import usb
|
||||||
|
from trezor import utils
|
||||||
|
|
||||||
|
if utils.USE_BLE:
|
||||||
|
import trezorble as ble
|
||||||
|
|
||||||
|
|
||||||
_WIRE_INTERFACE_USB = b"\x01"
|
_WIRE_INTERFACE_USB = b"\x01"
|
||||||
_WIRE_INTERFACE_BLE = b"\x02"
|
_WIRE_INTERFACE_BLE = b"\x02"
|
||||||
@ -17,11 +21,13 @@ def decode_iface(cached_iface: bytes) -> WireInterface:
|
|||||||
if iface is None:
|
if iface is None:
|
||||||
raise RuntimeError("There is no valid USB WireInterface")
|
raise RuntimeError("There is no valid USB WireInterface")
|
||||||
return iface
|
return iface
|
||||||
elif cached_iface == _WIRE_INTERFACE_BLE:
|
if utils.USE_BLE:
|
||||||
iface = ble.interface
|
if cached_iface == _WIRE_INTERFACE_BLE:
|
||||||
if iface is None:
|
iface = ble.interface
|
||||||
raise RuntimeError("There is no valid BLE WireInterface")
|
if iface is None:
|
||||||
return iface
|
raise RuntimeError("There is no valid BLE WireInterface")
|
||||||
|
return iface
|
||||||
|
|
||||||
raise Exception("Unknown WireInterface")
|
raise Exception("Unknown WireInterface")
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +35,7 @@ def encode_iface(iface: WireInterface) -> bytes:
|
|||||||
"""Encode wire interface into bytes."""
|
"""Encode wire interface into bytes."""
|
||||||
if iface is usb.iface_wire:
|
if iface is usb.iface_wire:
|
||||||
return _WIRE_INTERFACE_USB
|
return _WIRE_INTERFACE_USB
|
||||||
if iface is ble.interface:
|
if utils.USE_BLE:
|
||||||
return _WIRE_INTERFACE_BLE
|
if iface is ble.interface:
|
||||||
|
return _WIRE_INTERFACE_BLE
|
||||||
raise Exception("Unknown WireInterface")
|
raise Exception("Unknown WireInterface")
|
||||||
|
Loading…
Reference in New Issue
Block a user