Replace EVERY_N_SECONDS with millis
EVERY_N_SECONDS is not updated without a reboot of the controller
This commit is contained in:
parent
a4212f8aed
commit
c9e603b2de
@ -14,6 +14,7 @@ private:
|
||||
void publishField(String subtopic, std::shared_ptr<InverterAbstract> inv, uint8_t channel, uint8_t fieldId);
|
||||
|
||||
uint32_t _lastPublishStats[INV_MAX_COUNT];
|
||||
uint32_t _lastPublish;
|
||||
};
|
||||
|
||||
extern MqttPublishingClass MqttPublishing;
|
||||
@ -19,8 +19,7 @@ void HoymilesClass::loop()
|
||||
_radio->loop();
|
||||
|
||||
if (getNumInverters() > 0) {
|
||||
EVERY_N_SECONDS(_pollInterval)
|
||||
{
|
||||
if (millis() - _lastPoll > (_pollInterval * 1000)) {
|
||||
static uint8_t inverterPos = 0;
|
||||
|
||||
std::shared_ptr<InverterAbstract> iv = getInverterByPos(inverterPos);
|
||||
@ -42,6 +41,8 @@ void HoymilesClass::loop()
|
||||
if (++inverterPos >= getNumInverters()) {
|
||||
inverterPos = 0;
|
||||
}
|
||||
|
||||
_lastPoll = millis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ private:
|
||||
std::unique_ptr<HoymilesRadio> _radio;
|
||||
|
||||
uint32_t _pollInterval;
|
||||
uint32_t _lastPoll = 0;
|
||||
};
|
||||
|
||||
extern HoymilesClass Hoymiles;
|
||||
@ -16,8 +16,7 @@ void MqttPublishingClass::loop()
|
||||
|
||||
CONFIG_T& config = Configuration.get();
|
||||
|
||||
EVERY_N_SECONDS(config.Dtu_PollInterval)
|
||||
{
|
||||
if (millis() - _lastPublish > (config.Dtu_PollInterval * 1000)) {
|
||||
MqttSettings.publish("dtu/uptime", String(millis() / 1000));
|
||||
MqttSettings.publish("dtu/ip", WiFi.localIP().toString());
|
||||
|
||||
@ -58,6 +57,8 @@ void MqttPublishingClass::loop()
|
||||
|
||||
yield();
|
||||
}
|
||||
|
||||
_lastPublish = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user