Debugging info added.
This commit is contained in:
Blaz Kristan
2021-11-14 16:56:34 +01:00
parent 85ded6e500
commit 312cbc86e9
16 changed files with 90 additions and 129 deletions

View File

@@ -131,15 +131,20 @@ bool isAsterisksOnly(const char* str, byte maxLen)
}
bool requestJSONBufferLock()
bool requestJSONBufferLock(uint8_t module)
{
unsigned long now = millis();
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)
doc.clear();
return true;
@@ -148,8 +153,11 @@ bool requestJSONBufferLock()
void releaseJSONBufferLock()
{
#ifndef WLED_USE_DYNAMIC_JSON
DEBUG_PRINT(F("JSON buffer released. ("));
DEBUG_PRINT(jsonBufferLock);
DEBUG_PRINTLN(")");
fileDoc = nullptr;
jsonBufferLock = false;
#endif
#ifndef WLED_USE_DYNAMIC_JSON
jsonBufferLock = 0;
#endif
}