Feature: Re-Request DevInfo if it contains invalid data

It can sometimes occour that the DevInfo request returns invalid data. Currently this is identified if the firmware build year is < 2016. In this case the package will be re-requested now.
This commit is contained in:
Thomas Basler 2023-08-25 11:04:14 +02:00
parent 08ca221410
commit b88030f76e
3 changed files with 27 additions and 3 deletions

View File

@ -91,10 +91,22 @@ void HoymilesClass::loop()
}
// Fetch dev info (but first fetch stats)
if (iv->Statistics()->getLastUpdate() > 0 && (iv->DevInfo()->getLastUpdateAll() == 0 || iv->DevInfo()->getLastUpdateSimple() == 0)) {
if (iv->Statistics()->getLastUpdate() > 0) {
bool invalidDevInfo = !iv->DevInfo()->containsValidData()
&& iv->DevInfo()->getLastUpdateAll() > 0
&& iv->DevInfo()->getLastUpdateSimple() > 0;
if (invalidDevInfo) {
_messageOutput->println("DevInfo: No Valid Data");
}
if ((iv->DevInfo()->getLastUpdateAll() == 0)
|| (iv->DevInfo()->getLastUpdateSimple() == 0)
|| invalidDevInfo) {
_messageOutput->println("Request device info");
iv->sendDevInfoRequest();
}
}
if (++inverterPos >= getNumInverters()) {
inverterPos = 0;

View File

@ -196,6 +196,16 @@ String DevInfoParser::getHwModelName()
return devInfo[idx].modelName;
}
bool DevInfoParser::containsValidData()
{
time_t t = getFwBuildDateTime();
struct tm info;
localtime_r(&t, &info);
return info.tm_year > (2016 - 1900);
}
uint8_t DevInfoParser::getDevIdx()
{
uint8_t ret = 0xff;

View File

@ -33,6 +33,8 @@ public:
uint16_t getMaxPower();
String getHwModelName();
bool containsValidData();
private:
time_t timegm(struct tm* tm);
uint8_t getDevIdx();