Group runtime timers and flags to recover nRF52 repeater RAM

This commit is contained in:
mikecarper committed 2026-10-28 04:57:03 -07:00
1 parent 8f20fe5d83
commit acacf548ef
4 files changed
+45 -32

No files matched your search

+6 -3
View File
@@ -944,7 +944,6 @@ class CommonCLI {
#if MESH_ENABLE_EMERGENCY_POWER
FILESYSTEM* _emergency_power_fs = nullptr;
mesh::emergencypower::State _emergency_power;
bool _emergency_radio_sleeping = false;
void loadEmergencyPower(FILESYSTEM* fs);
bool saveEmergencyPower(const mesh::emergencypower::Settings& settings);
void loopEmergencyPower();
@@ -968,7 +967,6 @@ class CommonCLI {
SensorManager* _sensors;
RegionMap* _region_map;
uint32_t _media_regions_retry_ms = 0;
bool _media_regions_ready = false;
static bool mediaMeshRegionStoreMissing(FILESYSTEM* fs);
void recoverMediaMeshRegions();
static bool updateMediaMeshScope(void* context, bool enable, bool commit);
@@ -989,6 +987,12 @@ class CommonCLI {
bool _observer_save_result_known = false;
bool _observer_save_succeeded = false;
#endif
// Runtime flags share padding; persisted NodePrefs retains its own layout.
bool _media_regions_ready = false;
#if MESH_ENABLE_EMERGENCY_POWER
bool _emergency_radio_sleeping = false;
#endif
uint8_t _rx_settings_pending = 0;
bool _com_prefs_needs_upgrade = false; // old-format legacy prefs detected; rewrite once after load
bool _common_save_result_known = false;
bool _common_save_succeeded = false;
@@ -1004,7 +1008,6 @@ class CommonCLI {
RxGain = 1, RxPowerSaving = 2, RxSideDetectors = 4, RxRfRx = 8,
RxPendingMask = 15, RxRfRxDisabled = 128
};
uint8_t _rx_settings_pending = 0;
uint32_t _rx_settings_retry_at = 0;
uint32_t _prefs_save_failures = 0;
mesh::RadioProfileCLI _radio_profiles;
+9 -6
View File
@@ -44,18 +44,19 @@ inline bool decode(const uint8_t* in, size_t size, Settings& settings) {
}
struct State {
Settings settings;
// Runtime only: keep aligned timers together without packing accesses.
uint32_t sampledAt = 0;
uint16_t millivolts = 0;
uint8_t percentage = 0;
bool sampled = false;
bool valid = false;
bool lowBattery = false;
uint32_t phaseMs = 0;
uint32_t lastTick = 0;
uint32_t activationStarted = 0;
uint32_t awakeStarted = 0;
uint32_t awakeDuration = 0;
uint16_t millivolts = 0;
uint8_t percentage = 0;
Settings settings;
bool sampled = false;
bool valid = false;
bool lowBattery = false;
bool activationHold = false;
void begin(const Settings& loaded, uint32_t now) {
@@ -118,5 +119,7 @@ struct State {
return phase < AwakeWindowMs ? 0 : HourMs - phase;
}
};
static_assert(sizeof(State) <= 32, "Emergency timers must retain their compact RAM layout");
static_assert(alignof(State) >= alignof(uint32_t), "Emergency timers must remain aligned");
}} // namespace mesh::emergencypower