updated parsing

This commit is contained in:
ggw
2026-05-09 14:16:20 -07:00
parent 5937f9ac3b
commit 74debab835
3 changed files with 94 additions and 58 deletions
+12 -8
View File
@@ -12,8 +12,9 @@ async def scan():
async def connect(device):
async with BleakClient(device) as client:
value = bytes([0x01])
#await client.write_gatt_char(TX_UUID, value, response=True)
value = b'6'
await client.write_gatt_char(TX_UUID, value, response=True)
await client.stop_notify(RX_UUID)
await client.start_notify(RX_UUID, cb)
await asyncio.sleep(10000)
@@ -28,19 +29,22 @@ def cb(sender, data):
async def update_with_data():
types = get_type_list(packet_definitions)
cons = bytes()
start = time.time()
while(True):
data = await queue.get()
if len(cons) == 0:
size = int.from_bytes(data[:4], byteorder = 'little', signed = False)
cons = cons + data
assert len(cons) <= size
if len(cons) == size:
read_and_process(types, cons, size)
if len(cons) == size + 4:
read_and_process(types, cons[4 : size + 4], size)
cons = bytes()
start = time.time()
if len(cons) > size + 4:
print("Misaligned")
cons = bytes()
async def main():
device = await scan()
if not device: