Playlist load bugfix.
serializeConfig() in loop() (prevent crash/hang in web server callback)
This commit is contained in:
parent
8402de601f
commit
799d4f9465
@ -7099,7 +7099,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
|
||||
if (SEGENV.call == 0) for (int i=0; i<cols; i++) previousBarHeight[i] = 0;
|
||||
|
||||
bool rippleTime = false;
|
||||
if (millis() - SEGENV.step >= (256 - SEGMENT.intensity)) {
|
||||
if (millis() - SEGENV.step >= (256U - SEGMENT.intensity)) {
|
||||
SEGENV.step = millis();
|
||||
rippleTime = true;
|
||||
}
|
||||
|
@ -946,6 +946,8 @@ void serializeConfig() {
|
||||
if (f) serializeJson(doc, f);
|
||||
f.close();
|
||||
releaseJSONBufferLock();
|
||||
|
||||
doSerializeConfig = false;
|
||||
}
|
||||
|
||||
//settings in /wsec.json, not accessible via webserver, for passwords and tokens
|
||||
|
@ -426,11 +426,14 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
||||
} else if (root["win"].isNull() && getVal(root["ps"], &ps, 0, 0) && ps > 0 && ps < 251 && ps != currentPreset) {
|
||||
// b) preset ID only or preset that does not change state (use embedded cycling limits if they exist in getVal())
|
||||
presetCycCurr = ps;
|
||||
presetId = ps;
|
||||
root.remove(F("v")); // may be added in UI call
|
||||
root.remove(F("time")); // may be added in UI call
|
||||
root.remove("ps");
|
||||
if (root.size() == 0) applyPreset(ps, callMode); // async load (only preset ID was specified)
|
||||
return stateResponse;
|
||||
if (root.size() == 0) {
|
||||
applyPreset(ps, callMode); // async load (only preset ID was specified)
|
||||
return stateResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,6 +583,8 @@ void serializeInfo(JsonObject root)
|
||||
leds["fps"] = strip.getFps();
|
||||
leds[F("maxpwr")] = (strip.currentMilliamps)? strip.ablMilliampsMax : 0;
|
||||
leds[F("maxseg")] = strip.getMaxSegments();
|
||||
//leds[F("actseg")] = strip.getActiveSegmentsNum();
|
||||
//leds[F("seglock")] = false; //might be used in the future to prevent modifications to segment config
|
||||
leds[F("cpal")] = strip.customPalettes.size(); //number of custom palettes
|
||||
|
||||
#ifndef WLED_DISABLE_2D
|
||||
|
@ -607,7 +607,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
}
|
||||
}
|
||||
usermods.readFromConfig(um); // force change of usermod parameters
|
||||
|
||||
DEBUG_PRINTLN(F("Done re-init usermods."));
|
||||
releaseJSONBufferLock();
|
||||
}
|
||||
|
||||
@ -638,7 +638,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
#endif
|
||||
|
||||
lastEditTime = millis();
|
||||
if (subPage != 2 && !doReboot) serializeConfig(); //do not save if factory reset or LED settings (which are saved after LED re-init)
|
||||
if (subPage != 2 && !doReboot) doSerializeConfig = true; //serializeConfig(); //do not save if factory reset or LED settings (which are saved after LED re-init)
|
||||
if (subPage == 4) alexaInit();
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,8 @@ void WLED::loop()
|
||||
|
||||
yield();
|
||||
|
||||
if (doSerializeConfig) serializeConfig();
|
||||
|
||||
if (doReboot && !doInitBusses) // if busses have to be inited & saved, wait until next iteration
|
||||
reset();
|
||||
|
||||
@ -351,6 +353,7 @@ void WLED::setup()
|
||||
#endif
|
||||
updateFSInfo();
|
||||
|
||||
strcpy_P(apSSID, PSTR("WLED-AP")); // otherwise it is empty on first boot until config is saved
|
||||
DEBUG_PRINTLN(F("Reading config"));
|
||||
deserializeConfigFromFS();
|
||||
|
||||
@ -388,25 +391,16 @@ void WLED::setup()
|
||||
escapedMac = WiFi.macAddress();
|
||||
escapedMac.replace(":", "");
|
||||
escapedMac.toLowerCase();
|
||||
if (strcmp(cmDNS, "x") == 0) // fill in unique mdns default
|
||||
{
|
||||
strcpy_P(cmDNS, PSTR("wled-"));
|
||||
sprintf(cmDNS + 5, "%*s", 6, escapedMac.c_str() + 6);
|
||||
}
|
||||
if (mqttDeviceTopic[0] == 0) {
|
||||
strcpy_P(mqttDeviceTopic, PSTR("wled/"));
|
||||
sprintf(mqttDeviceTopic + 5, "%*s", 6, escapedMac.c_str() + 6);
|
||||
}
|
||||
if (mqttClientID[0] == 0) {
|
||||
strcpy_P(mqttClientID, PSTR("WLED-"));
|
||||
sprintf(mqttClientID + 5, "%*s", 6, escapedMac.c_str() + 6);
|
||||
}
|
||||
// fill in unique mdns default
|
||||
if (strcmp(cmDNS, "x") == 0) sprintf_P(cmDNS, PSTR("wled-%*s"), 6, escapedMac.c_str() + 6);
|
||||
if (mqttDeviceTopic[0] == 0) sprintf_P(mqttDeviceTopic, PSTR("wled/%*s"), 6, escapedMac.c_str() + 6);
|
||||
if (mqttClientID[0] == 0) sprintf_P(mqttClientID, PSTR("WLED-%*s"), 6, escapedMac.c_str() + 6);
|
||||
|
||||
#ifdef WLED_ENABLE_ADALIGHT
|
||||
if (Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket();
|
||||
#endif
|
||||
|
||||
strip.service();
|
||||
strip.service(); // why?
|
||||
|
||||
#ifndef WLED_DISABLE_OTA
|
||||
if (aOtaEnabled) {
|
||||
@ -474,10 +468,10 @@ void WLED::initAP(bool resetAP)
|
||||
if (apBehavior == AP_BEHAVIOR_BUTTON_ONLY && !resetAP)
|
||||
return;
|
||||
|
||||
if (!apSSID[0] || resetAP)
|
||||
if (resetAP) {
|
||||
strcpy_P(apSSID, PSTR("WLED-AP"));
|
||||
if (resetAP)
|
||||
strcpy_P(apPass, PSTR(DEFAULT_AP_PASS));
|
||||
}
|
||||
DEBUG_PRINT(F("Opening access point "));
|
||||
DEBUG_PRINTLN(apSSID);
|
||||
WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255, 255, 255, 0));
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2209131
|
||||
#define VERSION 2209141
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -619,8 +619,9 @@ WLED_GLOBAL byte errorFlag _INIT(0);
|
||||
WLED_GLOBAL String messageHead, messageSub;
|
||||
WLED_GLOBAL byte optionType;
|
||||
|
||||
WLED_GLOBAL bool doReboot _INIT(false); // flag to initiate reboot from async handlers
|
||||
WLED_GLOBAL bool doPublishMqtt _INIT(false);
|
||||
WLED_GLOBAL bool doSerializeConfig _INIT(false); // flag to initiate saving of config
|
||||
WLED_GLOBAL bool doReboot _INIT(false); // flag to initiate reboot from async handlers
|
||||
WLED_GLOBAL bool doPublishMqtt _INIT(false);
|
||||
|
||||
// status led
|
||||
#if defined(STATUSLED)
|
||||
|
@ -207,7 +207,7 @@ void initServer()
|
||||
if (!isConfig) {
|
||||
serveJson(request); return; //if JSON contains "v"
|
||||
} else {
|
||||
serializeConfig(); //Save new settings to FS
|
||||
doSerializeConfig = true; //serializeConfig(); //Save new settings to FS
|
||||
}
|
||||
}
|
||||
request->send(200, "application/json", F("{\"success\":true}"));
|
||||
|
Loading…
Reference in New Issue
Block a user