diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index 24244b4b..8d059b2c 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -38,11 +38,17 @@ void espurnaRegisterLoop(void (*callback)()) { void setup() { + // ------------------------------------------------------------------------- + // Basic modules, will always run + // ------------------------------------------------------------------------- + // Init EEPROM, Serial, SPIFFS and system check systemSetup(); // Init persistance and terminal features settingsSetup(); + + // Hostname & board name initialization if (getSetting("hostname").length() == 0) { setSetting("hostname", getIdentifier()); } @@ -51,10 +57,6 @@ void setup() { // Show welcome message and system configuration info(); - // ------------------------------------------------------------------------- - // Basic modules, will always run - // ------------------------------------------------------------------------- - wifiSetup(); otaSetup(); #if TELNET_SUPPORT diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 51e44352..1d586cdf 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -41,7 +41,7 @@ bool _settings_save = false; // Reverse engineering EEPROM storage format // ----------------------------------------------------------------------------- -unsigned long _settingsSize() { +unsigned long settingsSize() { unsigned pos = SPI_FLASH_SEC_SIZE - 1; while (size_t len = EEPROM.read(pos)) { pos = pos - len - 2; @@ -49,6 +49,8 @@ unsigned long _settingsSize() { return SPI_FLASH_SEC_SIZE - pos; } +// ----------------------------------------------------------------------------- + unsigned int _settingsKeyCount() { unsigned count = 0; unsigned pos = SPI_FLASH_SEC_SIZE - 1; @@ -156,7 +158,7 @@ void _settingsKeys() { DEBUG_MSG_P(PSTR("> %s => %s\n"), (keys[i]).c_str(), value.c_str()); } - unsigned long freeEEPROM = SPI_FLASH_SEC_SIZE - _settingsSize(); + unsigned long freeEEPROM = SPI_FLASH_SEC_SIZE - settingsSize(); DEBUG_MSG_P(PSTR("Number of keys: %d\n"), keys.size()); DEBUG_MSG_P(PSTR("Free EEPROM: %d bytes (%d%%)\n"), freeEEPROM, 100 * freeEEPROM / SPI_FLASH_SEC_SIZE); @@ -407,9 +409,6 @@ void settingsSetup() { _settingsInitCommands(); - DEBUG_MSG_P(PSTR("[SETTINGS] EEPROM size: %d bytes\n"), SPI_FLASH_SEC_SIZE); - DEBUG_MSG_P(PSTR("[SETTINGS] Settings size: %d bytes\n"), _settingsSize()); - #if TERMINAL_SUPPORT #ifdef SERIAL_RX_PORT SERIAL_RX_PORT.begin(SERIAL_RX_BAUDRATE); diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 99a1ca20..3e9c3294 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -403,6 +403,7 @@ void info() { DEBUG_MSG_P(PSTR("[INIT] Last reset reason: %s\n"), (char *) ESP.getResetReason().c_str()); } + DEBUG_MSG_P(PSTR("[INIT] Settings size: %u bytes\n"), settingsSize()); DEBUG_MSG_P(PSTR("[INIT] Free heap: %u bytes\n"), getFreeHeap()); #if ADC_VCC_ENABLED DEBUG_MSG_P(PSTR("[INIT] Power: %u mV\n"), ESP.getVcc());