From 46a8db286caa63028fcd69c333d3152de9d6e045 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Thu, 20 Feb 2025 12:36:21 -0700 Subject: [PATCH 1/2] Add handling of clientNotification on FromRadio, sending a pubsub message --- meshtastic/__init__.py | 1 + meshtastic/mesh_interface.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py index 57b810f..7573e8b 100644 --- a/meshtastic/__init__.py +++ b/meshtastic/__init__.py @@ -35,6 +35,7 @@ type of packet, you should subscribe to the full topic name. If you want to see - `meshtastic.receive.data.portnum(packet)` (where portnum is an integer or well known PortNum enum) - `meshtastic.node.updated(node = NodeInfo)` - published when a node in the DB changes (appears, location changed, username changed, etc...) - `meshtastic.log.line(line)` - a raw unparsed log line from the radio +- `meshtastic.clientNotification(notification, interface) - a ClientNotification sent from the radio We receive position, user, or data packets from the mesh. You probably only care about `meshtastic.receive.data`. The first argument for that publish will be the packet. Text or binary data packets (from `sendData` or `sendText`) will both arrive this way. If you print packet diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index a3a67b7..c1426b5 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -1,6 +1,6 @@ """Mesh Interface class """ -# pylint: disable=R0917 +# pylint: disable=R0917,C0302 import collections import json @@ -1311,6 +1311,14 @@ class MeshInterface: # pylint: disable=R0902 self._handleLogRecord(fromRadio.log_record) elif fromRadio.HasField("queueStatus"): self._handleQueueStatusFromRadio(fromRadio.queueStatus) + elif fromRadio.HasField("clientNotification"): + publishingThread.queueWork( + lambda: pub.sendMessage( + "meshtastic.clientNotification", + notification=fromRadio.clientNotification, + interface=self, + ) + ) elif fromRadio.HasField("mqttClientProxyMessage"): publishingThread.queueWork( From f5fa30cb22bb5fae84e4bfdc44dc203c54f73631 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Thu, 20 Feb 2025 12:40:39 -0700 Subject: [PATCH 2/2] try to get pylint happier --- meshtastic/__main__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index f4dbc1d..5f8edd0 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1,9 +1,6 @@ """ Main Meshtastic """ - -# We just hit the 1600 line limit for main.py, but I currently have a huge set of powermon/structured logging changes -# later we can have a separate changelist to refactor main.py into smaller files -# pylint: disable=too-many-lines +# pylint: disable=C0302 from typing import List, Optional, Union from types import ModuleType