Skip to content

Commit

Permalink
Add factory reset
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Sep 18, 2022
1 parent 733f22d commit 4ae49c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ def onConnected(interface):
closeNow = True
interface.getNode(args.dest).getMetadata()

if args.factory_reset:
closeNow = True
interface.getNode(args.dest).factoryReset()

if args.sendtext:
closeNow = True
channelIndex = 0
Expand Down Expand Up @@ -870,6 +874,9 @@ def initParser():
parser.add_argument(
"--device-metadata", help="Get the device metadata from the node", action="store_true")

parser.add_argument(
"--factory-reset", help="Tell the destination node to install the default config", action="store_true")

parser.add_argument(
"--reply", help="Reply to received messages",
action="store_true")
Expand Down
8 changes: 8 additions & 0 deletions meshtastic/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@ def getMetadata(self, secs: int = 10):

return self._sendAdmin(p, wantResponse=True, onResponse=self.onRequestGetMetadata)

def factoryReset(self):
"""Tell the node to factory reset."""
p = admin_pb2.AdminMessage()
p.factory_reset = True
logging.info(f"Telling node to factory reset")

return self._sendAdmin(p)

def _fixupChannels(self):
"""Fixup indexes and add disabled channels as needed"""

Expand Down

0 comments on commit 4ae49c6

Please sign in to comment.