mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
Feature: upload customization settings from a file #256
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user