mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
had to add headers in tcp cx
This commit is contained in:
parent
4f05c60212
commit
4685f511ad
1 changed files with 15 additions and 3 deletions
18
mccli.py
18
mccli.py
|
|
@ -72,11 +72,23 @@ class TCPConnection:
|
|||
self.mc = mc
|
||||
|
||||
def handle_rx(self, data: bytearray):
|
||||
if not self.mc is None:
|
||||
self.mc.handle_rx(data)
|
||||
cur_data = data
|
||||
while (len(cur_data) > 0) :
|
||||
if cur_data[0] != 62 :
|
||||
printerr(f"Error with received frame trying anyway ... first byte is {cur_data[0]}")
|
||||
|
||||
frame_size = int.from_bytes(cur_data[1:2], byteorder='little')
|
||||
frame = cur_data[3:3+frame_size]
|
||||
|
||||
if not self.mc is None:
|
||||
self.mc.handle_rx(frame)
|
||||
|
||||
cur_data = cur_data[3+frame_size:]
|
||||
|
||||
async def send(self, data):
|
||||
self.transport.write(data)
|
||||
size = len(data)
|
||||
pkt = b"<" + size.to_bytes(2, byteorder="little") + data
|
||||
self.transport.write(pkt)
|
||||
|
||||
class BLEConnection:
|
||||
def __init__(self, address):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue