diff options
Diffstat (limited to 'examples/bluetooth/ble_uart_repl.py')
-rw-r--r-- | examples/bluetooth/ble_uart_repl.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/bluetooth/ble_uart_repl.py b/examples/bluetooth/ble_uart_repl.py index 430a571a69..9e8a38ff4b 100644 --- a/examples/bluetooth/ble_uart_repl.py +++ b/examples/bluetooth/ble_uart_repl.py @@ -15,7 +15,7 @@ _MP_STREAM_POLL = const(3) _MP_STREAM_POLL_RD = const(0x0001) # TODO: Remove this when STM32 gets machine.Timer. -if hasattr(machine, 'Timer'): +if hasattr(machine, "Timer"): _timer = machine.Timer(-1) else: _timer = None @@ -24,11 +24,13 @@ else: def schedule_in(handler, delay_ms): def _wrap(_arg): handler() + if _timer: _timer.init(mode=machine.Timer.ONE_SHOT, period=delay_ms, callback=_wrap) else: micropython.schedule(_wrap, None) + # Simple buffering stream to support the dupterm requirements. class BLEUARTStream(io.IOBase): def __init__(self, uart): @@ -38,7 +40,7 @@ class BLEUARTStream(io.IOBase): def _on_rx(self): # Needed for ESP32. - if hasattr(os, 'dupterm_notify'): + if hasattr(os, "dupterm_notify"): os.dupterm_notify(None) def read(self, sz=None): @@ -74,7 +76,7 @@ class BLEUARTStream(io.IOBase): def start(): ble = bluetooth.BLE() - uart = BLEUART(ble, name='mpy-repl') + uart = BLEUART(ble, name="mpy-repl") stream = BLEUARTStream(uart) os.dupterm(stream) |