From 0bb3389b3b615c0fc2fa4bd0be708b12bf639f37 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Mon, 23 Jun 2025 22:11:50 -0700 Subject: [PATCH] init --- meshtastic/__main__.py | 3 +++ meshtastic/mesh_interface.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index ec75591..06b9933 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1097,6 +1097,7 @@ def export_config(interface) -> str: owner_short = interface.getShortName() channel_url = interface.localNode.getURL() myinfo = interface.getMyNodeInfo() + canned_messages = interface.getCannedMessage() pos = myinfo.get("position") lat = None lon = None @@ -1115,6 +1116,8 @@ def export_config(interface) -> str: configObj["channelUrl"] = channel_url else: configObj["channel_url"] = channel_url + # if canned_messages: + # configObj["cannedMessages"] = canned_messages # lat and lon don't make much sense without the other (so fill with 0s), and alt isn't meaningful without both if lat or lon: configObj["location"] = {"lat": lat or float(0), "lon": lon or float(0)} diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index cf9009c..9f80c54 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -1076,6 +1076,13 @@ class MeshInterface: # pylint: disable=R0902 if user is not None: return user.get("publicKey", None) return None + + def getCannedMessage(self): + """Fetch and return the canned message from the local node.""" + if hasattr(self, "localNode") and self.localNode: + return self.localNode.get_canned_message() + else: + raise RuntimeError("No local node available.") def _waitConnected(self, timeout=30.0): """Block until the initial node db download is complete, or timeout