устранение багов

This commit is contained in:
Dmitry Borisenko
2022-10-12 03:14:55 +02:00
parent 2c7adf468b
commit 6912d5f68d
16 changed files with 126 additions and 184 deletions

View File

@@ -276,58 +276,7 @@
"num": 20 "num": 20
}, },
{ {
"name": "21. Частотомер на ADC, Частота", "name": "21. GY21 Температура",
"type": "Reading",
"subtype": "FreqMeterF",
"id": "freq",
"widget": "anydataHtz",
"page": "Частотомер",
"descr": "Частота",
"plus": 0,
"multiply": 1,
"round": 1,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 21
},
{
"name": "22. Частотомер на ADC, Процент Пульсации",
"type": "Reading",
"subtype": "FreqMeterPcFl",
"id": "pctFlicker",
"widget": "anydataPct",
"page": "Частотомер",
"descr": "Процент Пульсации",
"plus": 0,
"multiply": 1,
"round": 1,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 22
},
{
"name": "23. Частотомер на ADC, Индекс Пульсации",
"type": "Reading",
"subtype": "FreqMeterFlIn",
"id": "flickerIndex",
"widget": "anydataDef",
"page": "Частотомер",
"descr": "Индекс Пульсации",
"plus": 0,
"multiply": 1,
"round": 10,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 23
},
{
"name": "24. GY21 Температура",
"type": "Reading", "type": "Reading",
"subtype": "GY21t", "subtype": "GY21t",
"id": "tmp4", "id": "tmp4",
@@ -336,10 +285,10 @@
"descr": "Температура", "descr": "Температура",
"round": 1, "round": 1,
"int": 15, "int": 15,
"num": 24 "num": 21
}, },
{ {
"name": "25. GY21 Влажность", "name": "22. GY21 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "GY21h", "subtype": "GY21h",
"id": "Hum4", "id": "Hum4",
@@ -348,10 +297,10 @@
"descr": "Влажность", "descr": "Влажность",
"round": 1, "round": 1,
"int": 15, "int": 15,
"num": 25 "num": 22
}, },
{ {
"name": "26. HDC1080 Температура", "name": "23. HDC1080 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Hdc1080t", "subtype": "Hdc1080t",
"id": "Temp1080", "id": "Temp1080",
@@ -361,10 +310,10 @@
"int": 15, "int": 15,
"addr": "0x40", "addr": "0x40",
"round": 1, "round": 1,
"num": 26 "num": 23
}, },
{ {
"name": "27. HDC1080 Влажность", "name": "24. HDC1080 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "Hdc1080h", "subtype": "Hdc1080h",
"id": "Hum1080", "id": "Hum1080",
@@ -374,10 +323,10 @@
"int": 15, "int": 15,
"addr": "0x40", "addr": "0x40",
"round": 1, "round": 1,
"num": 27 "num": 24
}, },
{ {
"name": "28. MAX6675 Температура", "name": "25. MAX6675 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Max6675t", "subtype": "Max6675t",
"id": "maxtmp", "id": "maxtmp",
@@ -388,10 +337,10 @@
"DO": 12, "DO": 12,
"CS": 13, "CS": 13,
"CLK": 14, "CLK": 14,
"num": 28 "num": 25
}, },
{ {
"name": "29. PZEM 004t Напряжение", "name": "26. PZEM 004t Напряжение",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004v", "subtype": "Pzem004v",
"id": "v", "id": "v",
@@ -401,10 +350,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 29 "num": 26
}, },
{ {
"name": "30. PZEM 004t Сила тока", "name": "27. PZEM 004t Сила тока",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004a", "subtype": "Pzem004a",
"id": "a", "id": "a",
@@ -414,10 +363,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 30 "num": 27
}, },
{ {
"name": "31. PZEM 004t Мощность", "name": "28. PZEM 004t Мощность",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004w", "subtype": "Pzem004w",
"id": "w", "id": "w",
@@ -427,10 +376,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 31 "num": 28
}, },
{ {
"name": "32. PZEM 004t Энергия", "name": "29. PZEM 004t Энергия",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004wh", "subtype": "Pzem004wh",
"id": "wh", "id": "wh",
@@ -440,10 +389,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 32 "num": 29
}, },
{ {
"name": "33. PZEM 004t Частота", "name": "30. PZEM 004t Частота",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004hz", "subtype": "Pzem004hz",
"id": "hz", "id": "hz",
@@ -453,10 +402,10 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 33 "num": 30
}, },
{ {
"name": "34. PZEM 004t Косинус", "name": "31. PZEM 004t Косинус",
"type": "Reading", "type": "Reading",
"subtype": "Pzem004pf", "subtype": "Pzem004pf",
"id": "pf", "id": "pf",
@@ -466,11 +415,11 @@
"int": 15, "int": 15,
"addr": "0xF8", "addr": "0xF8",
"round": 1, "round": 1,
"num": 34 "num": 31
}, },
{ {
"name": "35. Сканер кнопок 433 MHz", "name": "32. Сканер кнопок 433 MHz",
"num": 35, "num": 32,
"type": "Reading", "type": "Reading",
"subtype": "RCswitch", "subtype": "RCswitch",
"id": "rsw", "id": "rsw",
@@ -479,7 +428,7 @@
"pinTx": 12 "pinTx": 12
}, },
{ {
"name": "36. Sht20 Температура", "name": "33. Sht20 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Sht20t", "subtype": "Sht20t",
"id": "tmp2", "id": "tmp2",
@@ -488,10 +437,10 @@
"descr": "Температура", "descr": "Температура",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 36 "num": 33
}, },
{ {
"name": "37. Sht20 Влажность", "name": "34. Sht20 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "Sht20h", "subtype": "Sht20h",
"id": "Hum2", "id": "Hum2",
@@ -500,10 +449,10 @@
"descr": "Влажность", "descr": "Влажность",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 37 "num": 34
}, },
{ {
"name": "38. Sht30 Температура", "name": "35. Sht30 Температура",
"type": "Reading", "type": "Reading",
"subtype": "Sht30t", "subtype": "Sht30t",
"id": "tmp30", "id": "tmp30",
@@ -512,10 +461,10 @@
"descr": "SHT30 Температура", "descr": "SHT30 Температура",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 38 "num": 35
}, },
{ {
"name": "39. Sht30 Влажность", "name": "36. Sht30 Влажность",
"type": "Reading", "type": "Reading",
"subtype": "Sht30h", "subtype": "Sht30h",
"id": "Hum30", "id": "Hum30",
@@ -524,11 +473,11 @@
"descr": "SHT30 Влажность", "descr": "SHT30 Влажность",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 39 "num": 36
}, },
{ {
"name": "40. HC-SR04 Ультразвуковой дальномер", "name": "37. HC-SR04 Ультразвуковой дальномер",
"num": 40, "num": 37,
"type": "Reading", "type": "Reading",
"subtype": "Sonar", "subtype": "Sonar",
"id": "sonar", "id": "sonar",
@@ -540,7 +489,7 @@
"int": 5 "int": 5
}, },
{ {
"name": "41. UART", "name": "38. UART",
"type": "Reading", "type": "Reading",
"subtype": "UART", "subtype": "UART",
"page": "", "page": "",
@@ -550,13 +499,13 @@
"tx": 12, "tx": 12,
"rx": 13, "rx": 13,
"speed": 9600, "speed": 9600,
"num": 41 "num": 38
}, },
{ {
"header": "Исполнительные устройства" "header": "Исполнительные устройства"
}, },
{ {
"name": "42. Кнопка подключенная к пину", "name": "39. Кнопка подключенная к пину",
"type": "Writing", "type": "Writing",
"subtype": "ButtonIn", "subtype": "ButtonIn",
"id": "btn", "id": "btn",
@@ -569,10 +518,10 @@
"pinMode": "INPUT", "pinMode": "INPUT",
"debounceDelay": 50, "debounceDelay": 50,
"fixState": 0, "fixState": 0,
"num": 42 "num": 39
}, },
{ {
"name": "43. Управление пином", "name": "40. Управление пином",
"type": "Writing", "type": "Writing",
"subtype": "ButtonOut", "subtype": "ButtonOut",
"id": "btn", "id": "btn",
@@ -582,10 +531,10 @@
"int": 0, "int": 0,
"inv": 0, "inv": 0,
"pin": 2, "pin": 2,
"num": 43 "num": 40
}, },
{ {
"name": "44. Сервопривод", "name": "41. Сервопривод",
"type": "Writing", "type": "Writing",
"subtype": "IoTServo", "subtype": "IoTServo",
"id": "servo", "id": "servo",
@@ -596,10 +545,10 @@
"pin": 12, "pin": 12,
"apin": -1, "apin": -1,
"amap": "0, 4096, 0, 180", "amap": "0, 4096, 0, 180",
"num": 44 "num": 41
}, },
{ {
"name": "45. Расширитель портов Mcp23017", "name": "42. Расширитель портов Mcp23017",
"type": "Reading", "type": "Reading",
"subtype": "Mcp23017", "subtype": "Mcp23017",
"id": "Mcp", "id": "Mcp",
@@ -609,10 +558,10 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 45 "num": 42
}, },
{ {
"name": "46. MP3 плеер", "name": "43. MP3 плеер",
"type": "Reading", "type": "Reading",
"subtype": "Mp3", "subtype": "Mp3",
"id": "mp3", "id": "mp3",
@@ -622,10 +571,10 @@
"int": 1, "int": 1,
"pins": "14,12", "pins": "14,12",
"volume": 20, "volume": 20,
"num": 46 "num": 43
}, },
{ {
"name": "47. Расширитель портов Pcf8574", "name": "44. Расширитель портов Pcf8574",
"type": "Reading", "type": "Reading",
"subtype": "Pcf8574", "subtype": "Pcf8574",
"id": "Pcf", "id": "Pcf",
@@ -635,10 +584,10 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 47 "num": 44
}, },
{ {
"name": "48. PWM ESP32", "name": "45. PWM ESP32",
"type": "Writing", "type": "Writing",
"subtype": "Pwm32", "subtype": "Pwm32",
"id": "pwm", "id": "pwm",
@@ -652,10 +601,10 @@
"PWM_resolution": 10, "PWM_resolution": 10,
"val": 0, "val": 0,
"apin": -1, "apin": -1,
"num": 48 "num": 45
}, },
{ {
"name": "49. Телеграм-Лайт", "name": "46. Телеграм-Лайт",
"type": "Writing", "type": "Writing",
"subtype": "TelegramLT", "subtype": "TelegramLT",
"id": "tg", "id": "tg",
@@ -664,13 +613,13 @@
"descr": "", "descr": "",
"token": "", "token": "",
"chatID": "", "chatID": "",
"num": 49 "num": 46
}, },
{ {
"header": "Экраны" "header": "Экраны"
}, },
{ {
"name": "50. LCD экран 2004", "name": "47. LCD экран 2004",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -682,10 +631,10 @@
"size": "20,4", "size": "20,4",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 50 "num": 47
}, },
{ {
"name": "51. LCD экран 1602", "name": "48. LCD экран 1602",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -697,6 +646,6 @@
"size": "16,2", "size": "16,2",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 51 "num": 48
} }
] ]

