8000 Update ble_uart_repl.py with latest ble uart write changes · kitlab-io/micropython@0d8fe81 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d8fe81

Browse files
Update ble_uart_repl.py with latest ble uart write changes
Remove _timer and _flush
1 parent c5bb6a3 commit 0d8fe81

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

jem/ble_uart_repl.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@
55

66
import io
77
import os
8-
import machine
9-
from ble_uart_peripheral import schedule_in
108

119
_MP_STREAM_POLL = const(3)
1210
_MP_STREAM_POLL_RD = const(0x0001)
1311

1412
# Simple buffering stream to support the dupterm requirements.
1513
class BLEUARTStream(io.IOBase):
16-
def __init__(self, tmr, uart):
14+
def __init__(self, uart):
1715
self._uart = uart # ble_uart_peripheral.py BLEUART object
18-
self._tx_buf = bytearray()
1916
self._uart.irq(self._on_rx)
20-
self.tx_delay_ms = 25
21-
self._timer = tmr # ex: machine.Timer(0)
17+
self.errors = []
2218

2319
def connected_event(self, connected):
2420
if connected:
@@ -48,15 +44,8 @@ def ioctl(self, op, arg):
4844
return _MP_STREAM_POLL_RD
4945
return 0
5046

51-
def _flush(self):
52-
data = self._tx_buf[0:100]
53-
self._tx_buf = self._tx_buf[100:]
54-
self._uart.write(data)
55-
if self._tx_buf:
56-
schedule_in(self._timer, self._flush, self.tx_delay_ms)
57-
5847
def write(self, buf):
59-
empty = not self._tx_buf
60-
self._tx_buf += buf
61-
if empty:
62-
schedule_in(self._timer, self._flush, self.tx_delay_ms)
48+
try:
49+
self._uart.t_write(buf)
50+
except Exception as e:
51+
self.errors.append(e)

0 commit comments

Comments
 (0)
0