wsec start
This commit is contained in:
parent
fc9255cdc4
commit
8ddae6bba0
@ -15,6 +15,13 @@ void getStringFromJson(char* dest, const char* src, size_t len) {
|
||||
void deserializeSettings() {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
|
||||
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
|
||||
|
||||
bool success = readObjectFromFile("/cfg.json", nullptr, &doc);
|
||||
if (!success) { //if file does not exist, try reading from EEPROM
|
||||
loadSettingsFromEEPROM();
|
||||
}
|
||||
|
||||
//deserializeJson(doc, json);
|
||||
|
||||
//int rev_major = doc["rev"][0]; // 1
|
||||
@ -229,6 +236,7 @@ void deserializeSettings() {
|
||||
getStringFromJson(ntpServerName, if_ntp["host"], 33); // "1.wled.pool.ntp.org"
|
||||
CJSON(currentTimezone, if_ntp["tz"]);
|
||||
CJSON(utcOffsetSecs, if_ntp["offset"]);
|
||||
CJSON(useAMPM, if_ntp["ampm"]);
|
||||
|
||||
JsonObject ol = doc["ol"];
|
||||
CJSON(overlayDefault ,ol["clock"]); // 0
|
||||
@ -281,6 +289,13 @@ void deserializeSettings() {
|
||||
CJSON(aOtaEnabled, ota["aota"]);
|
||||
getStringFromJson(otaPass, pwd, 33); //normally not present due to security
|
||||
}
|
||||
|
||||
DEBUG_PRINTLN(F("Reading settings from /wsec.json..."));
|
||||
|
||||
success = readObjectFromFile("/wsec.json", nullptr, &doc);
|
||||
if (!success) { //if file does not exist, try reading from EEPROM
|
||||
loadSettingsFromEEPROM();
|
||||
}
|
||||
}
|
||||
|
||||
void serializeSettings() {
|
||||
@ -510,6 +525,7 @@ void serializeSettings() {
|
||||
if_ntp["host"] = ntpServerName;
|
||||
if_ntp["tz"] = currentTimezone;
|
||||
if_ntp["offset"] = utcOffsetSecs;
|
||||
if_ntp["ampm"] = useAMPM;
|
||||
|
||||
JsonObject ol = doc.createNestedObject("ol");
|
||||
ol["clock"] = overlayDefault;
|
||||
@ -542,4 +558,27 @@ void serializeSettings() {
|
||||
ota["aota"] = aOtaEnabled;
|
||||
|
||||
serializeJson(doc, Serial);
|
||||
}
|
||||
|
||||
//settings in /wsec.json, not accessible via webserver, for passwords and tokens
|
||||
void deserializeSettingsSec() {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
|
||||
JsonObject nw_ins_0 = doc["nw"]["ins"][0];
|
||||
getStringFromJson(clientPass, nw_ins_0["psk"], 65);
|
||||
|
||||
JsonObject ap = doc["ap"];
|
||||
getStringFromJson(apPass, ap["psk"] , 65);
|
||||
|
||||
//mqtt pass
|
||||
|
||||
//blynk token
|
||||
|
||||
//hue token
|
||||
|
||||
//ota pass
|
||||
}
|
||||
|
||||
void serializeSettingsSec() {
|
||||
|
||||
}
|
@ -330,6 +330,7 @@ bool readObjectFromFileUsingId(const char* file, uint16_t id, JsonDocument* dest
|
||||
return readObjectFromFile(file, objKey, dest);
|
||||
}
|
||||
|
||||
//if the key is a nullptr, deserialize entire object
|
||||
bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest)
|
||||
{
|
||||
if (doCloseFile) closeFile();
|
||||
@ -340,7 +341,7 @@ bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest)
|
||||
f = WLED_FS.open(file, "r");
|
||||
if (!f) return false;
|
||||
|
||||
if (!bufferedFind(key)) //key does not exist in file
|
||||
if (key != nullptr && !bufferedFind(key)) //key does not exist in file
|
||||
{
|
||||
f.close();
|
||||
dest->clear();
|
||||
|
@ -786,7 +786,7 @@ void deEEP() {
|
||||
|
||||
DEBUG_PRINTLN(F("Preset file not found, attempting to load from EEPROM"));
|
||||
DEBUGFS_PRINTLN(F("Allocating saving buffer for dEEP"));
|
||||
DynamicJsonDocument dDoc(JSON_BUFFER_SIZE);
|
||||
DynamicJsonDocument dDoc(JSON_BUFFER_SIZE *2);
|
||||
JsonObject sObj = dDoc.to<JsonObject>();
|
||||
sObj.createNestedObject("0");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user