Добавил массив виджетов и реализовал их отправку

This commit is contained in:
Dmitry Borisenko
2022-01-17 00:06:50 +01:00
parent ee322ce185
commit 775d7a11ad
39 changed files with 6648 additions and 209 deletions

View File

@@ -38,7 +38,8 @@ void setup() {
mqttInit();
//создаем объект класса выгружающего json массив из файла
mySendJson = new SendJson;
sendConfigJson = new SendJson;
sendWigdetsJson = new SendJson;
configure("/config.json");
@@ -61,7 +62,8 @@ void loop() {
ts.update();
//отправка json
if (mySendJson) mySendJson->loop();
if (sendConfigJson) sendConfigJson->loop();
if (sendWigdetsJson) sendWigdetsJson->loop();
#ifdef STANDARD_WEB_SERVER
//обработка web сервера

View File

@@ -212,8 +212,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
payloadStr += (char)payload[i];
}
if (payloadStr.startsWith("/config")) { //если прилетел url страницы /config то отправим пакеты с меткой /config.json
if (mySendJson) mySendJson->sendFile("/config.json", num);
if (payloadStr.startsWith("/config")) {
//если прилетел url страницы /config то отправим widgets.json и config.json
if (sendWigdetsJson) sendWigdetsJson->sendFile("/widgets.json", num);
if (sendConfigJson) sendConfigJson->sendFile("/config.json", num);
}
if (payloadStr.startsWith("/gifnoc.json")) { //если прилетел измененный пакет с меткой /gifnoc (config наоборот) то перепишем файл, пока переписываем целеком

View File

@@ -24,4 +24,5 @@ void SendJson::sendMqtt(String& jsonArrayElement) {
// mqtt send to do
}
SendJson* mySendJson;
SendJson* sendConfigJson;
SendJson* sendWigdetsJson;