mirror of
https://github.com/meshtastic/python.git
synced 2025-12-26 17:37:51 -05:00
Compare commits
8 Commits
master
...
backup-com
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7422d9d314 | ||
|
|
5ee0264737 | ||
|
|
ec13bd308a | ||
|
|
2d88d8e918 | ||
|
|
fb48fc20b3 | ||
|
|
336e5154a3 | ||
|
|
3008e039fb | ||
|
|
4bf61d4c98 |
@@ -59,7 +59,7 @@ except ImportError as e:
|
|||||||
have_powermon = False
|
have_powermon = False
|
||||||
powermon_exception = e
|
powermon_exception = e
|
||||||
meter = None
|
meter = None
|
||||||
from meshtastic.protobuf import channel_pb2, config_pb2, portnums_pb2
|
from meshtastic.protobuf import admin_pb2, channel_pb2, config_pb2, portnums_pb2
|
||||||
from meshtastic.version import get_active_version
|
from meshtastic.version import get_active_version
|
||||||
|
|
||||||
def onReceive(packet, interface) -> None:
|
def onReceive(packet, interface) -> None:
|
||||||
@@ -462,6 +462,22 @@ def onConnected(interface):
|
|||||||
waitForAckNak = True
|
waitForAckNak = True
|
||||||
interface.getNode(args.dest, False, **getNode_kwargs).removeFavorite(args.remove_favorite_node)
|
interface.getNode(args.dest, False, **getNode_kwargs).removeFavorite(args.remove_favorite_node)
|
||||||
|
|
||||||
|
if args.backup_prefs:
|
||||||
|
closeNow = True
|
||||||
|
waitForAckNak = True
|
||||||
|
print(f"Backing up preferences to {args.backup_prefs}")
|
||||||
|
interface.getNode(args.dest, False, **getNode_kwargs).backupPreferences(args.backup_prefs)
|
||||||
|
|
||||||
|
if args.restore_prefs:
|
||||||
|
closeNow = True
|
||||||
|
waitForAckNak = True
|
||||||
|
interface.getNode(args.dest, False, **getNode_kwargs).restorePreferences(args.restore_prefs)
|
||||||
|
|
||||||
|
if args.remove_backup_prefs:
|
||||||
|
closeNow = True
|
||||||
|
waitForAckNak = True
|
||||||
|
interface.getNode(args.dest, False, **getNode_kwargs).removePreferencesBackups(args.remove_backup_prefs)
|
||||||
|
|
||||||
if args.set_ignored_node:
|
if args.set_ignored_node:
|
||||||
closeNow = True
|
closeNow = True
|
||||||
waitForAckNak = True
|
waitForAckNak = True
|
||||||
@@ -1794,12 +1810,40 @@ def addRemoteAdminArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPars
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
group.add_argument(
|
||||||
|
"--backup-prefs",
|
||||||
|
help="Tell the destination node to create a backup preferences file."
|
||||||
|
"Location: 0 for local flash, 1 for SD card.",
|
||||||
|
default=admin_pb2.AdminMessage.BackupLocation.FLASH,
|
||||||
|
nargs="?",
|
||||||
|
const=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
group.add_argument(
|
||||||
|
"--restore-prefs",
|
||||||
|
help="Tell the destination node to remove backup preferences files."
|
||||||
|
"Location: 0 for local flash, 1 for SD card.",
|
||||||
|
default=admin_pb2.AdminMessage.BackupLocation.FLASH,
|
||||||
|
nargs="?",
|
||||||
|
const=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
group.add_argument(
|
||||||
|
"--remove-backup-prefs",
|
||||||
|
help="Tell the destination node to remove backup preferences files."
|
||||||
|
"Location: 0 for local flash, 1 for SD card.",
|
||||||
|
default=admin_pb2.AdminMessage.BackupLocation.FLASH,
|
||||||
|
nargs="?",
|
||||||
|
const=0,
|
||||||
|
)
|
||||||
|
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--remove-node",
|
"--remove-node",
|
||||||
help="Tell the destination node to remove a specific node from its NodeDB. "
|
help="Tell the destination node to remove a specific node from its NodeDB. "
|
||||||
"Use the node ID with a '!' or '0x' prefix or the node number.",
|
"Use the node ID with a '!' or '0x' prefix or the node number.",
|
||||||
metavar="!xxxxxxxx"
|
metavar="!xxxxxxxx"
|
||||||
)
|
)
|
||||||
|
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--set-favorite-node",
|
"--set-favorite-node",
|
||||||
help="Tell the destination node to set the specified node to be favorited on the NodeDB. "
|
help="Tell the destination node to set the specified node to be favorited on the NodeDB. "
|
||||||
|
|||||||
@@ -707,8 +707,47 @@ class Node:
|
|||||||
onResponse = self.onAckNak
|
onResponse = self.onAckNak
|
||||||
return self._sendAdmin(p, onResponse=onResponse)
|
return self._sendAdmin(p, onResponse=onResponse)
|
||||||
|
|
||||||
|
def backupPreferences(self, location: Optional[admin_pb2.AdminMessage.BackupLocation.ValueType] = 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: Optional[admin_pb2.AdminMessage.BackupLocation.ValueType] = 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: Optional[admin_pb2.AdminMessage.BackupLocation.ValueType] = 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]):
|
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()
|
self.ensureSessionKey()
|
||||||
if isinstance(nodeId, str):
|
if isinstance(nodeId, str):
|
||||||
if nodeId.startswith("!"):
|
if nodeId.startswith("!"):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "meshtastic"
|
name = "meshtastic"
|
||||||
version = "2.5.12"
|
version = "2.6.0a1"
|
||||||
description = "Python API & client shell for talking to Meshtastic devices"
|
description = "Python API & client shell for talking to Meshtastic devices"
|
||||||
authors = ["Meshtastic Developers <contact@meshtastic.org>"]
|
authors = ["Meshtastic Developers <contact@meshtastic.org>"]
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|||||||
Reference in New Issue
Block a user