Skip to content

Commit 23e6eca

Browse files
authored
Merge pull request #671 from ianmcorvidae/factory-reset-update
Split factory reset into two variants
2 parents ef6db0e + 21ff4a1 commit 23e6eca

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

meshtastic/__main__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,11 @@ def onConnected(interface):
416416
closeNow = True
417417
interface.getNode(args.dest, False).commitSettingsTransaction()
418418

419-
if args.factory_reset:
419+
if args.factory_reset or args.factory_reset_device:
420420
closeNow = True
421421
waitForAckNak = True
422-
interface.getNode(args.dest, False).factoryReset()
422+
full = bool(args.factory_reset_device)
423+
interface.getNode(args.dest, False).factoryReset(full=full)
423424

424425
if args.remove_node:
425426
closeNow = True
@@ -1549,8 +1550,14 @@ def initParser():
15491550
)
15501551

15511552
group.add_argument(
1552-
"--factory-reset",
1553-
help="Tell the destination node to install the default config",
1553+
"--factory-reset", "--factory-reset-config",
1554+
help="Tell the destination node to install the default config, preserving BLE bonds & PKI keys",
1555+
action="store_true",
1556+
)
1557+
1558+
group.add_argument(
1559+
"--factory-reset-device",
1560+
help="Tell the destination node to install the default config and clear BLE bonds & PKI keys",
15541561
action="store_true",
15551562
)
15561563

meshtastic/node.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,16 @@ def getMetadata(self):
629629
)
630630
self.iface.waitForAckNak()
631631

632-
def factoryReset(self):
632+
def factoryReset(self, full: bool = False):
633633
"""Tell the node to factory reset."""
634634
self.ensureSessionKey()
635635
p = admin_pb2.AdminMessage()
636-
p.factory_reset = True
637-
logging.info(f"Telling node to factory reset")
636+
if full:
637+
p.factory_reset_device = True
638+
logging.info(f"Telling node to factory reset (full device reset)")
639+
else:
640+
p.factory_reset_config = True
641+
logging.info(f"Telling node to factory reset (config reset)")
638642

639643
# If sending to a remote node, wait for ACK/NAK
640644
if self == self.iface.localNode:

0 commit comments

Comments
 (0)