|
|
|
@ -12,6 +12,8 @@ from protobufs_extra.queuestatus_proto import * |
|
|
|
from protobufs_extra.device_metadata_proto import * |
|
|
|
from protobufs_extra.file_info_proto import * |
|
|
|
|
|
|
|
from protobuf_decoder.protobuf_decoder import Parser |
|
|
|
|
|
|
|
DATA_SCHEMA = [ |
|
|
|
("varint", "portnum", 1), |
|
|
|
("bytes", "payload", 2), |
|
|
|
@ -214,6 +216,13 @@ PORTNUMS = { |
|
|
|
} |
|
|
|
NAMES_TO_PORTNUMS = {v: k for k, v in PORTNUMS.items()} |
|
|
|
|
|
|
|
def parseBytesToProtobuf(byte_s): |
|
|
|
try: |
|
|
|
to_parse = ' '.join(f'{byte:02x}' for byte in byte_s) |
|
|
|
res = Parser().parse(to_parse) |
|
|
|
print("TESTED CLIENT SEND PROTO: ", res.to_dict()) |
|
|
|
except: |
|
|
|
pass |
|
|
|
|
|
|
|
class Channel: |
|
|
|
def __init__(self, index, name, role): |
|
|
|
@ -223,7 +232,7 @@ class Channel: |
|
|
|
|
|
|
|
|
|
|
|
class MeshtDevice: |
|
|
|
def __init__(self, transport, device_uuid, skip_init = False): |
|
|
|
def __init__(self, transport, device_uuid, skip_init = False, test_client = False): |
|
|
|
self.transport = transport |
|
|
|
self.channels = [] |
|
|
|
self.lora_config = None |
|
|
|
@ -233,6 +242,7 @@ class MeshtDevice: |
|
|
|
self.nid = None |
|
|
|
self.device_uuid = device_uuid |
|
|
|
self.skip_init = skip_init |
|
|
|
self.test_client = test_client |
|
|
|
|
|
|
|
async def start(self): |
|
|
|
await self.transport.start() |
|
|
|
@ -270,6 +280,11 @@ class MeshtDevice: |
|
|
|
|
|
|
|
async def recv(self): |
|
|
|
data = await self.transport.recv() |
|
|
|
|
|
|
|
if self.test_client: |
|
|
|
parseBytesToProtobuf(data) |
|
|
|
return {}, b"" |
|
|
|
|
|
|
|
fr = pb.decode(data, FROMRADIO_SCHEMA) |
|
|
|
fr["device_uuid"] = self.device_uuid |
|
|
|
logger.debug(f"FromRadio: {fr}") |
|
|
|
|