From f4513d2fe30174993f16616ee17770c67c021ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 29 Jun 2018 13:16:37 +0200 Subject: [PATCH] Fix settings report after factory reset --- code/espurna/settings.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 19013663..51459a15 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -31,9 +31,10 @@ bool _settings_save = false; unsigned long settingsSize() { unsigned pos = SPI_FLASH_SEC_SIZE - 1; while (size_t len = EEPROMr.read(pos)) { + if (0xFF == len) break; pos = pos - len - 2; } - return SPI_FLASH_SEC_SIZE - pos; + return SPI_FLASH_SEC_SIZE - pos + EEPROM_DATA_END; } // ----------------------------------------------------------------------------- @@ -42,6 +43,7 @@ unsigned int settingsKeyCount() { unsigned count = 0; unsigned pos = SPI_FLASH_SEC_SIZE - 1; while (size_t len = EEPROMr.read(pos)) { + if (0xFF == len) break; pos = pos - len - 2; len = EEPROMr.read(pos); pos = pos - len - 2; @@ -57,6 +59,7 @@ String settingsKeyName(unsigned int index) { unsigned count = 0; unsigned pos = SPI_FLASH_SEC_SIZE - 1; while (size_t len = EEPROMr.read(pos)) { + if (0xFF == len) break; pos = pos - len - 2; if (count == index) { s.reserve(len);