fix Discovery, DugTrace

This commit is contained in:
Mit4el
2024-09-21 11:28:46 +03:00
parent b9c07b809f
commit af0f782f07
17 changed files with 80 additions and 101 deletions

View File

@@ -19,6 +19,9 @@ typedef struct {
} re_restart_debug_t; } re_restart_debug_t;
#endif // RESTART_DEBUG_INFO #endif // RESTART_DEBUG_INFO
__NOINIT_ATTR static int8_t bootloop_panic_count;
extern "C" void __real_esp_panic_handler(void*); extern "C" void __real_esp_panic_handler(void*);
void printDebugTrace(); void printDebugTrace();
void sendDebugTraceAndFreeMemory(bool); void sendDebugTraceAndFreeMemory(bool);

View File

@@ -51,6 +51,7 @@ extern void globalVarsSync();
// extern String getParamsJson(); // extern String getParamsJson();
extern void syncSettingsFlashJson(); extern void syncSettingsFlashJson();
void resetSettingsFlashByPanic();
extern void syncValuesFlashJson(); extern void syncValuesFlashJson();
extern const String getChipId(); extern const String getChipId();

View File

@@ -60,7 +60,7 @@
#include "utils/StringUtils.h" #include "utils/StringUtils.h"
#include "PeriodicTasks.h" #include "PeriodicTasks.h"
#include "classes/IoTGpio.h" #include "classes/IoTGpio.h"
#include "classes/IoTDiscovery.h"
/********************************************************************************************************************* /*********************************************************************************************************************
*****************************************глобальные объекты классов*************************************************** *****************************************глобальные объекты классов***************************************************
**********************************************************************************************************************/ **********************************************************************************************************************/

View File

