From 308ac933994a7a705b2e0be3ea97bf9c526931dc Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Tue, 24 Jun 2025 07:40:11 -0700 Subject: [PATCH] add to configure --- meshtastic/__main__.py | 12 ++++++++++-- meshtastic/mesh_interface.py | 16 +++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index bd04251..f751f07 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -362,7 +362,6 @@ def onConnected(interface): print(f"Setting device owner short to {args.set_owner_short}") interface.getNode(args.dest, False, **getNode_kwargs).setOwner(long_name=args.set_owner, short_name=args.set_owner_short) - # TODO: add to export-config and configure if args.set_canned_message: closeNow = True waitForAckNak = True @@ -371,7 +370,6 @@ def onConnected(interface): args.set_canned_message ) - # TODO: add to export-config and configure if args.set_ringtone: closeNow = True waitForAckNak = True @@ -705,6 +703,16 @@ def onConnected(interface): interface.getNode(args.dest, **getNode_kwargs).setURL(configuration["channelUrl"]) time.sleep(0.5) + if "canned_messages" in configuration: + print("Setting canned message messages to", configuration["canned_messages"]) + interface.getNode(args.dest, **getNode_kwargs).set_canned_message(configuration["canned_messages"]) + time.sleep(0.5) + + if "ringtone" in configuration: + print("Setting ringtone to", configuration["ringtone"]) + interface.getNode(args.dest, **getNode_kwargs).set_ringtone(configuration["ringtone"]) + time.sleep(0.5) + if "location" in configuration: alt = 0 lat = 0.0 diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index f2c6fa2..16ec975 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -1078,15 +1078,17 @@ class MeshInterface: # pylint: disable=R0902 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() + """Get canned message""" + node = self.localNode + if node is not None: + return node.get_canned_message() return None - + def getRingtone(self): - """Fetch and return the ringtone from the local node.""" - if hasattr(self, "localNode") and self.localNode: - return self.localNode.get_ringtone() + """Get ringtone""" + node = self.localNode + if node is not None: + return node.get_ringtone() return None def _waitConnected(self, timeout=30.0):