Restore uf2reset CLI after PR merges

This commit is contained in:
mikecarper committed 2026-06-22 18:18:14 -07:00
1 parent 915353c5d2
commit 4b6810d380
2 files changed
+54 -1

No files matched your search

+23
View File
@@ -28,12 +28,35 @@ This document provides an overview of CLI commands that can be sent to MeshCore
**Usage:**
- `reboot`
**Note:** No reply is sent.
---
### Power-off the node
**Usage:**
- `poweroff`, or
- `shutdown`
**Note:** No reply is sent.
---
### Enter the UF2 bootloader (nRF52 only)
**Usage:**
- `uf2reset`
**Serial Only:** Yes
**Note:** Reboots directly into the UF2 bootloader on supported nRF52 boards.
---
### Reset the clock and reboot
**Usage:**
- `clkreboot`
**Note:** No reply is sent.
---
### Sync the clock with the remote device
+31 -1
View File
@@ -4,6 +4,30 @@
#include "AdvertDataHelpers.h"
#include "TxtDataHelpers.h"
#include <RTClib.h>
#if defined(NRF52_PLATFORM)
#include <nrf.h>
#include <nrf_soc.h>
#ifndef DFU_MAGIC_UF2_RESET
#define DFU_MAGIC_UF2_RESET 0x57
#endif
static void resetToUf2Bootloader() {
uint8_t sd_enabled = 0;
sd_softdevice_is_enabled(&sd_enabled);
if (sd_enabled) {
sd_power_gpregret_clr(0, 0xFF);
sd_power_gpregret_set(0, DFU_MAGIC_UF2_RESET);
} else {
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
}
NVIC_SystemReset();
}
#endif
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
@@ -414,11 +438,17 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
_board->powerOff(); // doesn't return
} else if (memcmp(command, "reboot", 6) == 0) {
_board->reboot(); // doesn't return
} else if (sender_timestamp == 0 && memcmp(command, "uf2reset", 8) == 0 && (command[8] == 0 || command[8] == ' ')) {
#if defined(NRF52_PLATFORM)
resetToUf2Bootloader(); // doesn't return
#else
strcpy(reply, "ERR: unsupported");
#endif
} else if (memcmp(command, "clkreboot", 9) == 0) {
// Reset clock
getRTCClock()->setCurrentTime(1715770351); // 15 May 2024, 8:50pm
_board->reboot(); // doesn't return
} else if (memcmp(command, "advert.zerohop", 14) == 0 && (command[14] == 0 || command[14] == ' ')) {
} else if (memcmp(command, "advert.zerohop", 14) == 0 && (command[14] == 0 || command[14] == ' ')) {
// send zerohop advert
_callbacks->sendSelfAdvertisement(1500, false); // longer delay, give CLI response time to be sent first
strcpy(reply, "OK - zerohop advert sent");