Bugfix.
Debugging info added.
This commit is contained in:
parent
85ded6e500
commit
312cbc86e9
@ -1092,10 +1092,7 @@ void WS2812FX::deserializeMap(uint8_t n) {
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(5)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUG_PRINT(F("Reading LED map from "));
|
DEBUG_PRINT(F("Reading LED map from "));
|
||||||
|
@ -428,10 +428,7 @@ void deserializeConfigFromFS() {
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(1)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
|
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
|
||||||
@ -459,10 +456,7 @@ void serializeConfig() {
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(2)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonArray rev = doc.createNestedArray("rev");
|
JsonArray rev = doc.createNestedArray("rev");
|
||||||
@ -780,10 +774,7 @@ bool deserializeConfigSec() {
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(3)) return false;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool success = readObjectFromFile("/wsec.json", nullptr, &doc);
|
bool success = readObjectFromFile("/wsec.json", nullptr, &doc);
|
||||||
@ -832,10 +823,7 @@ void serializeConfigSec() {
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(4)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonObject nw = doc.createNestedObject("nw");
|
JsonObject nw = doc.createNestedObject("nw");
|
||||||
|
@ -1066,6 +1066,7 @@ function updateSelectedFx()
|
|||||||
var parent = gId('fxlist');
|
var parent = gId('fxlist');
|
||||||
var selEffectInput = parent.querySelector(`input[name="fx"][value="${selectedFx}"]`);
|
var selEffectInput = parent.querySelector(`input[name="fx"][value="${selectedFx}"]`);
|
||||||
if (selEffectInput) selEffectInput.checked = true;
|
if (selEffectInput) selEffectInput.checked = true;
|
||||||
|
console.log(selEffectInput);
|
||||||
|
|
||||||
var selElement = parent.querySelector('.selected');
|
var selElement = parent.querySelector('.selected');
|
||||||
if (selElement) selElement.classList.remove('selected');
|
if (selElement) selElement.classList.remove('selected');
|
||||||
|
@ -272,7 +272,7 @@ void sappends(char stype, const char* key, char* val);
|
|||||||
void prepareHostname(char* hostname);
|
void prepareHostname(char* hostname);
|
||||||
void _setRandomColor(bool _sec, bool fromButton);
|
void _setRandomColor(bool _sec, bool fromButton);
|
||||||
bool isAsterisksOnly(const char* str, byte maxLen);
|
bool isAsterisksOnly(const char* str, byte maxLen);
|
||||||
bool requestJSONBufferLock();
|
bool requestJSONBufferLock(uint8_t module=255);
|
||||||
void releaseJSONBufferLock();
|
void releaseJSONBufferLock();
|
||||||
|
|
||||||
//wled_eeprom.cpp
|
//wled_eeprom.cpp
|
||||||
|
@ -579,10 +579,7 @@ void decodeIRJson(uint32_t code)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(6)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sprintf_P(objKey, PSTR("\"0x%lX\":"), (unsigned long)code);
|
sprintf_P(objKey, PSTR("\"0x%lX\":"), (unsigned long)code);
|
||||||
|
@ -920,10 +920,7 @@ void serveJson(AsyncWebServerRequest* request)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
AsyncJsonResponse* response = new AsyncJsonResponse(JSON_BUFFER_SIZE);
|
AsyncJsonResponse* response = new AsyncJsonResponse(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(7)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AsyncJsonResponse *response = new AsyncJsonResponse(&doc);
|
AsyncJsonResponse *response = new AsyncJsonResponse(&doc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -94,10 +94,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(8)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (payload[0] == '{') { //JSON API
|
if (payload[0] == '{') { //JSON API
|
||||||
deserializeJson(doc, payloadStr);
|
deserializeJson(doc, payloadStr);
|
||||||
|
@ -25,10 +25,7 @@ bool applyPreset(byte index, byte callMode)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(9)) return false;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
errorFlag = readObjectFromFileUsingId(filename, index, &doc) ? ERR_NONE : ERR_FS_PLOAD;
|
errorFlag = readObjectFromFileUsingId(filename, index, &doc) ? ERR_NONE : ERR_FS_PLOAD;
|
||||||
@ -60,10 +57,7 @@ void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(10)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sObj = doc.to<JsonObject>();
|
sObj = doc.to<JsonObject>();
|
||||||
|
@ -418,10 +418,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(11)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonObject um = doc.createNestedObject("um");
|
JsonObject um = doc.createNestedObject("um");
|
||||||
|
@ -131,15 +131,20 @@ bool isAsterisksOnly(const char* str, byte maxLen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool requestJSONBufferLock()
|
bool requestJSONBufferLock(uint8_t module)
|
||||||
{
|
{
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
|
||||||
while (jsonBufferLock && millis()-now < 1000) delay(1); // wait for a second for buffer lock
|
while (jsonBufferLock && millis()-now < 1000) delay(1); // wait for a second for buffer lock
|
||||||
|
|
||||||
if (millis()-now >= 1000) return false; // waiting time-outed
|
if (millis()-now >= 1000) {
|
||||||
|
DEBUG_PRINT(F("ERROR: Locking JSON buffer failed! ("));
|
||||||
|
DEBUG_PRINT(jsonBufferLock);
|
||||||
|
DEBUG_PRINTLN(")");
|
||||||
|
return false; // waiting time-outed
|
||||||
|
}
|
||||||
|
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = module ? module : 255;
|
||||||
fileDoc = &doc; // used for applying presets (presets.cpp)
|
fileDoc = &doc; // used for applying presets (presets.cpp)
|
||||||
doc.clear();
|
doc.clear();
|
||||||
return true;
|
return true;
|
||||||
@ -148,8 +153,11 @@ bool requestJSONBufferLock()
|
|||||||
|
|
||||||
void releaseJSONBufferLock()
|
void releaseJSONBufferLock()
|
||||||
{
|
{
|
||||||
#ifndef WLED_USE_DYNAMIC_JSON
|
DEBUG_PRINT(F("JSON buffer released. ("));
|
||||||
|
DEBUG_PRINT(jsonBufferLock);
|
||||||
|
DEBUG_PRINTLN(")");
|
||||||
fileDoc = nullptr;
|
fileDoc = nullptr;
|
||||||
jsonBufferLock = false;
|
#ifndef WLED_USE_DYNAMIC_JSON
|
||||||
|
jsonBufferLock = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
|||||||
#ifndef WLED_USE_DYNAMIC_JSON
|
#ifndef WLED_USE_DYNAMIC_JSON
|
||||||
WLED_GLOBAL StaticJsonDocument<JSON_BUFFER_SIZE> doc;
|
WLED_GLOBAL StaticJsonDocument<JSON_BUFFER_SIZE> doc;
|
||||||
#endif
|
#endif
|
||||||
WLED_GLOBAL volatile bool jsonBufferLock _INIT(false);
|
WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0);
|
||||||
|
|
||||||
// enable additional debug output
|
// enable additional debug output
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
|
@ -385,10 +385,7 @@ void deEEP() {
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(12)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonObject sObj = doc.to<JsonObject>();
|
JsonObject sObj = doc.to<JsonObject>();
|
||||||
@ -469,6 +466,7 @@ void deEEP() {
|
|||||||
File f = WLED_FS.open("/presets.json", "w");
|
File f = WLED_FS.open("/presets.json", "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
errorFlag = ERR_FS_GENERAL;
|
errorFlag = ERR_FS_GENERAL;
|
||||||
|
releaseJSONBufferLock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
serializeJson(doc, f);
|
serializeJson(doc, f);
|
||||||
|
@ -47,10 +47,7 @@ void handleSerial()
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(13)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
Serial.setTimeout(100);
|
Serial.setTimeout(100);
|
||||||
DeserializationError error = deserializeJson(doc, Serial);
|
DeserializationError error = deserializeJson(doc, Serial);
|
||||||
|
@ -114,16 +114,15 @@ void initServer()
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(14)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DeserializationError error = deserializeJson(doc, (uint8_t*)(request->_tempObject));
|
DeserializationError error = deserializeJson(doc, (uint8_t*)(request->_tempObject));
|
||||||
JsonObject root = doc.as<JsonObject>();
|
JsonObject root = doc.as<JsonObject>();
|
||||||
if (error || root.isNull()) {
|
if (error || root.isNull()) {
|
||||||
request->send(400, "application/json", F("{\"error\":9}")); return;
|
releaseJSONBufferLock();
|
||||||
|
request->send(400, "application/json", F("{\"error\":9}"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const String& url = request->url();
|
const String& url = request->url();
|
||||||
isConfig = url.indexOf("cfg") > -1;
|
isConfig = url.indexOf("cfg") > -1;
|
||||||
|
@ -40,10 +40,7 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(15)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DeserializationError error = deserializeJson(doc, data, len);
|
DeserializationError error = deserializeJson(doc, data, len);
|
||||||
@ -120,10 +117,7 @@ void sendDataWs(AsyncWebSocketClient * client)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(16)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonObject state = doc.createNestedObject("state");
|
JsonObject state = doc.createNestedObject("state");
|
||||||
|
@ -256,10 +256,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
#ifdef WLED_USE_DYNAMIC_JSON
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
DynamicJsonDocument doc(2048); // 2k is enough for usermods
|
DynamicJsonDocument doc(2048); // 2k is enough for usermods
|
||||||
#else
|
#else
|
||||||
if (!requestJSONBufferLock()) {
|
if (!requestJSONBufferLock(17)) return;
|
||||||
DEBUG_PRINTLN(F("ERROR: Locking JSON buffer failed!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JsonObject mods = doc.createNestedObject(F("um"));
|
JsonObject mods = doc.createNestedObject(F("um"));
|
||||||
|
Loading…
Reference in New Issue
Block a user