отправка конфига в сокеты

This commit is contained in:
Dmitry Borisenko
2021-12-16 00:19:08 +01:00
parent 715d20c21f
commit f7a97c2d36
8 changed files with 55 additions and 49 deletions

View File

@@ -4,6 +4,7 @@
#include "FSEditor.h"
#include "Utils/FileUtils.h"
#include "Utils/WebUtils.h"
#include "WebSocket.h"
AsyncWebSocket ws("/ws");
AsyncEventSource events("/events");
@@ -112,9 +113,9 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
}
Serial.printf("%s\n", msg.c_str());
if (msg.startsWith("config")) {
if (msg.startsWith("/config")) {
SerialPrint("I", F("WS"), F("config send"));
sendEspSetupToWS();
wsSendSetup();
// publishWidgetsWS();
// publishStateWS();
@@ -211,18 +212,3 @@ void HttpServerinitWS() {
server.addHandler(&events);
#endif
}
//===========web sockets==============================
void sendEspSetupToWS() {
File file = seekFile("/setup.json");
DynamicJsonDocument doc(1024);
file.find("[");
do {
deserializeJson(doc, file);
// Serial.println(doc.as<String>());
ws.textAll(doc.as<String>());
} while (file.findUntil(",", "]"));
}