Add saved regulator modes and battery-gated crash recovery
This commit is contained in:
1 parent
515bb57cdf
commit
c4a1d485ff
70 files changed
+5335
-2472
No files matched your search
@@ -1,3 +1,4 @@
|
||||
#include <helpers/RegulatorSettings.h>
|
||||
#include <helpers/ui/DisplayPowerSettings.h>
|
||||
#include <helpers/BatteryChargeCLI.h>
|
||||
#include <helpers/MorseCLI.h>
|
||||
@@ -8222,6 +8223,7 @@ bool MyMesh::handleExtraFsHilCommand(const char* command, char* reply,
|
||||
if (strcmp(action, "unsafe-reset CONFIRM") == 0) {
|
||||
// Intentionally bypass all persistence hooks so HIL can prove that a
|
||||
// mutation was already committed before an event-driven sleep.
|
||||
meshRegulatorCleanReset(); // Retained marker only; no persistence flush.
|
||||
NVIC_SystemReset();
|
||||
while (true) {}
|
||||
}
|
||||
@@ -10720,6 +10722,8 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp,
|
||||
while (*command == ' ' || *command == '\t') command++;
|
||||
}
|
||||
|
||||
if (mesh::power::handleRegulatorCommand(command, reply, reply_capacity)) return true;
|
||||
|
||||
#if COMPANION_FEATURE_READER
|
||||
if (sender_timestamp == 0 && mesh::morseTimingActive(_radio)
|
||||
&& isCompanionReaderRequest(command)) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <helpers/RegulatorSettings.h>
|
||||
#include <Arduino.h> // needed for PlatformIO
|
||||
#include <helpers/ui/StartupScreen.h>
|
||||
#include <helpers/ui/DisplayPowerSettings.h>
|
||||
@@ -3600,6 +3601,16 @@ void setup() {
|
||||
#endif
|
||||
|
||||
|
||||
FILESYSTEM* regulator_prefs_fs = store.getPrimaryFS();
|
||||
#if defined(NRF52_PLATFORM)
|
||||
if (!mesh::storage::internalPrimaryFilesystemReady(primary_fs_boot)
|
||||
&& !store.isVolatilePrimaryFS()) regulator_prefs_fs = nullptr;
|
||||
#endif
|
||||
if (!mesh::power::beginRegulatorSettings(board, radio_driver, regulator_prefs_fs)) {
|
||||
MESH_DEBUG_PRINTLN("Regulator selection could not be applied");
|
||||
}
|
||||
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
// Load only the display policy before radio and secondary-storage startup.
|
||||
FILESYSTEM* display_prefs_fs = store.getPrimaryFS();
|
||||
@@ -4205,6 +4216,7 @@ void loop() {
|
||||
if (!morse_timing) companionPairingUiHilProbe();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
mesh::power::serviceRegulatorSettings();
|
||||
board.loop();
|
||||
if (mesh::serviceUsbLoggingWatchdog(usbLoggingRecoverySafe)) board.reboot();
|
||||
#ifdef TBEAM_1W
|
||||
|
||||
@@ -180,6 +180,7 @@ void setup() {
|
||||
#endif
|
||||
KISS_BOOT_STAGE("board.before");
|
||||
board.begin();
|
||||
board.applyMcuRegulator(mesh::power::RegulatorMode::Default);
|
||||
KISS_BOOT_STAGE("board.after");
|
||||
|
||||
#if defined(ESP32)
|
||||
|
||||
@@ -92,6 +92,7 @@ bool loadPrimaryRadio(mesh::RadioProfileParams& profile) {
|
||||
|
||||
void startLoRaReceiver() {
|
||||
board.begin();
|
||||
board.applyMcuRegulator(mesh::power::RegulatorMode::Default);
|
||||
if (!radio_init()) {
|
||||
Serial.println("Partition Expander: radio init failed; Wi-Fi recovery remains available");
|
||||
return;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <helpers/RegulatorSettings.h>
|
||||
#include <Arduino.h> // needed for PlatformIO
|
||||
#include <Mesh.h>
|
||||
#include <helpers/IdentityGeneration.h>
|
||||
@@ -203,6 +204,9 @@ void setup() {
|
||||
#else
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
if (!mesh::power::beginRegulatorSettings(board, radio_driver, fs)) {
|
||||
MESH_DEBUG_PRINTLN("Regulator selection could not be applied");
|
||||
}
|
||||
mesh::hilStartupTrace("fs_ready");
|
||||
#ifdef DISPLAY_CLASS
|
||||
mesh::hilStartupTrace("display_begin");
|
||||
@@ -538,6 +542,7 @@ static void __attribute__((noinline)) serviceCommandInterfaces() {
|
||||
command[0] = 0; // reset command buffer
|
||||
}
|
||||
|
||||
mesh::power::serviceRegulatorSettings();
|
||||
board.loop(); // let the board feed its watchdog, run periodic housekeeping
|
||||
|
||||
#ifdef ETHERNET_ENABLED
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <helpers/RegulatorSettings.h>
|
||||
#include <Arduino.h> // needed for PlatformIO
|
||||
#include <Mesh.h>
|
||||
#include <helpers/IdentityGeneration.h>
|
||||
@@ -137,6 +138,9 @@ void setup() {
|
||||
#else
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
if (!mesh::power::beginRegulatorSettings(board, radio_driver, fs)) {
|
||||
MESH_DEBUG_PRINTLN("Regulator selection could not be applied");
|
||||
}
|
||||
#ifdef DISPLAY_CLASS
|
||||
mesh::ui::loadDisplayPowerSettings(fs, false);
|
||||
mesh::ui::StartupScreen startup_screen;
|
||||
@@ -390,6 +394,7 @@ void loop() {
|
||||
if (display_ready) ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
mesh::power::serviceRegulatorSettings();
|
||||
board.loop();
|
||||
if (mesh::serviceUsbLoggingWatchdog(usbLoggingRecoverySafe)) board.reboot();
|
||||
#if MESH_USB_CONSOLE_COOPERATIVE
|
||||
|
||||
@@ -748,6 +748,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
board.begin();
|
||||
board.applyMcuRegulator(mesh::power::RegulatorMode::Default);
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.begin();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <helpers/RegulatorSettings.h>
|
||||
#include "SensorMesh.h"
|
||||
#include <math.h>
|
||||
#include <helpers/IdentityGeneration.h>
|
||||
@@ -162,6 +163,9 @@ void setup() {
|
||||
#else
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
if (!mesh::power::beginRegulatorSettings(board, radio_driver, fs)) {
|
||||
MESH_DEBUG_PRINTLN("Regulator selection could not be applied");
|
||||
}
|
||||
#ifdef DISPLAY_CLASS
|
||||
mesh::ui::loadDisplayPowerSettings(fs, false);
|
||||
mesh::ui::StartupScreen startup_screen;
|
||||
@@ -351,6 +355,7 @@ void loop() {
|
||||
command[0] = 0; // reset command buffer
|
||||
}
|
||||
|
||||
mesh::power::serviceRegulatorSettings();
|
||||
board.loop(); // let the board feed its watchdog, run periodic housekeeping
|
||||
|
||||
the_mesh.loop();
|
||||
|
||||
Reference in new issue
Block a user