From af0f782f07f45b379d9f3e2da5f9a6086c3031b9 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Sat, 21 Sep 2024 11:28:46 +0300 Subject: [PATCH] fix Discovery, DugTrace --- include/DebugTrace.h | 3 + include/EspFileSystem.h | 1 + include/Global.h | 2 +- include/classes/IoTItem.h | 9 +- lib/TickerScheduler/TickerScheduler.cpp | 4 +- myProfile.json | 14 ++- platformio.ini | 111 ++++++------------ src/DebugTrace.cpp | 1 + src/EspFileSystem.cpp | 14 +-- src/Main.cpp | 3 + src/classes/IoTDiscovery.cpp | 1 - src/classes/IoTItem.cpp | 4 +- .../exec/EctoControlAdapter/modinfo.json | 4 +- .../virtual/DiscoveryHA/DiscoveryHA.cpp | 2 +- src/modules/virtual/DiscoveryHA/modinfo.json | 2 +- .../virtual/DiscoveryHomeD/DiscoveryHomeD.cpp | 4 +- .../virtual/DiscoveryHomeD/modinfo.json | 2 +- 17 files changed, 80 insertions(+), 101 deletions(-) diff --git a/include/DebugTrace.h b/include/DebugTrace.h index a3532060..aff80087 100644 --- a/include/DebugTrace.h +++ b/include/DebugTrace.h @@ -19,6 +19,9 @@ typedef struct { } re_restart_debug_t; #endif // RESTART_DEBUG_INFO + +__NOINIT_ATTR static int8_t bootloop_panic_count; + extern "C" void __real_esp_panic_handler(void*); void printDebugTrace(); void sendDebugTraceAndFreeMemory(bool); diff --git a/include/EspFileSystem.h b/include/EspFileSystem.h index 1d468a88..332b1c25 100644 --- a/include/EspFileSystem.h +++ b/include/EspFileSystem.h @@ -51,6 +51,7 @@ extern void globalVarsSync(); // extern String getParamsJson(); extern void syncSettingsFlashJson(); +void resetSettingsFlashByPanic(); extern void syncValuesFlashJson(); extern const String getChipId(); diff --git a/include/Global.h b/include/Global.h index 5823e68f..9d5f36a5 100644 --- a/include/Global.h +++ b/include/Global.h @@ -60,7 +60,7 @@ #include "utils/StringUtils.h" #include "PeriodicTasks.h" #include "classes/IoTGpio.h" - +#include "classes/IoTDiscovery.h" /********************************************************************************************************************* *****************************************глобальные объекты классов*************************************************** **********************************************************************************************************************/ diff --git a/include/classes/IoTItem.h b/include/classes/IoTItem.h index 23b63644..43c802d9 100644 --- a/include/classes/IoTItem.h +++ b/include/classes/IoTItem.h @@ -3,6 +3,7 @@ //#include "classes/IoTBench.h" class IoTBench; +class IoTDiscovery; struct IoTValue { float valD = 0; @@ -57,10 +58,10 @@ class IoTItem { //virtual IoTItem* getCAMDriver(); virtual IoTItem* getTlgrmDriver(); //virtual IoTBench* getBenchmark(); - virtual IoTBench*getBenchmarkTask(); - virtual IoTBench*getBenchmarkLoad(); - virtual IoTBench*getHADiscovery(); - virtual IoTBench*getHOMEdDiscovery(); + virtual IoTBench* getBenchmarkTask(); + virtual IoTBench* getBenchmarkLoad(); + virtual IoTDiscovery* getHADiscovery(); + virtual IoTDiscovery* getHOMEdDiscovery(); virtual unsigned long getRtcUnixTime(); // делаем доступным модулям отправку сообщений в телеграм diff --git a/lib/TickerScheduler/TickerScheduler.cpp b/lib/TickerScheduler/TickerScheduler.cpp index 0f19e78c..6821422a 100644 --- a/lib/TickerScheduler/TickerScheduler.cpp +++ b/lib/TickerScheduler/TickerScheduler.cpp @@ -105,9 +105,9 @@ void TickerScheduler::update() { if (this->items[i].is_used) { - //#ifdef ARDUINO_ARCH_AVR + #if defined ARDUINO_ARCH_AVR || defined LIBRETINY this->items[i].t.Tick(); - //#endif + #endif handleTicker(this->items[i].cb, this->items[i].cb_arg, &this->items[i].flag); } diff --git a/myProfile.json b/myProfile.json index 503f4aaa..fcd49a01 100644 --- a/myProfile.json +++ b/myProfile.json @@ -137,13 +137,21 @@ "path": "src/modules/virtual/Cron", "active": false }, + { + "path": "src/modules/virtual/DiscoveryHA", + "active": true + }, + { + "path": "src/modules/virtual/DiscoveryHomeD", + "active": true + }, { "path": "src/modules/virtual/GoogleSheet", "active": false }, { "path": "src/modules/virtual/Loging", - "active": false + "active": true }, { "path": "src/modules/virtual/LogingDaily", @@ -167,7 +175,7 @@ }, { "path": "src/modules/virtual/Variable", - "active": false + "active": true }, { "path": "src/modules/virtual/VButton", @@ -447,7 +455,7 @@ }, { "path": "src/modules/exec/SIM800", - "active": true + "active": false }, { "path": "src/modules/exec/SmartBoiler", diff --git a/platformio.ini b/platformio.ini index ff87dc80..e697c59f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,18 +9,20 @@ lib_deps_external = [env] extra_scripts = pre:tools/prebuildscript.py + +[common] build_flags = - ; библиотека OpenTherm EctoControl Adapter - -I./src/modules/exec/EctoControlAdapter/lib -L./src/modules/exec/EctoControlAdapter/lib - -lEctoControlAdapterLib + -lrsEctoControl + -I./src/modules/exec/EctoControlAdapter/lib [env:esp8266_1mb_ota] lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_1mb_ota_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_1mb_ota="esp8266_1mb_ota" +build_flags = ${common.build_flags} + -Desp8266_1mb_ota="esp8266_1mb_ota" framework = arduino board = nodemcuv2 board_build.ldscript = eagle.flash.1m64.ld @@ -41,7 +43,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_1mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_1mb="esp8266_1mb" +build_flags = ${common.build_flags} + -Desp8266_1mb="esp8266_1mb" framework = arduino board = nodemcuv2 board_build.ldscript = eagle.flash.1m256.ld @@ -62,7 +65,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8285_1mb_ota_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_1mb_ota="esp8266_1mb_ota" +build_flags = ${common.build_flags} + -Desp8266_1mb_ota="esp8266_1mb_ota" framework = arduino board = esp8285 board_build.ldscript = eagle.flash.1m64.ld @@ -83,7 +87,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_2mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_2mb="esp8266_2mb" +build_flags = ${common.build_flags} + -Desp8266_2mb="esp8266_2mb" framework = arduino board = d1_wroom_02 board_build.ldscript = eagle.flash.2m1m.ld @@ -104,7 +109,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_2mb_ota_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_2mb_ota="esp8266_2mb_ota" +build_flags = ${common.build_flags} + -Desp8266_2mb_ota="esp8266_2mb_ota" framework = arduino board = d1_wroom_02 board_build.ldscript = eagle.flash.2m256.ld @@ -125,7 +131,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8285_1mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_1mb="esp8266_1mb" +build_flags = ${common.build_flags} + -Desp8266_1mb="esp8266_1mb" framework = arduino board = esp8285 board_build.ldscript = eagle.flash.1m256.ld @@ -146,7 +153,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_4mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_4mb="esp8266_4mb" +build_flags = ${common.build_flags} + -Desp8266_4mb="esp8266_4mb" framework = arduino board = nodemcuv2 board_build.ldscript = eagle.flash.4m1m.ld @@ -168,7 +176,8 @@ lib_deps = ${common_env_data.lib_deps_external} ${env:esp8266_16mb_fromitems.lib_deps} ESPAsyncUDP -build_flags = -Desp8266_16mb="esp8266_16mb" +build_flags = ${common.build_flags} + -Desp8266_16mb="esp8266_16mb" framework = arduino board = nodemcuv2 platform = espressif8266 @4.0.1 @@ -189,7 +198,8 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_4mb_fromitems.lib_deps} -build_flags = -Desp32_4mb="esp32_4mb" +build_flags = ${common.build_flags} + -Desp32_4mb="esp32_4mb" -Wl,--wrap=esp_panic_handler framework = arduino board = esp32dev @@ -211,7 +221,8 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_4mb3f_fromitems.lib_deps} -build_flags = -Desp32_4mb="esp32_4mb" +build_flags = ${common.build_flags} + -Desp32_4mb="esp32_4mb" -Wl,--wrap=esp_panic_handler framework = arduino board = esp32dev @@ -234,7 +245,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32cam_4mb_fromitems.lib_deps} -build_flags = +build_flags = ${common.build_flags} -Desp32cam_4mb="esp32cam_4mb" -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue @@ -259,7 +270,8 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32s2_4mb_fromitems.lib_deps} -build_flags = -Desp32s2_4mb="esp32s2_4mb" +build_flags = ${common.build_flags} + -Desp32s2_4mb="esp32s2_4mb" -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=0 -Wl,--wrap=esp_panic_handler @@ -283,7 +295,8 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32c3m_4mb_fromitems.lib_deps} -build_flags = -Desp32c3m_4mb="esp32c3m_4mb" +build_flags = ${common.build_flags} + -Desp32c3m_4mb="esp32c3m_4mb" -Wl,--wrap=esp_panic_handler framework = arduino board = lolin_c3_mini @@ -306,7 +319,7 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32s3_16mb_fromitems.lib_deps} -build_flags = +build_flags = ${common.build_flags} -Desp32s3_16mb="esp32s3_16mb" -Wl,--wrap=esp_panic_handler framework = arduino @@ -332,7 +345,8 @@ extra_scripts = pre:tools/patch32_ws.py lib_deps = ${common_env_data.lib_deps_external} ${env:esp32_16mb_fromitems.lib_deps} -build_flags = -Desp32_16mb="esp32_16mb" +build_flags = ${common.build_flags} + -Desp32_16mb="esp32_16mb" -Wl,--wrap=esp_panic_handler framework = arduino board = esp32dev @@ -371,7 +385,6 @@ monitor_speed = 115200 build_flags = -DLT_LOGLEVEL=LT_LEVEL_DEBUG -DLT_DEBUG_ALL=1 - #-DLFS_THREADSAFE=1 -DPROJECT_DATA_DIR="data_svelte" -DLT_USE_TIME=1 -DDEBUG_ESP_PORT=Serial1 @@ -385,10 +398,6 @@ build_src_filter = + ${env:tiny_fromitems.build_src_filter} -[task_flash_fs] -description = Flash File System -cmd = echo "Flash FS Tiny board" && patch\ltchiptool.exe flash --start 0x1DB000 --skip 0x00000 --length 0x25000 -f lt_littlefs.bin -p %UPLOAD_PORT% && echo "Complete!" - [env:esp8266_1mb_ota_fromitems] lib_deps = adafruit/Adafruit BME280 Library @@ -713,62 +722,16 @@ build_src_filter = [env:esp32_4mb3f_fromitems] lib_deps = - https://github.com/enjoyneering/AHTxx.git - adafruit/Adafruit BME280 Library - adafruit/Adafruit BMP280 Library - beegee-tokyo/DHT sensor library for ESPx - https://github.com/milesburton/Arduino-Temperature-Control-Library - https://github.com/tremaru/iarduino_RTC - robtillaart/SHT2x@^0.1.1 - WEMOS SHT3x@1.0.0 - plerup/EspSoftwareSerial - gyverlibs/EncButton @ ^2.0 - https://github.com/RoboticsBrno/ServoESP32#v1.0.3 - adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 - adafruit/Adafruit BusIO @ ^1.13.2 - dfrobot/DFRobotDFPlayerMini @ ^1.0.5 - adafruit/Adafruit BusIO @ ^1.13.2 - https://github.com/robotclass/RobotClass_LiquidCrystal_I2C - marcoschwartz/LiquidCrystal_I2C@^1.1.4 - https://github.com/maxint-rd/TM16xx - adafruit/Adafruit GFX Library @ ^1.11.5 + gyverlibs/FastBot build_src_filter = - + + + + + + - + + + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + [env:esp32cam_4mb_fromitems] lib_deps = diff --git a/src/DebugTrace.cpp b/src/DebugTrace.cpp index 14b011a4..0f4112db 100644 --- a/src/DebugTrace.cpp +++ b/src/DebugTrace.cpp @@ -9,6 +9,7 @@ __NOINIT_ATTR static re_restart_debug_t _debug_info; #include "esp_err.h" #include "soc/soc_memory_layout.h" #include "soc/cpu.h" +#include "esp_ota_ops.h" // RU: Размер буфера для конвертации даты и времeни в строку #define CONFIG_FORMAT_STRFTIME_BUFFER_SIZE 32 diff --git a/src/EspFileSystem.cpp b/src/EspFileSystem.cpp index 2c73801d..753f5cff 100644 --- a/src/EspFileSystem.cpp +++ b/src/EspFileSystem.cpp @@ -49,13 +49,13 @@ void resetSettingsFlashByPanic() writeFile(F("/scenario_bak.txt"), update.scenarioTxt); writeFile(F("/layout_bak.json"), update.layoutJson); */ - update.configJson = "[]"; - update.scenarioTxt = ""; - update.layoutJson = "[]"; - writeFile(F("/config.json"), update.configJson); - writeFile(F("/scenario.txt"), update.scenarioTxt); - writeFile(F("/layout.json"), update.layoutJson); - ESP.reset(); + //update.configJson = "[]"; + //update.scenarioTxt = ""; + //update.layoutJson = "[]"; + writeFile(F("/config.json"), "[]"); + writeFile(F("/scenario.txt"), ""); + writeFile(F("/layout.json"), "[]"); + ESP.restart(); } void syncValuesFlashJson() diff --git a/src/Main.cpp b/src/Main.cpp index 441d76d3..4984cde1 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -158,7 +158,10 @@ void setup() { bootloop_panic_count = -1; } if (bootloop_panic_count == -1) + { SerialPrint("E", "CORE", F("CONFIG and SCENARIO reset !!!")); + bootloop_panic_count = 0; + } // настраиваем микроконтроллер configure("/config.json"); diff --git a/src/classes/IoTDiscovery.cpp b/src/classes/IoTDiscovery.cpp index 734bb560..9eb202c6 100644 --- a/src/classes/IoTDiscovery.cpp +++ b/src/classes/IoTDiscovery.cpp @@ -1,6 +1,5 @@ #include "Global.h" #include "classes/IoTDiscovery.h" -#include "IoTDiscovery.h" IoTDiscovery::IoTDiscovery(const String ¶meters) : IoTItem(parameters) { diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index b6cb26d5..60cadc34 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -258,11 +258,11 @@ IoTBench *IoTItem::getBenchmarkLoad() { return nullptr; } -IoTBench *IoTItem::getHOMEdDiscovery() +IoTDiscovery *IoTItem::getHOMEdDiscovery() { return nullptr; } -IoTBench *IoTItem::getHADiscovery() +IoTDiscovery *IoTItem::getHADiscovery() { return nullptr; } diff --git a/src/modules/exec/EctoControlAdapter/modinfo.json b/src/modules/exec/EctoControlAdapter/modinfo.json index dbd8c178..c52358aa 100644 --- a/src/modules/exec/EctoControlAdapter/modinfo.json +++ b/src/modules/exec/EctoControlAdapter/modinfo.json @@ -1,5 +1,5 @@ { - "menuSection": "sensors", + "menuSection": "executive_devices", "configItem": [ { "global": 0, @@ -37,7 +37,7 @@ "title": "EctoControlAdapter", "moduleDesc": "Управление отопительным котлом через адаптер EctoControl по протоколам OpenTherm, eBUS, Navien. Посредством Modbus RTU. Разъем 4P4C: 1-Желтый(красный)+12V; 2-Белый-GND; 3-Зелёный-A; 4-Коричневый(Синий)-B", "propInfo": { - "addr": "Адрес slav", + "addr": "Адрес slave", "int": "Количество секунд между опросами датчика.", "RX": "Пин RX", "TX": "Пин TX", diff --git a/src/modules/virtual/DiscoveryHA/DiscoveryHA.cpp b/src/modules/virtual/DiscoveryHA/DiscoveryHA.cpp index ff3b571c..86f8e069 100644 --- a/src/modules/virtual/DiscoveryHA/DiscoveryHA.cpp +++ b/src/modules/virtual/DiscoveryHA/DiscoveryHA.cpp @@ -219,7 +219,7 @@ public: } } - IoTDiscovery *getBenchmarkTask() + IoTDiscovery *getHADiscovery() { if (HA) return this; diff --git a/src/modules/virtual/DiscoveryHA/modinfo.json b/src/modules/virtual/DiscoveryHA/modinfo.json index cf71635f..e06f37f9 100644 --- a/src/modules/virtual/DiscoveryHA/modinfo.json +++ b/src/modules/virtual/DiscoveryHA/modinfo.json @@ -1,5 +1,5 @@ { - "menuSection": "virtual", + "menuSection": "virtual_elments", "configItem": [ { "global": 0, diff --git a/src/modules/virtual/DiscoveryHomeD/DiscoveryHomeD.cpp b/src/modules/virtual/DiscoveryHomeD/DiscoveryHomeD.cpp index 07088ba6..a7c1703a 100644 --- a/src/modules/virtual/DiscoveryHomeD/DiscoveryHomeD.cpp +++ b/src/modules/virtual/DiscoveryHomeD/DiscoveryHomeD.cpp @@ -31,7 +31,7 @@ public: if (!HOMEd) return; - if (msg.indexOf("HELLO") == -1) + if (payloadStr.indexOf("HELLO") == -1) { /* String dev = selectToMarkerLast(topic, "/"); dev.toUpperCase(); @@ -254,7 +254,7 @@ public: } } } - IoTBench *getBenchmarkTask() + IoTDiscovery *getHOMEdDiscovery() { if (HOMEd) return this; diff --git a/src/modules/virtual/DiscoveryHomeD/modinfo.json b/src/modules/virtual/DiscoveryHomeD/modinfo.json index 049d3507..1f66c25a 100644 --- a/src/modules/virtual/DiscoveryHomeD/modinfo.json +++ b/src/modules/virtual/DiscoveryHomeD/modinfo.json @@ -1,5 +1,5 @@ { - "menuSection": "virtual", + "menuSection": "virtual_elments", "configItem": [ { "global": 0,