2023-02-22 11:24:09 +00:00
|
|
|
from trezorio import ble
|
|
|
|
|
|
|
|
|
|
|
|
class BleInterface:
|
2023-03-15 14:42:24 +00:00
|
|
|
def __init__(self, interface: int):
|
|
|
|
self.interface = interface
|
2023-02-22 11:24:09 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def iface_num(self) -> int:
|
2023-03-15 14:42:24 +00:00
|
|
|
return self.interface
|
2023-03-08 22:13:38 +00:00
|
|
|
|
2023-02-22 11:24:09 +00:00
|
|
|
def write(self, msg: bytes) -> int:
|
2023-03-15 14:42:24 +00:00
|
|
|
if self.interface == 16:
|
|
|
|
return ble.write_int(self, msg)
|
|
|
|
if self.interface == 17:
|
|
|
|
return ble.write_ext(self, msg)
|
|
|
|
return 0
|
2023-02-22 11:24:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
# interface used for trezor wire protocol
|
|
|
|
|
2023-03-15 14:42:24 +00:00
|
|
|
iface_ble_int = BleInterface(16)
|
|
|
|
iface_ble_ext = BleInterface(17)
|