Skip to content

Commit

Permalink
Merge pull request #556 from ianmcorvidae/enter-dfu
Browse files Browse the repository at this point in the history
Add --enter-dfu for entering DFU mode on NRF52 devices via admin message
  • Loading branch information
ianmcorvidae authored Apr 25, 2024
2 parents 158cac6 + 6812f50 commit 3d6fa36
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
13 changes: 12 additions & 1 deletion meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ def onConnected(interface):
waitForAckNak = True
interface.getNode(args.dest, False).rebootOTA()

if args.enter_dfu:
closeNow = True
waitForAckNak = True
interface.getNode(args.dest, False).enterDFUMode()

if args.shutdown:
closeNow = True
waitForAckNak = True
Expand Down Expand Up @@ -1364,7 +1369,13 @@ def initParser():

group.add_argument(
"--reboot-ota",
help="Tell the destination node to reboot into factory firmware",
help="Tell the destination node to reboot into factory firmware (ESP32)",
action="store_true",
)

group.add_argument(
"--enter-dfu",
help="Tell the destination node to enter DFU mode (NRF52)",
action="store_true",
)

Expand Down
13 changes: 13 additions & 0 deletions meshtastic/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,19 @@ def rebootOTA(self, secs: int = 10):
onResponse = self.onAckNak
return self._sendAdmin(p, onResponse=onResponse)

def enterDFUMode(self):
"""Tell the node to enter DFU mode (NRF52)."""
p = admin_pb2.AdminMessage()
p.enter_dfu_mode_request = True
logging.info(f"Telling node to enable DFU mode")

# If sending to a remote node, wait for ACK/NAK
if self == self.iface.localNode:
onResponse = None
else:
onResponse = self.onAckNak
return self._sendAdmin(p, onResponse=onResponse)

def shutdown(self, secs: int = 10):
"""Tell the node to shutdown."""
p = admin_pb2.AdminMessage()
Expand Down

0 comments on commit 3d6fa36

Please sign in to comment.