change OTA update period each 2h.

This commit is contained in:
Phat Nguyen
2024-05-22 11:45:56 +07:00
parent 805546b78e
commit 7550ef7b0c

View File

@ -220,6 +220,9 @@ void setup() {
// ota not supported
#else
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
/** Update first OTA */
measurements.otaBootCount = 0;
#endif
apiClient.fetchServerConfiguration();
@ -861,7 +864,9 @@ static void configUpdateHandle() {
doOta = true;
Serial.println("First OTA");
} else {
if ((measurements.bootCount - measurements.otaBootCount) >= 30) {
/** Only check for update each 2h*/
const float otaBootCount = 120.0f / (SERVER_SYNC_INTERVAL / 60000.0f);
if ((measurements.bootCount - measurements.otaBootCount) >= (int)otaBootCount) {
doOta = true;
} else {
Serial.println(