mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-12 14:16:06 +00:00
feat(core): add ble wire interface to interface manager
This commit is contained in:
parent
3c839d17e5
commit
a0afc0f0bb
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user