начал писать обновление параметров

This commit is contained in:
Dmitry Borisenko
2022-02-08 00:20:49 +01:00
parent 9b5a87bbcf
commit a423b81b07
5 changed files with 16 additions and 9 deletions

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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));
});

View File

@@ -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);

View File

@@ -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 + "'");