View File

@@ -19,5 +19,6 @@
"pinSCL": 0, "pinSCL": 0,
"pinSDA": 0, "pinSDA": 0,
"i2cFreq": 100000, "i2cFreq": 100000,
"wg": "group1",
"settings_": "" "settings_": ""
} }

View File

@@ -15,6 +15,8 @@
#define JSON_BUFFER_SIZE 2048 #define JSON_BUFFER_SIZE 2048
#define WEB_SOCKETS_FRAME_SIZE 2048 #define WEB_SOCKETS_FRAME_SIZE 2048
//#define LOOP_DEBUG
//выбор сервера //выбор сервера
//#define ASYNC_WEB_SERVER //#define ASYNC_WEB_SERVER
//#define ASYNC_WEB_SOCKETS //#define ASYNC_WEB_SOCKETS

View File

@@ -137,6 +137,8 @@ extern Time_t _time_local;
extern Time_t _time_utc; extern Time_t _time_utc;
extern bool _time_isTrust; extern bool _time_isTrust;
extern unsigned long loopPeriod;
// extern DynamicJsonDocument settingsFlashJsonDoc; // extern DynamicJsonDocument settingsFlashJsonDoc;
// extern DynamicJsonDocument paramsFlashJsonDoc; // extern DynamicJsonDocument paramsFlashJsonDoc;
// extern DynamicJsonDocument paramsHeapJsonDoc; // extern DynamicJsonDocument paramsHeapJsonDoc;

