post merge
MM specific adjustments
This commit is contained in:
@@ -204,12 +204,12 @@ bool requestJSONBufferLock(uint8_t module)
|
||||
{
|
||||
unsigned long now = millis();
|
||||
|
||||
while (jsonBufferLock && millis()-now < 100) delay(1); // wait for fraction for buffer lock
|
||||
while (jsonBufferLock && millis()-now < 1200) delay(1); // wait for fraction for buffer lock
|
||||
|
||||
if (jsonBufferLock) {
|
||||
DEBUG_PRINT(F("ERROR: Locking JSON buffer failed! (still locked by "));
|
||||
DEBUG_PRINT(jsonBufferLock);
|
||||
DEBUG_PRINTLN(")");
|
||||
USER_PRINT(F("ERROR: Locking JSON buffer failed! (still locked by "));
|
||||
USER_PRINT(jsonBufferLock);
|
||||
USER_PRINTLN(")");
|
||||
return false; // waiting time-outed
|
||||
}
|
||||
|
||||
|
||||
@@ -822,11 +822,13 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0);
|
||||
#define DEBUGOUT(x) (netDebugEnabled || !canUseSerial())?NetDebug.print(x):Serial.print(x)
|
||||
#define DEBUGOUTLN(x) (netDebugEnabled || !canUseSerial())?NetDebug.println(x):Serial.println(x)
|
||||
#define DEBUGOUTF(x...) (netDebugEnabled || !canUseSerial())?NetDebug.printf(x):Serial.printf(x)
|
||||
#define DEBUGOUTFP(x...) (netDebugEnabled || !canUseSerial())?NetDebug.printf_P(x):Serial.printf_P(x)
|
||||
#define DEBUGOUTFlush() (netDebugEnabled || !canUseSerial())?NetDebug.flush():Serial.flush()
|
||||
#else
|
||||
#define DEBUGOUT(x) {if (canUseSerial()) Serial.print(x);}
|
||||
#define DEBUGOUTLN(x) {if (canUseSerial()) Serial.println(x);}
|
||||
#define DEBUGOUTF(x...) {if (canUseSerial()) Serial.printf(x);}
|
||||
#define DEBUGOUTFP(x...) {if (canUseSerial()) Serial.printf_P(x);}
|
||||
#define DEBUGOUTFlush() {if (canUseSerial()) Serial.flush();}
|
||||
#endif
|
||||
|
||||
@@ -837,10 +839,12 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0);
|
||||
#define DEBUG_PRINT(x) DEBUGOUT(x)
|
||||
#define DEBUG_PRINTLN(x) DEBUGOUTLN(x)
|
||||
#define DEBUG_PRINTF(x...) DEBUGOUTF(x)
|
||||
#define DEBUG_PRINTF_P(x...) DEBUGOUTFP(x)
|
||||
#else
|
||||
#define DEBUG_PRINT(x)
|
||||
#define DEBUG_PRINTLN(x)
|
||||
#define DEBUG_PRINTF(x...)
|
||||
#define DEBUG_PRINTF_P(x...)
|
||||
#endif
|
||||
|
||||
#define USER_PRINT(x) DEBUGOUT(x)
|
||||
|
||||
@@ -137,7 +137,7 @@ void handleSerial()
|
||||
} else if (next == '{') { //JSON API
|
||||
bool verboseResponse = false;
|
||||
if (!requestJSONBufferLock(16)) {
|
||||
Serial.println(F("{\"error\":3}")); // ERR_NOBUF
|
||||
if (Serial) Serial.println(F("{\"error\":3}")); // ERR_NOBUF
|
||||
return;
|
||||
}
|
||||
Serial.setTimeout(100);
|
||||
|
||||
@@ -193,7 +193,11 @@ void initServer()
|
||||
bool verboseResponse = false;
|
||||
bool isConfig = false;
|
||||
|
||||
if (!requestJSONBufferLock(14)) return;
|
||||
if (!requestJSONBufferLock(14)) {
|
||||
// serveJsonError(request, 503, ERR_NOBUF); //WLEDMM we dont have this function, so we'll send the error response "old style"
|
||||
request->send(503, "application/json", F("{\"error\":3}")); // ERR_NOBUF
|
||||
return;
|
||||
}
|
||||
|
||||
DeserializationError error = deserializeJson(doc, (uint8_t*)(request->_tempObject));
|
||||
JsonObject root = doc.as<JsonObject>();
|
||||
|
||||
@@ -123,8 +123,8 @@ void sendDataWs(AsyncWebSocketClient * client)
|
||||
JsonObject info = doc.createNestedObject("info");
|
||||
serializeInfo(info);
|
||||
|
||||
size_t len = measureJson(*pDoc);
|
||||
DEBUG_PRINTF("JSON buffer size: %u for WS request (%u).\n", pDoc->memoryUsage(), len);
|
||||
size_t len = measureJson(doc);
|
||||
DEBUG_PRINTF("JSON buffer size: %u for WS request (%u).\n", doc.memoryUsage(), len);
|
||||
|
||||
#ifdef ESP8266
|
||||
size_t heap1 = ESP.getFreeHeap(); // WLEDMM moved into 8266 specific section
|
||||
|
||||
Reference in New Issue
Block a user