Skip to content

Commit 3d6fa36

Browse files
authored
Merge pull request #556 from ianmcorvidae/enter-dfu
Add --enter-dfu for entering DFU mode on NRF52 devices via admin message
2 parents 158cac6 + 6812f50 commit 3d6fa36

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

meshtastic/__main__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ def onConnected(interface):
375375
waitForAckNak = True
376376
interface.getNode(args.dest, False).rebootOTA()
377377

378+
if args.enter_dfu:
379+
closeNow = True
380+
waitForAckNak = True
381+
interface.getNode(args.dest, False).enterDFUMode()
382+
378383
if args.shutdown:
379384
closeNow = True
380385
waitForAckNak = True
@@ -1364,7 +1369,13 @@ def initParser():
13641369

13651370
group.add_argument(
13661371
"--reboot-ota",
1367-
help="Tell the destination node to reboot into factory firmware",
1372+
help="Tell the destination node to reboot into factory firmware (ESP32)",
1373+
action="store_true",
1374+
)
1375+
1376+
group.add_argument(
1377+
"--enter-dfu",
1378+
help="Tell the destination node to enter DFU mode (NRF52)",
13681379
action="store_true",
13691380
)
13701381

meshtastic/node.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,19 @@ def rebootOTA(self, secs: int = 10):
571571
onResponse = self.onAckNak
572572
return self._sendAdmin(p, onResponse=onResponse)
573573

574+
def enterDFUMode(self):
575+
"""Tell the node to enter DFU mode (NRF52)."""
576+
p = admin_pb2.AdminMessage()
577+
p.enter_dfu_mode_request = True
578+
logging.info(f"Telling node to enable DFU mode")
579+
580+
# If sending to a remote node, wait for ACK/NAK
581+
if self == self.iface.localNode:
582+
onResponse = None
583+
else:
584+
onResponse = self.onAckNak
585+
return self._sendAdmin(p, onResponse=onResponse)
586+
574587
def shutdown(self, secs: int = 10):
575588
"""Tell the node to shutdown."""
576589
p = admin_pb2.AdminMessage()

0 commit comments

Comments
 (0)