#ifdef DEBUGMODE
void getEEPROMContent() {
    getEEPROMContent(EEPROM_SIZE);
}

void getEEPROMContent(int _len) {
    EEPROM.begin(EEPROM_SIZE);
    int _eeprom_address = 0;
    uint8_t _eeprom_value;
    
    Serial.print(F("EEPROM length: "));
    Serial.println(EEPROM.length());

    Serial.println(F("EEPROM data:"));
    //sprintf(logBuf, F("EEPROM-Data:"));
    //sendLog(logBuf);
    
    delay(20);
    //Serial.println(F("ADDR\t0\t1\t2\t3\t4\t5\t6\t7"));
    //Serial.println(F("ADDR"));
    //delay(1);
    //Serial.println();
    int _col = 0;
    if (_len == 0) _len = EEPROM.length();
    for (int _i = 0; _i < _len; _i++) {
        _eeprom_value = EEPROM.read(_eeprom_address);
        if (_col == 0) {
            //Serial.print(_eeprom_address);
            Serial.print("0x");
            if (_eeprom_address < 16) Serial.print("0");
            Serial.print(_eeprom_address, HEX);
            //Serial.print("\t");
            Serial.print(":  ");
        }
        if (_eeprom_value < 16) Serial.print("0");
        Serial.print(_eeprom_value, HEX);
        //Serial.print(_eeprom_value, DEC);
        //Serial.print("\t");
        Serial.print("  ");
        _eeprom_address = _eeprom_address + 1;

        if (_col >= 15) {
            _col = 0;
            Serial.println();
            delay(20); // otherwise ESP UART cannot receive correctly
        }
        else _col++;
    }
    EEPROM.end();
}
#endif

void formatEEPROMArea(int _from, int _len) {
    EEPROM.begin(EEPROM_SIZE);
    int _to;
    _to = _from + _len - 1;
    if(_to >= EEPROM_SIZE) _to = EEPROM_SIZE;
    Serial.print(F("EEPROM - formatting area from "));
    Serial.print(_from);
    Serial.print(F(" to "));
    Serial.println(_to);
    for (int i = _from; i <= _to; i++) {
        Serial.print(".");
        EEPROM.write(i, 0);
    }
    Serial.println("DONE");
    EEPROM.commit();
    EEPROM.end();
}

void formatEEPROM_AllData() {
  formatEEPROMArea(0, EEPROM_SIZE);
}

void clearSecrets_EEPROM() {
    sendLog(F("CONF: clearing Secrets from EEPROM."));
    formatEEPROMArea(EEPROM_STARTADDR_SECRETS, sizeof(confSecrets) + 2);
}
