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);