View File

@@ -10,8 +10,5 @@
extern void periodicTasksInit(); extern void periodicTasksInit();
extern void printGlobalVarSize(); extern void printGlobalVarSize();
extern void handleError(String errorId, String errorValue);
extern void handleError(String errorId, int errorValue);
extern String ESP_getResetReason(void); extern String ESP_getResetReason(void);
extern String ESP32GetResetReason(uint32_t cpu_no); extern String ESP32GetResetReason(uint32_t cpu_no);

View File

@@ -20,7 +20,8 @@
"mqttin": 0, "mqttin": 0,
"pinSCL": 0, "pinSCL": 0,
"pinSDA": 0, "pinSDA": 0,
"i2cFreq": 100000 "i2cFreq": 100000,
"wg": "group1"
}, },
"projectProp": { "projectProp": {
"platformio": { "platformio": {
@@ -90,7 +91,7 @@
}, },
{ {
"path": "src/modules/sensors/FreqMeter", "path": "src/modules/sensors/FreqMeter",
"active": true "active": false
}, },
{ {
"path": "src/modules/sensors/GY21", "path": "src/modules/sensors/GY21",

View File

@@ -57,7 +57,6 @@ lib_deps =
adafruit/Adafruit BMP280 Library adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx beegee-tokyo/DHT sensor library for ESPx
milesburton/DallasTemperature@^3.9.1 milesburton/DallasTemperature@^3.9.1
kosme/arduinoFFT@^1.5.6
https://github.com/JonasGMorsch/GY-21.git https://github.com/JonasGMorsch/GY-21.git
ClosedCube HDC1080 ClosedCube HDC1080
adafruit/MAX6675 library adafruit/MAX6675 library
@@ -83,7 +82,6 @@ build_src_filter =
+<modules/sensors/Bmp280> +<modules/sensors/Bmp280>
+<modules/sensors/Dht1122> +<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20> +<modules/sensors/Ds18b20>
+<modules/sensors/FreqMeter>
+<modules/sensors/GY21> +<modules/sensors/GY21>
+<modules/sensors/Hdc1080> +<modules/sensors/Hdc1080>
+<modules/sensors/Max6675> +<modules/sensors/Max6675>
@@ -110,7 +108,6 @@ lib_deps =
adafruit/Adafruit BMP280 Library adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx beegee-tokyo/DHT sensor library for ESPx
milesburton/DallasTemperature@^3.9.1 milesburton/DallasTemperature@^3.9.1
kosme/arduinoFFT@^1.5.6
https://github.com/JonasGMorsch/GY-21.git https://github.com/JonasGMorsch/GY-21.git
ClosedCube HDC1080 ClosedCube HDC1080
adafruit/MAX6675 library adafruit/MAX6675 library
@@ -137,7 +134,6 @@ build_src_filter =
+<modules/sensors/Bmp280> +<modules/sensors/Bmp280>
+<modules/sensors/Dht1122> +<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20> +<modules/sensors/Ds18b20>
+<modules/sensors/FreqMeter>
+<modules/sensors/GY21> +<modules/sensors/GY21>
+<modules/sensors/Hdc1080> +<modules/sensors/Hdc1080>
+<modules/sensors/Max6675> +<modules/sensors/Max6675>

View File

@@ -2,7 +2,8 @@
const String getThisDevice() { const String getThisDevice() {
String thisDevice = "{}"; String thisDevice = "{}";
jsonWriteStr_(thisDevice, F("devicelist_"), ""); //метка для парсинга нужна для udp валидации может быть рабочей группой в последствии jsonWriteStr_(thisDevice, F("devicelist_"), ""); //метка для парсинга
jsonWriteStr_(thisDevice, F("wg"), jsonReadStr(settingsFlashJson, F("wg"))); //рабочая группа
jsonWriteStr_(thisDevice, F("ip"), jsonReadStr(settingsFlashJson, F("ip"))); jsonWriteStr_(thisDevice, F("ip"), jsonReadStr(settingsFlashJson, F("ip")));
jsonWriteStr_(thisDevice, F("id"), jsonReadStr(settingsFlashJson, F("id"))); jsonWriteStr_(thisDevice, F("id"), jsonReadStr(settingsFlashJson, F("id")));
jsonWriteStr_(thisDevice, F("name"), jsonReadStr(settingsFlashJson, F("name"))); jsonWriteStr_(thisDevice, F("name"), jsonReadStr(settingsFlashJson, F("name")));
@@ -52,7 +53,7 @@ void asyncUdpInit() {
}); });
} }
//будем отправлять каждые 30 секунд презентацию данного устройства //будем отправлять каждые 60 секунд презентацию данного устройства
ts.add( ts.add(
UDP, 60000, [&](void*) { // UDPP UDP, 60000, [&](void*) { // UDPP
if (isNetworkActive()) { if (isNetworkActive()) {
@@ -68,7 +69,9 @@ void asyncUdpInit() {
} }
bool udpPacketValidation(String& data) { bool udpPacketValidation(String& data) {
if (data.indexOf("devicelist_") != -1) { // SerialPrint("i", F("UDP"), data);
String workgroup = jsonReadStr(settingsFlashJson, "wg");
if (workgroup != "" && data.indexOf(workgroup) != -1) {
return true; return true;
} else { } else {
return false; return false;

View File

@@ -68,6 +68,8 @@ String mqttRootDevice = "";
unsigned long unixTime = 0; unsigned long unixTime = 0;
unsigned long unixTimeShort = 0; unsigned long unixTimeShort = 0;
unsigned long loopPeriod;
bool isTimeSynch = false; bool isTimeSynch = false;
Time_t _time_local; Time_t _time_local;
Time_t _time_utc; Time_t _time_utc;

View File

@@ -116,38 +116,22 @@ void setup() {
} }
void loop() { void loop() {
// if(millis()%2000==0){ #ifdef LOOP_DEBUG
// //watch->settimeUnix(time(&iotTimeNow)); unsigned long st = millis();
// Serial.println(watch->gettime("d-m-Y, H:i:s, M"));
// delay(1);
// }
//обновление задач таскера
ts.update();
//отправка json
#ifdef QUEUE_FROM_STR
if (sendJsonFiles) sendJsonFiles->loop();
#endif #endif
ts.update();
#ifdef STANDARD_WEB_SERVER #ifdef STANDARD_WEB_SERVER
//обработка web сервера 1
HTTP.handleClient(); HTTP.handleClient();
#endif #endif
#ifdef STANDARD_WEB_SOCKETS #ifdef STANDARD_WEB_SOCKETS
//обработка web сокетов
standWebSocket.loop(); standWebSocket.loop();
#endif #endif
//обновление mqtt
mqttLoop(); mqttLoop();
#ifdef STANDARD_WEB_SERVER
//обработка web сервера 2
// HTTP.handleClient();
#endif
// передаем управление каждому элементу конфигурации для выполнения своих функций // передаем управление каждому элементу конфигурации для выполнения своих функций
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
(*it)->loop(); (*it)->loop();
@@ -159,13 +143,24 @@ void loop() {
} }
handleOrder(); handleOrder();
handleEvent(); handleEvent();
#ifdef STANDARD_WEB_SERVER #ifdef LOOP_DEBUG
//обработка web сервера 3 loopPeriod = millis() - st;
// HTTP.handleClient(); if (loopPeriod > 2) Serial.println(loopPeriod);
#endif #endif
}
//отправка json
//#ifdef QUEUE_FROM_STR
// if (sendJsonFiles) sendJsonFiles->loop();
//#endif
// if(millis()%2000==0){
// //watch->settimeUnix(time(&iotTimeNow));
// Serial.println(watch->gettime("d-m-Y, H:i:s, M"));
// delay(1);
// }
// сохраняем значения IoTItems в файл каждую секунду, если были изменения (установлены маркеры на сохранение) // сохраняем значения IoTItems в файл каждую секунду, если были изменения (установлены маркеры на сохранение)
// currentMillis = millis(); // currentMillis = millis();
@@ -184,7 +179,6 @@ void loop() {
// Serial.println(volStrForSave.c_str()); // Serial.println(volStrForSave.c_str());
// } // }
//} //}
}
// File dir = FileFS.open("/", "r"); // File dir = FileFS.open("/", "r");
// String out; // String out;

View File

@@ -278,7 +278,7 @@ void publishWidgets() {
DeserializationError error = deserializeJson(doc, file); DeserializationError error = deserializeJson(doc, file);
if (error) { if (error) {
SerialPrint("E", F("MQTT"), error.f_str()); SerialPrint("E", F("MQTT"), error.f_str());
handleError("jse3", 1); jsonWriteInt(errorsHeapJson, F("jse3"), 1); //Ошибка чтения json файла с виджетами при отправки в mqtt
} }
JsonArray arr = doc.as<JsonArray>(); JsonArray arr = doc.as<JsonArray>();
for (JsonVariant value : arr) { for (JsonVariant value : arr) {

View File

@@ -13,9 +13,11 @@ void ntpInit() {
if (unixTime < MIN_DATETIME) { if (unixTime < MIN_DATETIME) {
isTimeSynch = false; isTimeSynch = false;
// SerialPrint("E", "NTP", "Time not synched"); // SerialPrint("E", "NTP", "Time not synched");
jsonWriteInt(errorsHeapJson, F("tme1"), 1);
synchTime(); synchTime();
return; return;
} }
jsonWriteInt(errorsHeapJson, F("tme1"), 0);
breakEpochToTime(unixTime + jsonReadInt(settingsFlashJson, F("timezone")) * 60 * 60, _time_local); breakEpochToTime(unixTime + jsonReadInt(settingsFlashJson, F("timezone")) * 60 * 60, _time_local);
breakEpochToTime(unixTime, _time_utc); breakEpochToTime(unixTime, _time_utc);
isTimeSynch = true; isTimeSynch = true;

View File

@@ -31,14 +31,6 @@ void periodicTasksInit() {
SerialPrint("i", "Task", "Periodic tasks init"); SerialPrint("i", "Task", "Periodic tasks init");
} }
void handleError(String errorId, String errorValue) {
jsonWriteStr_(errorsHeapJson, errorId, errorValue);
}
void handleError(String errorId, int errorValue) {
jsonWriteInt_(errorsHeapJson, errorId, errorValue);
}
void printGlobalVarSize() { void printGlobalVarSize() {
size_t settingsFlashJsonSize = settingsFlashJson.length(); size_t settingsFlashJsonSize = settingsFlashJson.length();
// SerialPrint(F("i"), F("settingsFlashJson"), String(settingsFlashJsonSize)); // SerialPrint(F("i"), F("settingsFlashJson"), String(settingsFlashJsonSize));

View File

@@ -176,10 +176,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
// Страница веб интерфейса dev // Страница веб интерфейса dev
//----------------------------------------------------------------------// //----------------------------------------------------------------------//
if (headerStr == "/dev|") { if (headerStr == "/dev|") {
// standWebSocket.sendTXT(num, errorsHeapJson); sendStringToWs("errors", errorsHeapJson, num);
// standWebSocket.sendTXT(num, settingsFlashJson); sendStringToWs("settin", settingsFlashJson, num);
// sendFileToWs("/config.json", num, 1024); sendFileToWsByFrames("/config.json", "config", "", num, WEB_SOCKETS_FRAME_SIZE);
// sendFileToWs("/items.json", num, 1024); sendFileToWsByFrames("/items.json", "itemsj", "", num, WEB_SOCKETS_FRAME_SIZE);
// sendFileToWsByFrames("/layout.json", "layout", "", num, WEB_SOCKETS_FRAME_SIZE);
}
if (headerStr == "/test|") {
} }
//----------------------------------------------------------------------// //----------------------------------------------------------------------//
@@ -216,8 +220,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
SerialPrint("i", F("=>WS"), "Msg from svelte web, WS No: " + String(num) + ", msg: " + msg); SerialPrint("i", F("=>WS"), "Msg from svelte web, WS No: " + String(num) + ", msg: " + msg);
} }
if (headerStr == "/test|") {
}
} break; } break;
case WStype_BIN: { case WStype_BIN: {
@@ -306,7 +308,7 @@ void sendFileToWsByFrames(const String& filename, const String& header, const St
} }
size_t totalSize = file.size(); size_t totalSize = file.size();
Serial.println("Send file '" + String(filename) + "', file size: " + String(totalSize)); // Serial.println("Send file '" + String(filename) + "', file size: " + String(totalSize));
char buf[32]; char buf[32];
sprintf(buf, "%04d", json.length() + 12); sprintf(buf, "%04d", json.length() + 12);
@@ -346,7 +348,7 @@ void sendFileToWsByFrames(const String& filename, const String& header, const St
continuation = true; continuation = true;
} }
Serial.println(String(i) + ") " + "ws: " + String(client_id) + " fr sz: " + String(size) + " fin: " + String(fin) + " cnt: " + String(continuation)); // Serial.println(String(i) + ") " + "ws: " + String(client_id) + " fr sz: " + String(size) + " fin: " + String(fin) + " cnt: " + String(continuation));
if (client_id == -1) { if (client_id == -1) {
standWebSocket.broadcastBIN(frameBuf, size, fin, continuation); standWebSocket.broadcastBIN(frameBuf, size, fin, continuation);

View File

@@ -12,7 +12,6 @@ void* getAPI_Bme280(String subtype, String params);
void* getAPI_Bmp280(String subtype, String params); void* getAPI_Bmp280(String subtype, String params);
void* getAPI_Dht1122(String subtype, String params); void* getAPI_Dht1122(String subtype, String params);
void* getAPI_Ds18b20(String subtype, String params); void* getAPI_Ds18b20(String subtype, String params);
void* getAPI_FreqMeter(String subtype, String params);
void* getAPI_GY21(String subtype, String params); void* getAPI_GY21(String subtype, String params);
void* getAPI_Hdc1080(String subtype, String params); void* getAPI_Hdc1080(String subtype, String params);
void* getAPI_Max6675(String subtype, String params); void* getAPI_Max6675(String subtype, String params);
@@ -46,7 +45,6 @@ if ((tmpAPI = getAPI_Bme280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_FreqMeter(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_GY21(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_GY21(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI;

View File

@@ -318,8 +318,9 @@ String jsonWriteFloat(String& json, String name, float value, bool e) {
} }
void jsonErrorDetected() { void jsonErrorDetected() {
jsonWriteInt(errorsHeapJson, F("jse2"), 1); // пример как отправить ошибку с количеством
int number = jsonReadInt(errorsHeapJson, F("jse2n")); // jsonWriteInt(errorsHeapJson, F("jse2"), 1);
number++; // int number = jsonReadInt(errorsHeapJson, F("jse2n"));
jsonWriteInt(errorsHeapJson, F("jse2n"), number); // number++;
// jsonWriteInt(errorsHeapJson, F("jse2n"), number);
} }