Feature: upload customization settings from a file #256

This commit is contained in:
Proddy
2022-05-07 17:49:02 +02:00
parent f243162724
commit 9923b60d64
26 changed files with 348 additions and 352 deletions

View File

@@ -30,12 +30,12 @@ class FSPersistence {
DynamicJsonDocument jsonDocument = DynamicJsonDocument(_bufferSize);
DeserializationError error = deserializeJson(jsonDocument, settingsFile);
if (error == DeserializationError::Ok && jsonDocument.is<JsonObject>()) {
// jsonDocument.shrinkToFit(); // added by proddy
JsonObject jsonObject = jsonDocument.as<JsonObject>();
// debug added by Proddy
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_USE_SERIAL)
Serial.println();
Serial.printf("Reading file: %s: ", _filePath);
serializeJson(jsonDocument, Serial);
Serial.println();
@@ -49,9 +49,17 @@ class FSPersistence {
settingsFile.close();
}
// If we reach here we have not been successful in loading the config,
// hard-coded emergency defaults are now applied.
// If we reach here we have not been successful in loading the config,
// hard-coded emergency defaults are now applied.
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_USE_SERIAL)
Serial.println();
Serial.printf("Applying defaults for %s: ", _filePath);
Serial.println();
#endif
#endif
applyDefaults();
writeToFS(); // added to make sure the initial file is created
}
bool writeToFS() {