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