diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 3184d2a3..eafb4922 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -416,10 +416,11 @@ def onConnected(interface): closeNow = True interface.getNode(args.dest, False).commitSettingsTransaction() - if args.factory_reset: + if args.factory_reset or args.factory_reset_device: closeNow = True waitForAckNak = True - interface.getNode(args.dest, False).factoryReset() + full = bool(args.factory_reset_device) + interface.getNode(args.dest, False).factoryReset(full=full) if args.remove_node: closeNow = True @@ -1549,8 +1550,14 @@ def initParser(): ) group.add_argument( - "--factory-reset", - help="Tell the destination node to install the default config", + "--factory-reset", "--factory-reset-config", + help="Tell the destination node to install the default config, preserving BLE bonds & PKI keys", + action="store_true", + ) + + group.add_argument( + "--factory-reset-device", + help="Tell the destination node to install the default config and clear BLE bonds & PKI keys", action="store_true", ) diff --git a/meshtastic/node.py b/meshtastic/node.py index ca1977c4..415154db 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -629,12 +629,16 @@ def getMetadata(self): ) self.iface.waitForAckNak() - def factoryReset(self): + def factoryReset(self, full: bool = False): """Tell the node to factory reset.""" self.ensureSessionKey() p = admin_pb2.AdminMessage() - p.factory_reset = True - logging.info(f"Telling node to factory reset") + if full: + p.factory_reset_device = True + logging.info(f"Telling node to factory reset (full device reset)") + else: + p.factory_reset_config = True + logging.info(f"Telling node to factory reset (config reset)") # If sending to a remote node, wait for ACK/NAK if self == self.iface.localNode: