Minor optimisation

- disable JSON live
- WS error string
- button irelevant check
This commit is contained in:
Blaz Kristan 2024-08-22 17:08:51 +02:00
parent d11ca2e159
commit 0bbd6b7c4b
3 changed files with 9 additions and 5 deletions

View File

@ -308,7 +308,7 @@ void handleButton()
buttonLongPressed[b] = true;
}
} else if (!isButtonPressed(b) && buttonPressedBefore[b]) { //released
} else if (buttonPressedBefore[b]) { //released
long dur = now - buttonPressedTime[b];
// released after rising-edge short press action

View File

@ -36,7 +36,7 @@
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
#endif
//#define WLED_ENABLE_DMX // uses 3.5kb (use LEDPIN other than 2)
#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
//#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
#ifndef WLED_DISABLE_LOXONE
#define WLED_ENABLE_LOXONE // uses 1.2kb
#endif
@ -331,7 +331,7 @@ typedef class WiFiOptions {
struct {
uint8_t selectedWiFi : 4; // max 16 SSIDs
uint8_t apChannel : 4;
bool apHide : 1;
uint8_t apHide : 3;
uint8_t apBehavior : 3;
bool noWifiSleep : 1;
bool force802_3g : 1;

View File

@ -96,6 +96,8 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
//pong message was received (in response to a ping request maybe)
DEBUG_PRINTLN(F("WS pong."));
} else {
DEBUG_PRINTLN(F("WS unknown event."));
}
}
@ -104,10 +106,11 @@ void sendDataWs(AsyncWebSocketClient * client)
if (!ws.count()) return;
if (!requestJSONBufferLock(12)) {
const char* error = PSTR("{\"error\":3}");
if (client) {
client->text(F("{\"error\":3}")); // ERR_NOBUF
client->text(FPSTR(error)); // ERR_NOBUF
} else {
ws.textAll(F("{\"error\":3}")); // ERR_NOBUF
ws.textAll(FPSTR(error)); // ERR_NOBUF
}
return;
}
@ -120,6 +123,7 @@ void sendDataWs(AsyncWebSocketClient * client)
size_t len = measureJson(*pDoc);
DEBUG_PRINTF_P(PSTR("JSON buffer size: %u for WS request (%u).\n"), pDoc->memoryUsage(), len);
// the following may no longer be necessary as heap management has been fixed by @willmmiles in AWS
size_t heap1 = ESP.getFreeHeap();
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
#ifdef ESP8266