Add an hourly emergency battery sleep schedule for infrastructure nodes

This commit is contained in:
mikecarper committed 2026-10-28 02:06:58 -07:00
1 parent 744692fb93
commit 0c7dec9f19
30 files changed
+2020 -33

No files matched your search

+16
View File
@@ -5,6 +5,7 @@
#include <Mesh.h>
#include <helpers/PacketFileLoggingConfig.h>
#include <helpers/PowerSavingDiagnostics.h>
#include <helpers/EmergencyOtaWork.h>
#include <helpers/FloodGroupPlainText.h>
#include <helpers/FloodRuleExtensions.h>
#include <helpers/GuestLoginSettings.h>
@@ -1277,6 +1278,21 @@ public:
NodePrefs* getNodePrefs() {
return &_prefs;
}
#if MESH_ENABLE_EMERGENCY_POWER
mesh::power::EmergencyOtaWork _emergency_ota_work;
CommonCLI& getPowerCLI() { return _cli; }
bool emergencyPowerBusy() const {
#if defined(ENABLE_OTA)
if (_emergency_ota_work.busy(mesh::ota::ota_context_if_active(), millis())) return true;
#endif
#if MESH_ENABLE_DIRECT_OTA_ADMIN
if (direct_ota_admin.awaitingPeer()) return true;
#endif
return hasPendingOtaApply() || _cli.hasPendingRadioSettings()
|| _cli.hasActiveUserGpioTimer() || dirty_contacts_expiry != 0
|| (saved_radio_apply_pending && !temp_radio_applied) || _ota_update_at != 0;
}
#endif
bool isHiddenNode() const {
return _prefs.advert_interval == 0 && _prefs.flood_advert_interval == 0;
}
+20
View File
@@ -20,6 +20,7 @@
#include <helpers/HostKiss.h>
#include <helpers/MorseLoopPolicy.h>
#include <helpers/PowerManagementUtils.h>
#include <helpers/EmergencyPowerRuntime.h>
#include <helpers/HilStartupTrace.h>
#if MESH_PACKET_LOGGING
#include <helpers/SerialPacketLog.h>
@@ -727,6 +728,23 @@ void loop() {
#endif
serviceCommandInterfaces();
#if MESH_ENABLE_EMERGENCY_POWER
static mesh::power::EmergencyPowerRuntime emergency_power;
#if defined(ESP32_PLATFORM)
board.servicePowerTestControls();
#endif
rtc_clock.tick();
#ifdef HAS_EXTERNAL_WATCHDOG
external_watchdog.loop();
#endif
bool emergency_busy = command[0];
#if MESH_USB_CONSOLE_COOPERATIVE
emergency_busy = emergency_busy || the_mesh.hasPendingSerialOutput();
#endif
if (emergency_power.service(the_mesh, radio_driver, board,
the_mesh.getPowerCLI(), emergency_busy, the_mesh.emergencyPowerBusy())) return;
#endif
#if defined(PIN_USER_BTN) && defined(_SEEED_SENSECAP_SOLAR_H_) && !defined(DISPLAY_CLASS)
// Hold the user button to power off the SenseCAP Solar repeater.
int btnState = digitalRead(PIN_USER_BTN);
@@ -778,7 +796,9 @@ void loop() {
// Report the guard that really stopped this iteration, without probing
// later guards or changing their short-circuit hardware access.
#if defined(ESP32_PLATFORM)
#if !MESH_ENABLE_EMERGENCY_POWER
board.servicePowerTestControls();
#endif
mesh::esp32::serviceCpuFrequencyPolicy(board, the_mesh.getNodePrefs()->cpu_freq_mhz,
the_mesh.getNodePrefs()->powersaving_enabled != 0, millis(), false, the_mesh.isDualRadioActive());
#endif
+16
View File
@@ -3,6 +3,10 @@
#include <Arduino.h> // needed for PlatformIO
#include <Mesh.h>
#include <helpers/PowerSavingDiagnostics.h>
#include <helpers/EmergencyOtaWork.h>
#if MESH_ENABLE_EMERGENCY_POWER && defined(ENABLE_OTA)
#include <helpers/ota/OtaContext.h>
#endif
#include "RoomServerFeatures.h"
#if defined(NRF52_PLATFORM)
@@ -553,6 +557,18 @@ public:
NodePrefs* getNodePrefs() {
return &_prefs;
}
#if MESH_ENABLE_EMERGENCY_POWER
mesh::power::EmergencyOtaWork _emergency_ota_work;
CommonCLI& getPowerCLI() { return _cli; }
bool emergencyPowerBusy() const {
#if defined(ENABLE_OTA)
if (_emergency_ota_work.busy(mesh::ota::ota_context_if_active(), millis())) return true;
#endif
return hasPendingOtaApply() || _cli.hasPendingRadioSettings()
|| _cli.hasActiveUserGpioTimer() || dirty_contacts_expiry != 0
|| (saved_radio_apply_pending && !temp_radio_applied) || _ota_update_at != 0;
}
#endif
#ifdef DISPLAY_ACTIVITY_DASHBOARD
RadioActivityWindow* getActivityWindow() { return &_activity; }
+25 -5
View File
@@ -20,6 +20,7 @@
#include <helpers/HostKiss.h>
#include <helpers/MorseLoopPolicy.h>
#include <helpers/PowerManagementUtils.h>
#include <helpers/EmergencyPowerRuntime.h>
#if MESH_PACKET_LOGGING
#include <helpers/SerialPacketLog.h>
#endif
@@ -452,6 +453,28 @@ void loop() {
}
#endif
mesh::power::serviceRegulatorSettings();
#if defined(MESH_SOLARXIAO_POWER) && MESH_SOLARXIAO_POWER
mesh::solar::service();
#endif
board.loop();
#if MESH_ENABLE_EMERGENCY_POWER
static mesh::power::EmergencyPowerRuntime emergency_power;
#if defined(ESP32_PLATFORM)
board.servicePowerTestControls();
#endif
rtc_clock.tick();
#ifdef HAS_EXTERNAL_WATCHDOG
external_watchdog.loop();
#endif
bool emergency_busy = command[0];
#if MESH_USB_CONSOLE_COOPERATIVE
emergency_busy = emergency_busy || the_mesh.hasPendingSerialOutput();
#endif
if (emergency_power.service(the_mesh, radio_driver, board,
the_mesh.getPowerCLI(), emergency_busy, the_mesh.emergencyPowerBusy())) return;
#endif
the_mesh.loop();
const bool morse_timing = mesh::morseTimingActive(&radio_driver);
#if defined(USE_LR2021)
@@ -466,11 +489,6 @@ void loop() {
#endif
#endif
rtc_clock.tick();
mesh::power::serviceRegulatorSettings();
#if defined(MESH_SOLARXIAO_POWER) && MESH_SOLARXIAO_POWER
mesh::solar::service();
#endif
board.loop();
if (mesh::serviceUsbLoggingWatchdog(usbLoggingRecoverySafe)) board.reboot();
#if MESH_USB_CONSOLE_COOPERATIVE
#if MESH_ENABLE_HOST_KISS
@@ -489,7 +507,9 @@ void loop() {
&& !morse_timing) board.prepareProfileIdleCycle();
#endif
#if defined(ESP32_PLATFORM)
#if !MESH_ENABLE_EMERGENCY_POWER
board.servicePowerTestControls();
#endif
mesh::esp32::serviceCpuFrequencyPolicy(board, the_mesh.getNodePrefs()->cpu_freq_mhz,
the_mesh.getNodePrefs()->powersaving_enabled != 0, millis(), false, the_mesh.isDualRadioActive());
#endif
+16
View File
@@ -3,6 +3,10 @@
#include <Arduino.h> // needed for PlatformIO
#include <Mesh.h>
#include <helpers/PowerSavingDiagnostics.h>
#include <helpers/EmergencyOtaWork.h>
#if MESH_ENABLE_EMERGENCY_POWER && defined(ENABLE_OTA)
#include <helpers/ota/OtaContext.h>
#endif
#include "TimeSeriesData.h"
@@ -86,6 +90,18 @@ public:
const char* getRole() override { return FIRMWARE_ROLE; }
const char* getNodeName() { return _prefs.node_name; }
NodePrefs* getNodePrefs() { return &_prefs; }
#if MESH_ENABLE_EMERGENCY_POWER
mesh::power::EmergencyOtaWork _emergency_ota_work;
CommonCLI& getPowerCLI() { return _cli; }
bool emergencyPowerBusy() const {
#if defined(ENABLE_OTA)
if (_emergency_ota_work.busy(mesh::ota::ota_context_if_active(), millis())) return true;
#endif
return hasPendingOtaApply() || _cli.hasPendingRadioSettings()
|| _cli.hasActiveUserGpioTimer() || dirty_contacts_expiry != 0
|| (saved_radio_apply_pending && !temp_radio_applied);
}
#endif
uint32_t getPowerSaveSleepSeconds(uint32_t max_secs) const;
uint32_t getPowerSaveSleepMilliseconds(uint32_t max_ms) const;
bool isTrackerModeEnabled() const {
+15
View File
@@ -24,6 +24,7 @@
#include <helpers/HostKiss.h>
#include <helpers/MorseLoopPolicy.h>
#include <helpers/PowerManagementUtils.h>
#include <helpers/EmergencyPowerRuntime.h>
#if defined(NRF52_PLATFORM) && MESH_ENABLE_SENSOR_TRACKER
#include <utility/SoftwareTimer.h>
static SoftwareTimer tracker_wake_timer;
@@ -412,6 +413,18 @@ void loop() {
mesh::power::serviceRegulatorSettings();
board.loop(); // let the board feed its watchdog, run periodic housekeeping
#if MESH_ENABLE_EMERGENCY_POWER
static mesh::power::EmergencyPowerRuntime emergency_power;
#if defined(ESP32_PLATFORM)
board.servicePowerTestControls();
#endif
rtc_clock.tick();
#ifdef HAS_EXTERNAL_WATCHDOG
external_watchdog.loop();
#endif
if (emergency_power.service(the_mesh, radio_driver, board,
the_mesh.getPowerCLI(), command[0], the_mesh.emergencyPowerBusy())) return;
#endif
the_mesh.loop();
const bool morse_timing = mesh::morseTimingActive(&radio_driver);
#if defined(USE_LR2021)
@@ -442,7 +455,9 @@ void loop() {
#endif
#if defined(ESP32_PLATFORM)
#if !MESH_ENABLE_EMERGENCY_POWER
board.servicePowerTestControls();
#endif
mesh::esp32::serviceCpuFrequencyPolicy(board, the_mesh.getNodePrefs()->cpu_freq_mhz,
the_mesh.getNodePrefs()->powersaving_enabled != 0, millis(), false, the_mesh.isDualRadioActive());
#endif