Fix issue that in multi inverter environments some inverters where not fetched

When the radio was busy, the current inverter was just skipped and switched to the next one
This commit is contained in:
Thomas Basler 2022-11-15 22:30:29 +01:00
parent e5cbeb8990
commit 2b2afee770

View File

@ -28,8 +28,9 @@ void HoymilesClass::loop()
if (millis() - _lastPoll > (_pollInterval * 1000)) { if (millis() - _lastPoll > (_pollInterval * 1000)) {
static uint8_t inverterPos = 0; static uint8_t inverterPos = 0;
if (_radio->isIdle()) {
std::shared_ptr<InverterAbstract> iv = getInverterByPos(inverterPos); std::shared_ptr<InverterAbstract> iv = getInverterByPos(inverterPos);
if (iv != nullptr && _radio->isIdle()) { if (iv != nullptr) {
Serial.print(F("Fetch inverter: ")); Serial.print(F("Fetch inverter: "));
Serial.println(iv->serial(), HEX); Serial.println(iv->serial(), HEX);
@ -68,6 +69,7 @@ void HoymilesClass::loop()
if (++inverterPos >= getNumInverters()) { if (++inverterPos >= getNumInverters()) {
inverterPos = 0; inverterPos = 0;
} }
}
_lastPoll = millis(); _lastPoll = millis();
} }