ota update first version, with led management

This commit is contained in:
Emanuele Trabattoni
2025-08-05 11:56:13 +02:00
parent 80fda62344
commit 5bff567863
7 changed files with 212 additions and 7 deletions

View File

@@ -8,9 +8,11 @@
#include <commands.h>
#include <cronjobs.h>
#include <mqtt.h>
#include <ota.h>
#include <devices.h>
#include "utils.h"
#include <utils.h>
#include <pinlist.h>
/////////////// GLOBALS ///////////////
Config &conf = Config::getInstance();
@@ -40,8 +42,10 @@ void loop()
auto seneca = drivers::S50140(bus, conf.m_modbusSenecaAddr);
auto buzzer = drivers::Buzzer();
auto led = drivers::Led();
delay(500);
auto io = digitalIO(i2c, bus, {conf.m_modbusRelayAddr});
// Create device structure to pass all devices in the callbacks as needed
devices_t devices(eth, rtc, tmp, seneca, buzzer, led, io);
//
// get RTC time drift offset value
rtc.setOffset(conf.m_ntpRtcOffsetRegister);
LOG_INFO("RTC offset register -> ", printHex(rtc.getOffset()).c_str());
@@ -49,9 +53,16 @@ void loop()
sensors = tmp.getNum();
tmp.setCorrection(conf.m_tempCorrectionValues);
LOG_INFO("Temperature sensors connected ->", sensors);
// Create device structure to pass all devices in the callbacks as needed
devices_t devices(eth, rtc, tmp, seneca, buzzer, led, io);
// Initialize OTA updater if needed
auto ota = OTA(devices);
if (io.digitalInRead(DI_OTAENABLE)) {
buzzer.beepRepeat(25,25, NOTE_A);
delay(1000);
if (io.digitalInRead(DI_OTAENABLE)) { // maintain keyPress for 1s
ota.begin();
}
buzzer.beep(100, NOTE_G);
}
//////////////// DEVICES ////////////////
//////////////// MQTT ////////////////
@@ -187,7 +198,7 @@ void loop()
mqtt.publish(conf.m_mqttPublish["temperatures"], ti);
};
if (io.digitalInRead(0)) // ROSSO - Config Reset
if (io.digitalInRead(DI_CONFRESET)) // ROSSO - Config Reset
{
LOG_WARN("Config RESET!");
buzzer.beep(450, NOTE_E);
@@ -195,7 +206,7 @@ void loop()
conf.resetConfig();
}
if (io.digitalInRead(1)) // GIALLO - Restart
if (io.digitalInRead(DI_RESTART)) // GIALLO - Restart
{
LOG_WARN("RESTART!");
buzzer.beep(450, NOTE_D);