ESP8266 compatibility

This commit is contained in:
Patrick Haßel 2025-08-29 14:19:45 +02:00
parent 85d43231f5
commit 1080eb97d5

View File

@ -21,7 +21,12 @@ void listDir(const String &path, const String &indent) {
} }
if (child.isDirectory()) { if (child.isDirectory()) {
Serial.printf("%s[D] [ ] %s\n", indent.c_str(), child.name()); Serial.printf("%s[D] [ ] %s\n", indent.c_str(), child.name());
#ifdef ESP32
listDir(child.path(), indent + " "); listDir(child.path(), indent + " ");
#endif
#ifdef ESP8266
listDir(child.fullName(), indent + " ");
#endif
} }
child.close(); child.close();
} }
@ -40,7 +45,15 @@ void listDir(const String &path, const String &indent) {
} }
void configSetup() { void configSetup() {
LittleFS.begin(true); #ifdef ESP32
LittleFS.begin(true)
#endif
#ifdef ESP8266
if (!LittleFS.begin()) {
LittleFS.format();
LittleFS.begin();
}
#endif
Serial.println("Filesystem-content:"); Serial.println("Filesystem-content:");
listDir("/", ""); listDir("/", "");
} }
@ -49,7 +62,12 @@ File configOpen(const String &path, const bool write) {
if (!write && !LittleFS.exists(path)) { if (!write && !LittleFS.exists(path)) {
return {}; return {};
} }
#ifdef ESP32
return LittleFS.open(path, write ? "w" : "r", write); return LittleFS.open(path, write ? "w" : "r", write);
#endif
#ifdef ESP8266
return LittleFS.open(path, write ? "w" : "r");
#endif
} }
void doLog(const String &path, const String &value, const bool isPassword, const CONFIG_LOG type, const bool enable) { void doLog(const String &path, const String &value, const bool isPassword, const CONFIG_LOG type, const bool enable) {