добавил ответ конфигом на запрос

This commit is contained in:
Dmitry Borisenko
2021-12-13 02:36:55 +01:00
parent b8a8290928
commit 715d20c21f
3 changed files with 25 additions and 3 deletions

View File

@@ -7,3 +7,6 @@ extern void initMDNS();
extern void HttpServerinitWS(); extern void HttpServerinitWS();
extern void HttpServerinit(); extern void HttpServerinit();
//===========web sockets==============================
extern void sendEspSetupToWS();

View File

@@ -112,8 +112,10 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
} }
Serial.printf("%s\n", msg.c_str()); Serial.printf("%s\n", msg.c_str());
if (msg.startsWith("HELLO")) { if (msg.startsWith("config")) {
SerialPrint("I", F("WS"), F("Full update")); SerialPrint("I", F("WS"), F("config send"));
sendEspSetupToWS();
// publishWidgetsWS(); // publishWidgetsWS();
// publishStateWS(); // publishStateWS();
// choose_log_date_and_send(); // функцию выгрузки архива с графиком я не сделал. Забираю при выгрузке по MQTT // choose_log_date_and_send(); // функцию выгрузки архива с графиком я не сделал. Забираю при выгрузке по MQTT
@@ -209,3 +211,18 @@ void HttpServerinitWS() {
server.addHandler(&events); server.addHandler(&events);
#endif #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(",", "]"));
}

View File

@@ -98,7 +98,9 @@ void setup() {
}, },
nullptr, true); nullptr, true);
setupESP(); // setupESP();
sendEspSetupToWS();
SerialPrint("I", F("System"), F("✔ Initialization completed")); SerialPrint("I", F("System"), F("✔ Initialization completed"));
} }