From a423b81b07e7a6c7ddb008b3c54d8179771b7581 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <67171972+IoTManagerProject@users.noreply.github.com> Date: Tue, 8 Feb 2022 00:20:49 +0100 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=20=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D1=82=D1=8C=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DeviceList.cpp | 15 ++++++++------- src/EspFileSystem.cpp | 3 ++- src/StandWebServer.cpp | 4 ++++ src/WsServer.cpp | 1 + src/classes/IoTItem.cpp | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/DeviceList.cpp b/src/DeviceList.cpp index 5fac2f68..7f932c96 100644 --- a/src/DeviceList.cpp +++ b/src/DeviceList.cpp @@ -1,17 +1,18 @@ #include "DeviceList.h" void addThisDeviceToList() { - jsonWriteStr_(devListJson, "devicelist", "devicelist"); + jsonWriteStr_(devListJson, "devicelist", ""); //метка для парсинга jsonWriteStr_(devListJson, "ip", jsonReadStr(settingsFlashJson, "ip")); jsonWriteStr_(devListJson, "id", jsonReadStr(settingsFlashJson, "id")); jsonWriteStr_(devListJson, "name", jsonReadStr(settingsFlashJson, "name")); - devListJson = devListJson + ","; - String test; - jsonWriteStr_(test, "ip", "192.168.88.88"); - jsonWriteStr_(test, "id", "123456789"); - jsonWriteStr_(test, "name", "test"); - devListJson = devListJson + test; + // для проверки + // devListJson = devListJson + ","; + // String test; + // jsonWriteStr_(test, "ip", "192.168.88.88"); + // jsonWriteStr_(test, "id", "123456789"); + // jsonWriteStr_(test, "name", "test"); + // devListJson = devListJson + test; devListJson = "[" + devListJson + "]"; Serial.println(devListJson); diff --git a/src/EspFileSystem.cpp b/src/EspFileSystem.cpp index a9fcee09..7284e456 100644 --- a/src/EspFileSystem.cpp +++ b/src/EspFileSystem.cpp @@ -18,7 +18,8 @@ void globalVarsSync() { jsonWriteStr_(settingsFlashJson, "root", mqttRootDevice); jsonWriteStr_(settingsFlashJson, "id", chipId); saveSettingsFlashJson(); - jsonWriteStr_(ssidListJson, "ssid", ""); + jsonWriteStr_(ssidListJson, "ssid", ""); //метка для парсинга + jsonWriteStr(paramsHeapJson, "params", ""); //метка для парсинга } void saveSettingsFlashJson() { diff --git a/src/StandWebServer.cpp b/src/StandWebServer.cpp index 7dd065eb..52eb9a8f 100644 --- a/src/StandWebServer.cpp +++ b/src/StandWebServer.cpp @@ -13,6 +13,10 @@ void standWebServerInit() { HTTP.send(200, "application/json", settingsFlashJson); }); + HTTP.on("/paramsh.json", HTTP_GET, []() { + HTTP.send(200, "application/json", paramsHeapJson); + }); + HTTP.on("/config.json", HTTP_GET, []() { HTTP.send(200, "application/json", readFile(F("config.json"), 20000)); }); diff --git a/src/WsServer.cpp b/src/WsServer.cpp index 318fcacc..32f2ace1 100644 --- a/src/WsServer.cpp +++ b/src/WsServer.cpp @@ -32,6 +32,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) // dashboard=================================================================== if (headerStr == "/") { sendFileToWs("/layout.json", num, 1024); + standWebSocket.sendTXT(num, paramsHeapJson); } if (headerStr == "/tuoyal") { writeFileUint8tByFrames("layout.json", payload, length, headerLenth, 256); diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index 5ac9fd72..ff964a8c 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -43,7 +43,7 @@ void IoTItem::loop() { void IoTItem::regEvent(String value, String consoleInfo = "") { eventGen2(_id, value); - jsonWriteStr(paramsFlashJson, _id, value); + jsonWriteStr(paramsHeapJson, _id, value); publishStatusMqtt(_id, value); publishStatusWs(_id, value); SerialPrint("I", "Sensor " + consoleInfo, "'" + _id + "' data: " + value + "'");