@@ -3,6 +3,7 @@
//#include "classes/IoTBench.h" //#include "classes/IoTBench.h"
class IoTBench; class IoTBench;
class IoTDiscovery;
struct IoTValue { struct IoTValue {
float valD = 0; float valD = 0;
@@ -57,10 +58,10 @@ class IoTItem {
//virtual IoTItem* getCAMDriver(); //virtual IoTItem* getCAMDriver();
virtual IoTItem* getTlgrmDriver(); virtual IoTItem* getTlgrmDriver();
//virtual IoTBench* getBenchmark(); //virtual IoTBench* getBenchmark();
virtual IoTBench*getBenchmarkTask(); virtual IoTBench* getBenchmarkTask();
virtual IoTBench*getBenchmarkLoad(); virtual IoTBench* getBenchmarkLoad();
virtual IoTBench*getHADiscovery(); virtual IoTDiscovery* getHADiscovery();
virtual IoTBench*getHOMEdDiscovery(); virtual IoTDiscovery* getHOMEdDiscovery();
virtual unsigned long getRtcUnixTime(); virtual unsigned long getRtcUnixTime();
// делаем доступным модулям отправку сообщений в телеграм // делаем доступным модулям отправку сообщений в телеграм

View File

@@ -105,9 +105,9 @@ void TickerScheduler::update()
{ {
if (this->items[i].is_used) if (this->items[i].is_used)
{ {
//#ifdef ARDUINO_ARCH_AVR #if defined ARDUINO_ARCH_AVR || defined LIBRETINY
this->items[i].t.Tick(); this->items[i].t.Tick();
//#endif #endif
handleTicker(this->items[i].cb, this->items[i].cb_arg, &this->items[i].flag); handleTicker(this->items[i].cb, this->items[i].cb_arg, &this->items[i].flag);
} }

View File

@@ -137,13 +137,21 @@
"path": "src/modules/virtual/Cron", "path": "src/modules/virtual/Cron",
"active": false "active": false
}, },
{
"path": "src/modules/virtual/DiscoveryHA",
"active": true
},
{
"path": "src/modules/virtual/DiscoveryHomeD",
"active": true
},
{ {
"path": "src/modules/virtual/GoogleSheet", "path": "src/modules/virtual/GoogleSheet",
"active": false "active": false
}, },
{ {
"path": "src/modules/virtual/Loging", "path": "src/modules/virtual/Loging",
"active": false "active": true
}, },
{ {
"path": "src/modules/virtual/LogingDaily", "path": "src/modules/virtual/LogingDaily",
@@ -167,7 +175,7 @@
}, },
{ {
"path": "src/modules/virtual/Variable", "path": "src/modules/virtual/Variable",
"active": false "active": true
}, },
{ {
"path": "src/modules/virtual/VButton", "path": "src/modules/virtual/VButton",
@@ -447,7 +455,7 @@
}, },
{ {
"path": "src/modules/exec/SIM800", "path": "src/modules/exec/SIM800",
"active": true "active": false
}, },
{ {
"path": "src/modules/exec/SmartBoiler", "path": "src/modules/exec/SmartBoiler",

View File

@@ -9,18 +9,20 @@ lib_deps_external =
[env] [env]
extra_scripts = pre:tools/prebuildscript.py extra_scripts = pre:tools/prebuildscript.py
[common]
build_flags = build_flags =
; библиотека OpenTherm EctoControl Adapter
-I./src/modules/exec/EctoControlAdapter/lib
-L./src/modules/exec/EctoControlAdapter/lib -L./src/modules/exec/EctoControlAdapter/lib
-lEctoControlAdapterLib -lrsEctoControl
-I./src/modules/exec/EctoControlAdapter/lib
[env:esp8266_1mb_ota] [env:esp8266_1mb_ota]
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8266_1mb_ota_fromitems.lib_deps} ${env:esp8266_1mb_ota_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_1mb_ota="esp8266_1mb_ota" build_flags = ${common.build_flags}
-Desp8266_1mb_ota="esp8266_1mb_ota"
framework = arduino framework = arduino
board = nodemcuv2 board = nodemcuv2
board_build.ldscript = eagle.flash.1m64.ld board_build.ldscript = eagle.flash.1m64.ld
@@ -41,7 +43,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8266_1mb_fromitems.lib_deps} ${env:esp8266_1mb_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_1mb="esp8266_1mb" build_flags = ${common.build_flags}
-Desp8266_1mb="esp8266_1mb"
framework = arduino framework = arduino
board = nodemcuv2 board = nodemcuv2
board_build.ldscript = eagle.flash.1m256.ld board_build.ldscript = eagle.flash.1m256.ld
@@ -62,7 +65,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8285_1mb_ota_fromitems.lib_deps} ${env:esp8285_1mb_ota_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_1mb_ota="esp8266_1mb_ota" build_flags = ${common.build_flags}
-Desp8266_1mb_ota="esp8266_1mb_ota"
framework = arduino framework = arduino
board = esp8285 board = esp8285
board_build.ldscript = eagle.flash.1m64.ld board_build.ldscript = eagle.flash.1m64.ld
@@ -83,7 +87,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8266_2mb_fromitems.lib_deps} ${env:esp8266_2mb_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_2mb="esp8266_2mb" build_flags = ${common.build_flags}
-Desp8266_2mb="esp8266_2mb"
framework = arduino framework = arduino
board = d1_wroom_02 board = d1_wroom_02
board_build.ldscript = eagle.flash.2m1m.ld board_build.ldscript = eagle.flash.2m1m.ld
@@ -104,7 +109,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8266_2mb_ota_fromitems.lib_deps} ${env:esp8266_2mb_ota_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_2mb_ota="esp8266_2mb_ota" build_flags = ${common.build_flags}
-Desp8266_2mb_ota="esp8266_2mb_ota"
framework = arduino framework = arduino
board = d1_wroom_02 board = d1_wroom_02
board_build.ldscript = eagle.flash.2m256.ld board_build.ldscript = eagle.flash.2m256.ld
@@ -125,7 +131,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8285_1mb_fromitems.lib_deps} ${env:esp8285_1mb_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_1mb="esp8266_1mb" build_flags = ${common.build_flags}
-Desp8266_1mb="esp8266_1mb"
framework = arduino framework = arduino
board = esp8285 board = esp8285
board_build.ldscript = eagle.flash.1m256.ld board_build.ldscript = eagle.flash.1m256.ld
@@ -146,7 +153,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8266_4mb_fromitems.lib_deps} ${env:esp8266_4mb_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_4mb="esp8266_4mb" build_flags = ${common.build_flags}
-Desp8266_4mb="esp8266_4mb"
framework = arduino framework = arduino
board = nodemcuv2 board = nodemcuv2
board_build.ldscript = eagle.flash.4m1m.ld board_build.ldscript = eagle.flash.4m1m.ld
@@ -168,7 +176,8 @@ lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp8266_16mb_fromitems.lib_deps} ${env:esp8266_16mb_fromitems.lib_deps}
ESPAsyncUDP ESPAsyncUDP
build_flags = -Desp8266_16mb="esp8266_16mb" build_flags = ${common.build_flags}
-Desp8266_16mb="esp8266_16mb"
framework = arduino framework = arduino
board = nodemcuv2 board = nodemcuv2
platform = espressif8266 @4.0.1 platform = espressif8266 @4.0.1
@@ -189,7 +198,8 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32_4mb_fromitems.lib_deps} ${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 -Wl,--wrap=esp_panic_handler
framework = arduino framework = arduino
board = esp32dev board = esp32dev
@@ -211,7 +221,8 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32_4mb3f_fromitems.lib_deps} ${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 -Wl,--wrap=esp_panic_handler
framework = arduino framework = arduino
board = esp32dev board = esp32dev
@@ -234,7 +245,7 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32cam_4mb_fromitems.lib_deps} ${env:esp32cam_4mb_fromitems.lib_deps}
build_flags = build_flags = ${common.build_flags}
-Desp32cam_4mb="esp32cam_4mb" -Desp32cam_4mb="esp32cam_4mb"
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-issue
@@ -259,7 +270,8 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32s2_4mb_fromitems.lib_deps} ${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_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=0 -DARDUINO_USB_MODE=0
-Wl,--wrap=esp_panic_handler -Wl,--wrap=esp_panic_handler
@@ -283,7 +295,8 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32c3m_4mb_fromitems.lib_deps} ${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 -Wl,--wrap=esp_panic_handler
framework = arduino framework = arduino
board = lolin_c3_mini board = lolin_c3_mini
@@ -306,7 +319,7 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32s3_16mb_fromitems.lib_deps} ${env:esp32s3_16mb_fromitems.lib_deps}
build_flags = build_flags = ${common.build_flags}
-Desp32s3_16mb="esp32s3_16mb" -Desp32s3_16mb="esp32s3_16mb"
-Wl,--wrap=esp_panic_handler -Wl,--wrap=esp_panic_handler
framework = arduino framework = arduino
@@ -332,7 +345,8 @@ extra_scripts = pre:tools/patch32_ws.py
lib_deps = lib_deps =
${common_env_data.lib_deps_external} ${common_env_data.lib_deps_external}
${env:esp32_16mb_fromitems.lib_deps} ${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 -Wl,--wrap=esp_panic_handler
framework = arduino framework = arduino
board = esp32dev board = esp32dev
@@ -371,7 +385,6 @@ monitor_speed = 115200
build_flags = build_flags =
-DLT_LOGLEVEL=LT_LEVEL_DEBUG -DLT_LOGLEVEL=LT_LEVEL_DEBUG
-DLT_DEBUG_ALL=1 -DLT_DEBUG_ALL=1
#-DLFS_THREADSAFE=1
-DPROJECT_DATA_DIR="data_svelte" -DPROJECT_DATA_DIR="data_svelte"
-DLT_USE_TIME=1 -DLT_USE_TIME=1
-DDEBUG_ESP_PORT=Serial1 -DDEBUG_ESP_PORT=Serial1
@@ -385,10 +398,6 @@ build_src_filter =
+<modules/*.cpp> +<modules/*.cpp>
${env:tiny_fromitems.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] [env:esp8266_1mb_ota_fromitems]
lib_deps = lib_deps =
adafruit/Adafruit BME280 Library adafruit/Adafruit BME280 Library
@@ -713,62 +722,16 @@ build_src_filter =
[env:esp32_4mb3f_fromitems] [env:esp32_4mb3f_fromitems]
lib_deps = lib_deps =
https://github.com/enjoyneering/AHTxx.git gyverlibs/FastBot
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
build_src_filter = build_src_filter =
+<modules/virtual/Cron> +<modules/virtual/DiscoveryHA>
+<modules/virtual/DiscoveryHomeD>
+<modules/virtual/Loging> +<modules/virtual/Loging>
+<modules/virtual/LogingDaily>
+<modules/virtual/Timer> +<modules/virtual/Timer>
+<modules/virtual/Variable> +<modules/virtual/Variable>
+<modules/virtual/VariableColor>
+<modules/virtual/VButton> +<modules/virtual/VButton>
+<modules/sensors/Acs712> +<modules/exec/EctoControlAdapter>
+<modules/sensors/AhtXX> +<modules/exec/Telegram_v2>
+<modules/sensors/AnalogAdc>
+<modules/sensors/Bme280>
+<modules/sensors/Bmp280>
+<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20>
+<modules/sensors/Impulse>
+<modules/sensors/Pzem004t>
+<modules/sensors/RTC>
+<modules/sensors/S8>
+<modules/sensors/Sht20>
+<modules/sensors/Sht30>
+<modules/sensors/Sonar>
+<modules/sensors/UART>
+<modules/exec/ButtonIn>
+<modules/exec/ButtonOut>
+<modules/exec/Buzzer>
+<modules/exec/Enconder>
+<modules/exec/IoTServo>
+<modules/exec/Mcp23017>
+<modules/exec/Mp3>
+<modules/exec/Multitouch>
+<modules/exec/Pcf8574>
+<modules/exec/Pwm32>
+<modules/exec/TelegramLT>
+<modules/display/Lcd2004>
+<modules/display/Smi2_m>
+<modules/display/TM16XX>
[env:esp32cam_4mb_fromitems] [env:esp32cam_4mb_fromitems]
lib_deps = lib_deps =

View File

@@ -9,6 +9,7 @@ __NOINIT_ATTR static re_restart_debug_t _debug_info;
#include "esp_err.h" #include "esp_err.h"
#include "soc/soc_memory_layout.h" #include "soc/soc_memory_layout.h"
#include "soc/cpu.h" #include "soc/cpu.h"
#include "esp_ota_ops.h"
// RU: Размер буфера для конвертации даты и времeни в строку // RU: Размер буфера для конвертации даты и времeни в строку
#define CONFIG_FORMAT_STRFTIME_BUFFER_SIZE 32 #define CONFIG_FORMAT_STRFTIME_BUFFER_SIZE 32

View File

@@ -49,13 +49,13 @@ void resetSettingsFlashByPanic()
writeFile(F("/scenario_bak.txt"), update.scenarioTxt); writeFile(F("/scenario_bak.txt"), update.scenarioTxt);
writeFile(F("/layout_bak.json"), update.layoutJson); writeFile(F("/layout_bak.json"), update.layoutJson);
*/ */
update.configJson = "[]"; //update.configJson = "[]";
update.scenarioTxt = ""; //update.scenarioTxt = "";
update.layoutJson = "[]"; //update.layoutJson = "[]";
writeFile(F("/config.json"), update.configJson); writeFile(F("/config.json"), "[]");
writeFile(F("/scenario.txt"), update.scenarioTxt); writeFile(F("/scenario.txt"), "");
writeFile(F("/layout.json"), update.layoutJson); writeFile(F("/layout.json"), "[]");
ESP.reset(); ESP.restart();
} }
void syncValuesFlashJson() void syncValuesFlashJson()

View File

@@ -158,7 +158,10 @@ void setup() {
bootloop_panic_count = -1; bootloop_panic_count = -1;
} }
if (bootloop_panic_count == -1) if (bootloop_panic_count == -1)
{
SerialPrint("E", "CORE", F("CONFIG and SCENARIO reset !!!")); SerialPrint("E", "CORE", F("CONFIG and SCENARIO reset !!!"));
bootloop_panic_count = 0;
}
// настраиваем микроконтроллер // настраиваем микроконтроллер
configure("/config.json"); configure("/config.json");

