Distinguish erased-NVS from NVS-unavailable in deferred warning

If the erase+reopen recovery also fails (e.g. missing/mislabeled NVS
partition), nvs_handle stays 0. Report that state explicitly instead of
claiming NVS was erased.
This commit is contained in:
J. Nick Koston
2026-04-27 10:06:05 -05:00
parent 98f250b62c
commit 8af10c0c97
+5 -1
View File
@@ -96,7 +96,11 @@ void ESP32Preferences::open() {
ESPPreferenceObject ESP32Preferences::make_preference(size_t length, uint32_t type) {
if (s_open_err != ESP_OK) {
ESP_LOGW(TAG, "nvs_open failed: %s - erased NVS", esp_err_to_name(s_open_err));
if (this->nvs_handle == 0) {
ESP_LOGW(TAG, "nvs_open failed: %s - NVS unavailable", esp_err_to_name(s_open_err));
} else {
ESP_LOGW(TAG, "nvs_open failed: %s - erased NVS", esp_err_to_name(s_open_err));
}
s_open_err = ESP_OK;
}
auto *pref = new ESP32PreferenceBackend(); // NOLINT(cppcoreguidelines-owning-memory)