From cde86a7f992bd050b26f7b45c329093604f4902d Mon Sep 17 00:00:00 2001 From: Emanuele Trabattoni Date: Fri, 29 Aug 2025 21:30:38 +0200 Subject: [PATCH] reenabled ota and logs to TCP ocnnection port 9876 --- platformio.ini | 4 ++-- src/cronjobs.cpp | 2 +- src/main.cpp | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index ab52b02..d2c1644 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,8 +23,8 @@ build_type = release board_build.filesystem = ffat board_build.partitions = fatfs_partition.csv ; se stai usando uno custom -#upload_protocol = espota -#upload_port = 10.0.2.139 +upload_protocol = espota +upload_port = 10.0.2.139 [env:esp32-s3-waveshare8-debug] diff --git a/src/cronjobs.cpp b/src/cronjobs.cpp index 67723c2..5609477 100644 --- a/src/cronjobs.cpp +++ b/src/cronjobs.cpp @@ -237,7 +237,7 @@ const bool Cron::processEvents() LOG_INFO("Cron skipping INACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]"); break; case CronStatus::SKIP: - LOG_INFO("Cron skipping 1 time ACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]"); + LOG_INFO("Cron skipping one time ACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]"); eventParams.status = CronStatus::ACTIVE; break; default: diff --git a/src/main.cpp b/src/main.cpp index 1bbb65c..74f8ec7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,7 @@ void loop() uint16_t k(0); uint8_t sensors(0); bool buzzing(false); + NetworkClient logStream; //////////////// DEVICES //////////////// // Declared here to keep devices local to the main loop otherwise the kernel crashes // @@ -129,6 +130,7 @@ void loop() if (!eth.isConnected()) { led.setColor(led.COLOR_RED); + logStream.stop(); return; } if (io.digitalInRead(DI::OTAENABLE)) // Initialize OTA, BLUE @@ -146,6 +148,7 @@ void loop() time_t ntpTime; uint8_t timeRetries(0); uint8_t mqttRetries(0); + uint8_t logStreamRetries(0); while (timeRetries++ < conf.m_ntpRetries) { eth.setNtpTimeOffset(conf.m_ntpTimezone); @@ -173,6 +176,14 @@ void loop() } delay(250); } + while (logStreamRetries++ < conf.m_mqttRetries) + { + if (logStream.connect(conf.m_mqttHost.c_str(), 9876)) + { + LOG_ATTACH_STREAM(logStream); + break; + } + } }); ////////////////////////////////////////