set ntp parameters via config file

This commit is contained in:
Emanuele Trabattoni
2025-08-03 12:11:00 +02:00
parent a1a66ebf8e
commit 4a1e944ea2
6 changed files with 39 additions and 20 deletions

View File

@@ -108,7 +108,6 @@ namespace commands
response["cmd"] = "getCronJob";
auto &cron = Cron::getInstance(dev);
auto eventName = params["name"].as<std::string>();
response["values"]["name"] = eventName;
if (eventName.empty())
{
@@ -132,6 +131,7 @@ namespace commands
}
Cron::CronEvent event;
response["values"]["name"] = eventName;
if (!cron.getEvent(eventName, event))
{
LOG_ERROR("getCronJob failed to get job [", eventName.c_str(), "]");

View File

@@ -35,13 +35,16 @@ void loop()
auto i2c = drivers::I2C();
auto bus = drivers::MODBUS(9600, SERIAL_8N1);
auto rtc = drivers::PCF85063(i2c);
auto eth = drivers::Ethernet(conf.m_ethHostname);
auto eth = drivers::Ethernet(conf.m_ethHostname, conf.m_ntpPool, conf.m_ntpTimezone, conf.m_ntpUpdateInterval);
auto tmp = drivers::R4DCB08(bus, conf.m_modbusTemperatureAddr);
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});
// get RTC time drift offset value
rtc.setOffset(conf.m_ntpRtcOffsetRegister);
LOG_INFO("RTC offset register -> ", printHex(rtc.getOffset()).c_str());
// Initialize temperature sensors
sensors = tmp.getNum();
tmp.setCorrection(conf.m_tempCorrectionValues);
@@ -83,13 +86,13 @@ void loop()
MQTTwrapper::MessageCallback onMessage = [&devices](const MQTTwrapper::Topic &topic, const MQTTwrapper::Message &message)
{
LOG_INFO("onMessage callback [", topic.c_str(), "]");
LOG_DEBUG("onMessage callback [", topic.c_str(), "]");
devices.led.setColor(devices.led.COLOR_MAGENTA);
};
MQTTwrapper::MessageCallback onPublish = [&devices](const MQTTwrapper::Topic &topic, const MQTTwrapper::Message &message)
{
LOG_INFO("onPublish callback [", topic.c_str(), "]");
LOG_DEBUG("onPublish callback [", topic.c_str(), "]");
devices.led.setColor(devices.led.COLOR_SKYBLUE);
};
@@ -126,6 +129,8 @@ void loop()
uint8_t mqttRetries(0);
while (timeRetries++ < conf.m_ntpRetries)
{
eth.setNtpTimeOffset(conf.m_ntpTimezone);
LOG_INFO("NTP Timezone UTC", conf.m_ntpTimezone >= 0 ? "+" : "", conf.m_ntpTimezone);
if (eth.getNtpTime(ntpTime))
{ // skip NTP update for drift testing
buzzer.beep(250, NOTE_A);