diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index c710d01c..a873c168 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -187,15 +187,11 @@ class AppModLeds:public SysModule { }); //fixture ui->initText(tableVar, "dimensions", nullptr, 32, true, [](JsonObject var) { //uiFun - char details[32] = ""; - print->fFormat(details, sizeof(details)-1, "P:%dx%dx%d V:%dx%dx%d", ledsV.widthP, ledsV.heightP, ledsV.depthP, ledsV.widthV, ledsV.heightV, ledsV.depthV); - web->addResponse(var["id"], "value", JsonString(details, JsonString::Copied)); + web->addResponseV(var["id"], "value", "P:%dx%dx%d V:%dx%dx%d", ledsV.widthP, ledsV.heightP, ledsV.depthP, ledsV.widthV, ledsV.heightV, ledsV.depthV); }); ui->initText(tableVar, "nrOfLeds", nullptr, 32, true, [](JsonObject var) { //uiFun - char details[32] = ""; - print->fFormat(details, sizeof(details)-1, "P:%d V:%d", ledsV.nrOfLedsP, ledsV.nrOfLedsV); - web->addResponse(var["id"], "value", JsonString(details, JsonString::Copied)); + web->addResponseV(var["id"], "value", "P:%d V:%d", ledsV.nrOfLedsP, ledsV.nrOfLedsV); web->addResponseV(var["id"], "comment", "Max %d", NUM_LEDS_Max); }); diff --git a/src/Sys/SysModFiles.cpp b/src/Sys/SysModFiles.cpp index 27448fcc..b3a9887f 100644 --- a/src/Sys/SysModFiles.cpp +++ b/src/Sys/SysModFiles.cpp @@ -78,9 +78,7 @@ void SysModFiles::setup() { }); ui->initText(parentVar, "drsize", nullptr, 32, true, [](JsonObject var) { //uiFun - char details[32] = ""; - print->fFormat(details, sizeof(details)-1, "%d / %d B", files->usedBytes(), files->totalBytes()); - web->addResponse(var["id"], "value", JsonString(details, JsonString::Copied)); + web->addResponseV(var["id"], "value", "%d / %d B", files->usedBytes(), files->totalBytes()); web->addResponse(var["id"], "label", "Total FS size"); }); diff --git a/src/Sys/SysModModel.h b/src/Sys/SysModModel.h index 297ee9e6..ea1d76f0 100644 --- a/src/Sys/SysModModel.h +++ b/src/Sys/SysModModel.h @@ -97,6 +97,8 @@ class SysModModel:public SysModule { static JsonObject modelParentVar; + bool doWriteModel = false; + SysModModel(); void setup(); void loop(); @@ -210,7 +212,6 @@ class SysModModel:public SysModule { void varToValues(JsonObject var, JsonArray values); private: - bool doWriteModel = false; bool doShowObsolete = false; bool cleanUpModelDone = false; diff --git a/src/Sys/SysModNetwork.cpp b/src/Sys/SysModNetwork.cpp index 601b10db..ede8f8fd 100644 --- a/src/Sys/SysModNetwork.cpp +++ b/src/Sys/SysModNetwork.cpp @@ -43,8 +43,9 @@ void SysModNetwork::setup() { }); ui->initButton(parentVar, "connect", nullptr, false, [](JsonObject var) { //uiFun - web->addResponse(var["id"], "comment", "Force reconnect (you loose current connection)"); + web->addResponse(var["id"], "comment", "Force reconnect (loose current connection)"); }, [this](JsonObject var, uint8_t) { //chFun + mdl->doWriteModel = true; //saves the model forceReconnect = true; }); ui->initText(parentVar, "nwstatus", nullptr, 32, true, [](JsonObject var) { //uiFun diff --git a/src/Sys/SysModPrint.cpp b/src/Sys/SysModPrint.cpp index 8ed8ca71..a70645a1 100644 --- a/src/Sys/SysModPrint.cpp +++ b/src/Sys/SysModPrint.cpp @@ -90,7 +90,7 @@ size_t SysModPrint::print(const char * format, ...) { va_start(args, format); - Serial.print(strncmp(pcTaskGetTaskName(NULL), "loopTask", 8) == 0?"λ":"α"); //looptask / asyncTCP task + Serial.print(strncmp(pcTaskGetTaskName(NULL), "loopTask", 8) == 0?"":"α"); //looptask λ/ asyncTCP task α for (size_t i = 0; i < strlen(format); i++) { diff --git a/src/Sys/SysModUI.cpp b/src/Sys/SysModUI.cpp index 49947adb..3cd566ef 100644 --- a/src/Sys/SysModUI.cpp +++ b/src/Sys/SysModUI.cpp @@ -202,7 +202,7 @@ void SysModUI::setChFunAndWs(JsonObject var, uint8_t rowNr, const char * value) else if (var["value"].is()) web->addResponse(var["id"], "value", var["value"].as()); else if (var["value"].is()) { - USER_PRINTF("setChFunAndWs %s JsonArray %s\n", var["id"].as(), var["value"].as().c_str()); + // USER_PRINTF("setChFunAndWs %s JsonArray %s\n", var["id"].as(), var["value"].as().c_str()); web->addResponse(var["id"], "value", var["value"].as()); } else { diff --git a/src/Sys/SysModWeb.cpp b/src/Sys/SysModWeb.cpp index b37039f1..def140e9 100644 --- a/src/Sys/SysModWeb.cpp +++ b/src/Sys/SysModWeb.cpp @@ -347,26 +347,18 @@ void SysModWeb::sendDataWs(std::function fi fill(wsBuf); //function parameter - if (client) { - if (client->status() == WS_CONNECTED && !client->queueIsFull() && client->queueLength() <= WS_MAX_QUEUED_MESSAGES / web->ws->count() / 2) { - isBinary?client->binary(wsBuf):client->text(wsBuf); - sendDataWsCounter++; - } - else - print->printClient("sendDataWs client full or not connected", client); - - // DEBUG_PRINTLN("to a single client."); - } else { - for (auto client:ws->getClients()) { - if (client->status() == WS_CONNECTED && !client->queueIsFull() && client->queueLength() <= WS_MAX_QUEUED_MESSAGES / web->ws->count() / 2) { - isBinary?client->binary(wsBuf): client->text(wsBuf); + for (auto loopClient:ws->getClients()) { + if (!client || client == loopClient) { + if (loopClient->status() == WS_CONNECTED && !loopClient->queueIsFull() && loopClient->queueLength() <= WS_MAX_QUEUED_MESSAGES / web->ws->count() / 2) { + isBinary?loopClient->binary(wsBuf): loopClient->text(wsBuf); sendDataWsCounter++; } - else - // print->printClient("sendDataWs client(s) full or not connected", client); //crash!! - USER_PRINT_Async("sendDataWs client full or not connected\n"); + else { + USER_PRINT_Async("sendDataWs client full or not connected\n", client); + ws->cleanupClients(); //only if above threshold + ws->_cleanBuffers(); + } } - // DEBUG_PRINTLN("to multiple clients."); } wsBuf->unlock(); ws->_cleanBuffers(); diff --git a/src/User/UserModInstances.h b/src/User/UserModInstances.h index 0dc65d1e..689fb29e 100644 --- a/src/User/UserModInstances.h +++ b/src/User/UserModInstances.h @@ -488,7 +488,7 @@ class UserModInstances:public SysModule { IPAddress broadcastIP(255, 255, 255, 255); if (0 != instanceUDP.beginPacket(broadcastIP, instanceUDPPort)) { // WLEDMM beginPacket == 0 --> error - USER_PRINTF("sendSysInfoUDP %s s:%d p:%d i:...%d\n", starModMessage.header.name, sizeof(UDPStarModMessage), instanceUDPPort, localIP[3]); + // USER_PRINTF("sendSysInfoUDP %s s:%d p:%d i:...%d\n", starModMessage.header.name, sizeof(UDPStarModMessage), instanceUDPPort, localIP[3]); // for (size_t x = 0; x < sizeof(UDPWLEDMessage) + sizeof(SysData) + sizeof(AppData); x++) { // char * xx = (char *)&starModMessage; // Serial.printf("%d: %d - %c\n", x, xx[x], xx[x]);