mirror of
https://github.com/meshtastic/python.git
synced 2026-01-14 18:57:56 -05:00
Add backup / restore admin commands
This commit is contained in:
@@ -462,6 +462,21 @@ def onConnected(interface):
|
||||
waitForAckNak = True
|
||||
interface.getNode(args.dest, False, **getNode_kwargs).removeFavorite(args.remove_favorite_node)
|
||||
|
||||
if args.backup_prefs:
|
||||
closeNow = True
|
||||
waitForAckNak = True
|
||||
interface.getNode(args.dest, False, **getNode_kwargs).re(args.backup_preferences)
|
||||
|
||||
if args.restore_prefs:
|
||||
closeNow = True
|
||||
waitForAckNak = True
|
||||
interface.getNode(args.dest, False, **getNode_kwargs).re(args.backup_preferences)
|
||||
|
||||
if args.remove_backup_prefs:
|
||||
closeNow = True
|
||||
waitForAckNak = True
|
||||
interface.getNode(args.dest, False, **getNode_kwargs).re(args.remove_backup_preferences)
|
||||
|
||||
if args.set_ignored_node:
|
||||
closeNow = True
|
||||
waitForAckNak = True
|
||||
|
||||
@@ -707,8 +707,47 @@ class Node:
|
||||
onResponse = self.onAckNak
|
||||
return self._sendAdmin(p, onResponse=onResponse)
|
||||
|
||||
def backupPreferences(self, location: int = 0):
|
||||
"""Tell the node to backup preferences to flash."""
|
||||
self.ensureSessionKey()
|
||||
|
||||
p = admin_pb2.AdminMessage()
|
||||
p.backup_preferences = location
|
||||
|
||||
if self == self.iface.localNode:
|
||||
onResponse = None
|
||||
else:
|
||||
onResponse = self.onAckNak
|
||||
return self._sendAdmin(p, onResponse=onResponse)
|
||||
|
||||
def restorePreferences(self, location: int = 0):
|
||||
"""Tell the node to restore preferences from backup."""
|
||||
self.ensureSessionKey()
|
||||
|
||||
p = admin_pb2.AdminMessage()
|
||||
p.restore_preferences = location
|
||||
|
||||
if self == self.iface.localNode:
|
||||
onResponse = None
|
||||
else:
|
||||
onResponse = self.onAckNak
|
||||
return self._sendAdmin(p, onResponse=onResponse)
|
||||
|
||||
def removePreferencesBackups(self, location: int = 0):
|
||||
"""Tell the node to remove backup preferences from the filesystem."""
|
||||
self.ensureSessionKey()
|
||||
|
||||
p = admin_pb2.AdminMessage()
|
||||
p.remove_backup_preferences = location
|
||||
|
||||
if self == self.iface.localNode:
|
||||
onResponse = None
|
||||
else:
|
||||
onResponse = self.onAckNak
|
||||
return self._sendAdmin(p, onResponse=onResponse)
|
||||
|
||||
def removeFavorite(self, nodeId: Union[int, str]):
|
||||
"""Tell the node to set the specified node ID to be un-favorited on the NodeDB on the device"""
|
||||
"""Tell the node to set the specified node ID to be un-favorited on the NodeDB on the device."""
|
||||
self.ensureSessionKey()
|
||||
if isinstance(nodeId, str):
|
||||
if nodeId.startswith("!"):
|
||||
|
||||
Reference in New Issue
Block a user