mirror of
https://github.com/meshtastic/python.git
synced 2026-01-13 10:17:55 -05:00
working export-config
This commit is contained in:
@@ -928,12 +928,14 @@ def onConnected(interface):
|
||||
if args.get_canned_message:
|
||||
closeNow = True
|
||||
print("")
|
||||
interface.getNode(args.dest, **getNode_kwargs).get_canned_message()
|
||||
messages = interface.getNode(args.dest, **getNode_kwargs).get_canned_message()
|
||||
print(f"canned_plugin_message:{messages}")
|
||||
|
||||
if args.get_ringtone:
|
||||
closeNow = True
|
||||
print("")
|
||||
interface.getNode(args.dest, **getNode_kwargs).get_ringtone()
|
||||
ringtone = interface.getNode(args.dest, **getNode_kwargs).get_ringtone()
|
||||
print(f"ringtone:{ringtone}")
|
||||
|
||||
if args.info:
|
||||
print("")
|
||||
@@ -1098,6 +1100,7 @@ def export_config(interface) -> str:
|
||||
channel_url = interface.localNode.getURL()
|
||||
myinfo = interface.getMyNodeInfo()
|
||||
canned_messages = interface.getCannedMessage()
|
||||
ringtone = interface.getRingtone()
|
||||
pos = myinfo.get("position")
|
||||
lat = None
|
||||
lon = None
|
||||
@@ -1116,8 +1119,10 @@ def export_config(interface) -> str:
|
||||
configObj["channelUrl"] = channel_url
|
||||
else:
|
||||
configObj["channel_url"] = channel_url
|
||||
# if canned_messages:
|
||||
# configObj["cannedMessages"] = canned_messages
|
||||
if canned_messages:
|
||||
configObj["canned_messages"] = canned_messages
|
||||
if ringtone:
|
||||
configObj["ringtone"] = ringtone
|
||||
# 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)}
|
||||
|
||||
@@ -1076,13 +1076,18 @@ 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.")
|
||||
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()
|
||||
return None
|
||||
|
||||
def _waitConnected(self, timeout=30.0):
|
||||
"""Block until the initial node db download is complete, or timeout
|
||||
|
||||
@@ -454,7 +454,6 @@ class Node:
|
||||
if self.ringtonePart:
|
||||
self.ringtone += self.ringtonePart
|
||||
|
||||
print(f"ringtone:{self.ringtone}")
|
||||
logging.debug(f"ringtone:{self.ringtone}")
|
||||
return self.ringtone
|
||||
|
||||
@@ -530,7 +529,6 @@ class Node:
|
||||
if self.cannedPluginMessageMessages:
|
||||
self.cannedPluginMessage += self.cannedPluginMessageMessages
|
||||
|
||||
print(f"canned_plugin_message:{self.cannedPluginMessage}")
|
||||
logging.debug(f"canned_plugin_message:{self.cannedPluginMessage}")
|
||||
return self.cannedPluginMessage
|
||||
|
||||
|
||||
Reference in New Issue
Block a user