1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00
trezor-firmware/core/src/bluetooth.py

24 lines
521 B
Python
Raw Normal View History

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-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)