View File

@@ -1,6 +1,5 @@
#include "Global.h" #include "Global.h"
#include "classes/IoTDiscovery.h" #include "classes/IoTDiscovery.h"
#include "IoTDiscovery.h"
IoTDiscovery::IoTDiscovery(const String &parameters) : IoTItem(parameters) IoTDiscovery::IoTDiscovery(const String &parameters) : IoTItem(parameters)
{ {

View File

@@ -258,11 +258,11 @@ IoTBench *IoTItem::getBenchmarkLoad()
{ {
return nullptr; return nullptr;
} }
IoTBench *IoTItem::getHOMEdDiscovery() IoTDiscovery *IoTItem::getHOMEdDiscovery()
{ {
return nullptr; return nullptr;
} }
IoTBench *IoTItem::getHADiscovery() IoTDiscovery *IoTItem::getHADiscovery()
{ {
return nullptr; return nullptr;
} }

View File

@@ -1,5 +1,5 @@
{ {
"menuSection": "sensors", "menuSection": "executive_devices",
"configItem": [ "configItem": [
{ {
"global": 0, "global": 0,
@@ -37,7 +37,7 @@
"title": "EctoControlAdapter", "title": "EctoControlAdapter",
"moduleDesc": "Управление отопительным котлом через адаптер EctoControl по протоколам OpenTherm, eBUS, Navien. Посредством Modbus RTU. Разъем 4P4C: 1-Желтый(красный)+12V; 2-Белый-GND; 3-Зелёный-A; 4-Коричневый(Синий)-B", "moduleDesc": "Управление отопительным котлом через адаптер EctoControl по протоколам OpenTherm, eBUS, Navien. Посредством Modbus RTU. Разъем 4P4C: 1-Желтый(красный)+12V; 2-Белый-GND; 3-Зелёный-A; 4-Коричневый(Синий)-B",
"propInfo": { "propInfo": {
"addr": "Адрес slav", "addr": "Адрес slave",
"int": "Количество секунд между опросами датчика.", "int": "Количество секунд между опросами датчика.",
"RX": "Пин RX", "RX": "Пин RX",
"TX": "Пин TX", "TX": "Пин TX",

View File

@@ -219,7 +219,7 @@ public:
} }
} }
IoTDiscovery *getBenchmarkTask() IoTDiscovery *getHADiscovery()
{ {
if (HA) if (HA)
return this; return this;

View File

@@ -1,5 +1,5 @@
{ {
"menuSection": "virtual", "menuSection": "virtual_elments",
"configItem": [ "configItem": [
{ {
"global": 0, "global": 0,

View File

@@ -31,7 +31,7 @@ public:
if (!HOMEd) if (!HOMEd)
return; return;
if (msg.indexOf("HELLO") == -1) if (payloadStr.indexOf("HELLO") == -1)
{ {
/* String dev = selectToMarkerLast(topic, "/"); /* String dev = selectToMarkerLast(topic, "/");
dev.toUpperCase(); dev.toUpperCase();
@@ -254,7 +254,7 @@ public:
} }
} }
} }
IoTBench *getBenchmarkTask() IoTDiscovery *getHOMEdDiscovery()
{ {
if (HOMEd) if (HOMEd)
return this; return this;

View File

@@ -1,5 +1,5 @@
{ {
"menuSection": "virtual", "menuSection": "virtual_elments",
"configItem": [ "configItem": [
{ {
"global": 0, "global": 0,