From f462889b626d3e2012999e680077793e8b88a927 Mon Sep 17 00:00:00 2001 From: Pablo Revilla Date: Tue, 24 Jun 2025 13:46:23 -0700 Subject: [PATCH] update version --- meshview/mqtt_reader.py | 22 +++++++++++++++++++--- meshview/mqtt_store.py | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/meshview/mqtt_reader.py b/meshview/mqtt_reader.py index ea70d24..1ac0559 100644 --- a/meshview/mqtt_reader.py +++ b/meshview/mqtt_reader.py @@ -30,20 +30,36 @@ async def get_topic_envelopes(mqtt_server, mqtt_port, topics, mqtt_user, mqtt_pa while True: try: async with aiomqtt.Client( - mqtt_server, port=mqtt_port , username=mqtt_user, password=mqtt_passwd , identifier=identifier, + mqtt_server, + port=mqtt_port, + username=mqtt_user, + password=mqtt_passwd, + identifier=identifier, ) as client: for topic in topics: - print(topic) + print(f"Subscribing to: {topic}") await client.subscribe(topic) + async for msg in client.messages: try: envelope = ServiceEnvelope.FromString(msg.payload) - print(envelope) except DecodeError: continue + decrypt(envelope.packet) + if not envelope.packet.decoded: continue + + # Skip packets from specific node + if getattr(envelope.packet, "from", None) == 2144342101: + continue + + # ✅ Print decoded packet + print("Decoded Packet:", envelope.packet.decoded) + yield msg.topic.value, envelope + except aiomqtt.MqttError as e: + print(f"MQTT error: {e}, reconnecting in 1s...") await asyncio.sleep(1) diff --git a/meshview/mqtt_store.py b/meshview/mqtt_store.py index f67dc79..fd36d18 100644 --- a/meshview/mqtt_store.py +++ b/meshview/mqtt_store.py @@ -15,7 +15,8 @@ async def process_envelope(topic, env): # Checking if the received packet is a MAP_REPORT # Update the node table with the firmware version - if env.packet.decoded.portnum == PortNum.MAP_REPORT_APP: + #if env.packet.decoded.portnum == PortNum.MAP_REPORT_APP: + if env.packet.decoded.portnum == 0: # Extract the node ID from the packet and format the user ID node_id = getattr(env.packet, "from") user_id = f"!{node_id:0{8}x}"