mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-11 04:45:45 +00:00
do not merge
This commit is contained in:
parent
3940493785
commit
8665cf68c3
@ -36,6 +36,9 @@ import trezor.pin # noqa: F401
|
||||
# usb imports trezor.utils and trezor.io which is a C module
|
||||
import usb
|
||||
|
||||
from trezor import io
|
||||
io.ble.start_comm()
|
||||
|
||||
# create an unimport manager that will be reused in the main loop
|
||||
unimport_manager = utils.unimport()
|
||||
|
||||
|
@ -1,8 +1,39 @@
|
||||
# isort: skip_file
|
||||
from trezor import log, loop, utils, wire, workflow
|
||||
from trezor import log, loop, utils, wire, workflow, io
|
||||
|
||||
import apps.base
|
||||
import usb
|
||||
from typing import Generator
|
||||
|
||||
|
||||
class BleInterface:
|
||||
|
||||
RX_PACKET_LEN = io.ble.RX_PACKET_LEN
|
||||
TX_PACKET_LEN = io.ble.TX_PACKET_LEN
|
||||
|
||||
def iface_num(self) -> int:
|
||||
return io.BLE
|
||||
|
||||
def write(self, msg: bytes) -> int:
|
||||
return io.ble.write(msg)
|
||||
|
||||
def read(self, buffer: bytearray, offset: int = 0) -> int:
|
||||
return io.ble.read(buffer, offset)
|
||||
|
||||
|
||||
# interface used for trezor wire protocol
|
||||
iface_ble = BleInterface()
|
||||
|
||||
|
||||
def ble_events() -> Generator:
|
||||
from trezor import io
|
||||
|
||||
x = loop.wait(io.BLE_EVENT)
|
||||
while True:
|
||||
# Using `yield` instead of `await` to avoid allocations.
|
||||
event = yield x
|
||||
print(f"ble_event {event}")
|
||||
|
||||
|
||||
apps.base.boot()
|
||||
|
||||
@ -21,7 +52,9 @@ apps.base.set_homescreen()
|
||||
workflow.start_default()
|
||||
|
||||
# initialize the wire codec
|
||||
wire.setup(usb.iface_wire)
|
||||
# wire.setup(usb.iface_wire)
|
||||
wire.setup(BleInterface())
|
||||
loop.schedule(ble_events())
|
||||
|
||||
# start the event loop
|
||||
loop.run()
|
||||
|
Loading…
Reference in New Issue
Block a user