Avoid missing Preferences namespaces on fresh ESP32 boot

This commit is contained in:
mikecarper committed 2026-09-26 01:14:47 -07:00
1 parent 9ba79848ca
commit 73c7935261
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -1516,7 +1516,9 @@ void halt() {
void reloadCompanionWiFiPowerSave() {
uint8_t configured = mesh::wifi::kDefaultPowerSave;
Preferences nvs;
if (nvs.begin("mesh-wifi", true)) {
// On a fresh install the namespace may not exist until WiFi setup runs.
// Create it here so loading the default does not log NVS_NOT_FOUND.
if (nvs.begin("mesh-wifi", false)) {
configured = nvs.getUChar("powersave", mesh::wifi::kDefaultPowerSave);
nvs.end();
}
+3 -1
View File
@@ -54,7 +54,9 @@ IdentityLoadResult IdentityStore::loadResult(
// accepts either that temporary key or a missing identity.
if (strcmp(_dir, "/identity") == 0 && strcmp(name, "_main") == 0) {
Preferences migration_nvs;
if (migration_nvs.begin("mesh-pt-migrate", true)) {
// A fresh device has no migration namespace. Open read-write to create the
// empty namespace once instead of logging NVS_NOT_FOUND on every boot.
if (migration_nvs.begin("mesh-pt-migrate", false)) {
const bool pending = migration_nvs.getBool("id-pending", false);
uint8_t file_bytes[PUB_KEY_SIZE + PRV_KEY_SIZE];
const size_t staged = pending