Skip to content

Commit 84417f0

Browse files
committed
working export-config
1 parent 0bb3389 commit 84417f0

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

meshtastic/__main__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,14 @@ def setSimpleConfig(modem_preset):
928928
if args.get_canned_message:
929929
closeNow = True
930930
print("")
931-
interface.getNode(args.dest, **getNode_kwargs).get_canned_message()
931+
messages = interface.getNode(args.dest, **getNode_kwargs).get_canned_message()
932+
print(f"canned_plugin_message:{messages}")
932933

933934
if args.get_ringtone:
934935
closeNow = True
935936
print("")
936-
interface.getNode(args.dest, **getNode_kwargs).get_ringtone()
937+
ringtone = interface.getNode(args.dest, **getNode_kwargs).get_ringtone()
938+
print(f"ringtone:{ringtone}")
937939

938940
if args.info:
939941
print("")
@@ -1098,6 +1100,7 @@ def export_config(interface) -> str:
10981100
channel_url = interface.localNode.getURL()
10991101
myinfo = interface.getMyNodeInfo()
11001102
canned_messages = interface.getCannedMessage()
1103+
ringtone = interface.getRingtone()
11011104
pos = myinfo.get("position")
11021105
lat = None
11031106
lon = None
@@ -1116,8 +1119,10 @@ def export_config(interface) -> str:
11161119
configObj["channelUrl"] = channel_url
11171120
else:
11181121
configObj["channel_url"] = channel_url
1119-
# if canned_messages:
1120-
# configObj["cannedMessages"] = canned_messages
1122+
if canned_messages:
1123+
configObj["canned_messages"] = canned_messages
1124+
if ringtone:
1125+
configObj["ringtone"] = ringtone
11211126
# lat and lon don't make much sense without the other (so fill with 0s), and alt isn't meaningful without both
11221127
if lat or lon:
11231128
configObj["location"] = {"lat": lat or float(0), "lon": lon or float(0)}

meshtastic/mesh_interface.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,13 +1076,18 @@ def getPublicKey(self):
10761076
if user is not None:
10771077
return user.get("publicKey", None)
10781078
return None
1079-
1079+
10801080
def getCannedMessage(self):
10811081
"""Fetch and return the canned message from the local node."""
10821082
if hasattr(self, "localNode") and self.localNode:
10831083
return self.localNode.get_canned_message()
1084-
else:
1085-
raise RuntimeError("No local node available.")
1084+
return None
1085+
1086+
def getRingtone(self):
1087+
"""Fetch and return the ringtone from the local node."""
1088+
if hasattr(self, "localNode") and self.localNode:
1089+
return self.localNode.get_ringtone()
1090+
return None
10861091

10871092
def _waitConnected(self, timeout=30.0):
10881093
"""Block until the initial node db download is complete, or timeout

meshtastic/node.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ def get_ringtone(self):
454454
if self.ringtonePart:
455455
self.ringtone += self.ringtonePart
456456

457-
print(f"ringtone:{self.ringtone}")
458457
logging.debug(f"ringtone:{self.ringtone}")
459458
return self.ringtone
460459

@@ -530,7 +529,6 @@ def get_canned_message(self):
530529
if self.cannedPluginMessageMessages:
531530
self.cannedPluginMessage += self.cannedPluginMessageMessages
532531

533-
print(f"canned_plugin_message:{self.cannedPluginMessage}")
534532
logging.debug(f"canned_plugin_message:{self.cannedPluginMessage}")
535533
return self.cannedPluginMessage
536534

0 commit comments

Comments
 (0)