mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 17:52:08 +02:00
Merge branch 'hotfix/configuration-default-after-ota-success-and-new-firmware-has-change-configuration-param' into feature/press-button-for-offline-mode
This commit is contained in:
@ -41,6 +41,7 @@ JSON_PROP_DEF(ledbarBrightness);
|
|||||||
JSON_PROP_DEF(displayBrightness);
|
JSON_PROP_DEF(displayBrightness);
|
||||||
JSON_PROP_DEF(co2CalibrationRequested);
|
JSON_PROP_DEF(co2CalibrationRequested);
|
||||||
JSON_PROP_DEF(ledBarTestRequested);
|
JSON_PROP_DEF(ledBarTestRequested);
|
||||||
|
JSON_PROP_DEF(lastOta);
|
||||||
JSON_PROP_DEF(offlineMode);
|
JSON_PROP_DEF(offlineMode);
|
||||||
JSONVar jconfig;
|
JSONVar jconfig;
|
||||||
|
|
||||||
@ -1101,6 +1102,17 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
jconfig[jprop_offlineMode] = false;
|
jconfig[jprop_offlineMode] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Last OTA */
|
||||||
|
if(JSON.typeof_(jconfig[jprop_lastOta]) != "number") {
|
||||||
|
isInvalid = true;
|
||||||
|
} else {
|
||||||
|
isInvalid = false;
|
||||||
|
}
|
||||||
|
if(isInvalid) {
|
||||||
|
jconfig[jprop_lastOta] = 0;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
@ -1196,13 +1208,15 @@ int Configuration::getLastOta(void) {
|
|||||||
logError("Current year " + String(curYear) + String(" invalid"));
|
logError("Current year " + String(curYear) + String(" invalid"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
double _t = jconfig[jprop_lastOta];
|
||||||
|
time_t lastOta = (time_t)_t;
|
||||||
time_t curTime = mktime(&timeInfo);
|
time_t curTime = mktime(&timeInfo);
|
||||||
logInfo("Last ota time: " + String(config.lastOta));
|
logInfo("Last ota time: " + String(lastOta));
|
||||||
if (config.lastOta == 0) {
|
if (lastOta == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sec = curTime - config.lastOta;
|
int sec = curTime - lastOta;
|
||||||
logInfo("Last ota secconds: " + String(sec));
|
logInfo("Last ota secconds: " + String(sec));
|
||||||
return sec;
|
return sec;
|
||||||
}
|
}
|
||||||
@ -1218,8 +1232,10 @@ void Configuration::updateLastOta(void) {
|
|||||||
logError("updateLastOta: lolcal time invalid");
|
logError("updateLastOta: lolcal time invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
config.lastOta = mktime(&timeInfo);
|
|
||||||
logInfo("Last OTA: " + String(config.lastOta));
|
time_t lastOta = mktime(&timeInfo);
|
||||||
|
jconfig[jprop_lastOta] = (unsigned long)lastOta;
|
||||||
|
logInfo("Last OTA: " + String(lastOta));
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user