From 12a8bd4c1934f98abf27501a0a9011f8e1dbbd47 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Sun, 8 Mar 2026 14:09:43 +1100 Subject: [PATCH] building out UI a ton more and also working on serialization and deserial for the desktop app --- desktop_app/api/channel.py | 6 +- desktop_app/api/node.py | 65 +++++++++++++++++-- desktop_app/ui/app.py | 4 ++ desktop_app/ui/screens/main_screen.py | 2 + desktop_app/ui/screens/pair_screen.py | 2 +- desktop_app/ui/widgets/channels_list.py | 19 +++--- desktop_app/ui/widgets/chat_window.py | 84 ++++++++++++++++++++++--- 7 files changed, 158 insertions(+), 24 deletions(-) diff --git a/desktop_app/api/channel.py b/desktop_app/api/channel.py index 39c08b0..5b2e1f6 100644 --- a/desktop_app/api/channel.py +++ b/desktop_app/api/channel.py @@ -1,3 +1,5 @@ class Channel: - def __init__(self, name: str, key: str): - self.name = name \ No newline at end of file + def __init__(self, name: str, key: str, sf: int = 9): + self.name = name + self.key = key + self.sf = sf \ No newline at end of file diff --git a/desktop_app/api/node.py b/desktop_app/api/node.py index f25dca9..5b5cc79 100644 --- a/desktop_app/api/node.py +++ b/desktop_app/api/node.py @@ -1,23 +1,80 @@ from bleak import BleakScanner, BleakClient +import asyncio +import struct +from dataclasses import dataclass +from enum import Enum NODE_BLUETOOTH_SERVICE_UUID = "E1898FF7-5063-4441-a6eb-526073B00001" NODE_BLUETOOTH_RX_UUID = "E1898FF7-5063-4441-a6eb-526073B00002" NODE_BLUETOOTH_TX_UUID = "E1898FF7-5063-4441-a6eb-526073B00003" +class BluetoothPacketType(Enum): + SEND_MESSAGE = 1 + GET_INFO = 2 + +@dataclass +class BluetoothPacket: + packet_type: BluetoothPacketType + data: dict + class MeshNode: - def __init__(self, client: BleakClient): + def __init__(self, client: BleakClient, app): self.client = client - self.client.pair() + self.app = app + self.name = "None" - async def discover(): + self.rx_queue = asyncio.Queue() + + async def get_client_info(self): + await self.transmit_bluetooth_packet(BluetoothPacket( + BluetoothPacketType.GET_INFO, + None + )) + + def serialize_msg(self, packet: BluetoothPacket): + final = bytes() + + final += struct.pack("