Fix OTA recovery, radio2 replies, and preference persistence
Keep each deferred OTA response tied to the request's radio profile and generation. Separate requests from different radio sessions, discard stale queued responses, and retain the existing companion and infrastructure reply policies. Reject staged captures with invalid file framing before adopting their state. Recover fixed internal-flash trailer bytes after interrupted checkpoints and handle small ESP32 delta trailers that share metadata sectors. Fail closed when install preflight cannot read a valid header, so hardware and automatic-update policy checks cannot be skipped. Replace Companion preferences through verified file transactions and quarantine writes after incomplete loads on all platforms. Initialize serializer runtime fields before preferences snapshots copy them. Add production-code fault regressions to CI for deferred routing, store recovery, install preflight, and preferences persistence. Validation: 1,510 native tests, 60 host checks, and six firmware targets across ESP32, nRF52, STM32, and RP2040.
This commit is contained in:
1 parent
39c3f7b25c
commit
016a1ed2ea
20 files changed
+1010
-44
No files matched your search
@@ -641,16 +641,23 @@ bool DataStore::loadPrefs(CompanionNodePrefs& prefs, double& node_lat,
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (_prefs_load_incomplete) return false;
|
||||
#if defined(ESP32_PLATFORM) || defined(RP2040_PLATFORM)
|
||||
if (!mesh::ContactFileTransaction::recover(_fs, "/new_prefs")) {
|
||||
_prefs_load_incomplete = true;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (_fs->exists("/new_prefs")) {
|
||||
return loadPrefsInt("/new_prefs", prefs, node_lat, node_lon);
|
||||
const bool loaded = loadPrefsInt("/new_prefs", prefs, node_lat, node_lon);
|
||||
_prefs_load_incomplete = !loaded;
|
||||
return loaded;
|
||||
}
|
||||
if (!_fs->exists("/node_prefs")) return true;
|
||||
#endif
|
||||
|
||||
if (!loadPrefsInt("/node_prefs", prefs, node_lat, node_lon)) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
_prefs_load_incomplete = true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#if defined(NRF52_PLATFORM)
|
||||
@@ -826,10 +833,14 @@ bool DataStore::loadPrefsInt(const char *filename,
|
||||
}
|
||||
|
||||
bool DataStore::savePrefs(const CompanionNodePrefs& _prefs, double node_lat, double node_lon) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
if (_prefs_load_incomplete) return false;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
if (_primary_storage_unavailable) return false;
|
||||
#endif
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
mesh::AtomicFileWriter file(_fs, "/new_prefs");
|
||||
#elif defined(ESP32_PLATFORM) || defined(RP2040_PLATFORM)
|
||||
mesh::ContactFileTransaction file(_fs, "/new_prefs");
|
||||
#else
|
||||
File file = openWrite(_fs, "/new_prefs");
|
||||
#endif
|
||||
@@ -928,7 +939,7 @@ bool DataStore::savePrefs(const CompanionNodePrefs& _prefs, double node_lat, dou
|
||||
sizeof(_prefs.bluetooth_stealth_mode))
|
||||
== sizeof(_prefs.bluetooth_stealth_mode);
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) || defined(ESP32_PLATFORM) || defined(RP2040_PLATFORM)
|
||||
success = file.commit(success);
|
||||
if (!success) MESH_DEBUG_PRINTLN("DataStore: atomic preferences write failed");
|
||||
#else
|
||||
|
||||
@@ -39,6 +39,7 @@ class DataStore
|
||||
FILESYSTEM* _configuredFsExtra;
|
||||
mesh::RTCClock* _clock;
|
||||
IdentityStore identity_store;
|
||||
bool _prefs_load_incomplete = false;
|
||||
#if !defined(NRF52_PLATFORM)
|
||||
bool _channel_load_incomplete = false;
|
||||
#endif
|
||||
@@ -68,7 +69,6 @@ class DataStore
|
||||
bool _identity_creation_blocked = false;
|
||||
bool _primary_storage_unavailable = false;
|
||||
bool _secondary_authority_unknown = false;
|
||||
bool _prefs_load_incomplete = false;
|
||||
uint32_t _contact_page_generations[mesh::storage::CONTACT_PAGE_COUNT];
|
||||
bool _legacy_contacts_pending_cleanup;
|
||||
bool _legacy_migration_ready;
|
||||
|
||||
Reference in new issue
Block a user