[OTA] Add hourly update routine for update check (#1538)

Update check will be done at start and hourly
This commit is contained in:
Florian authored and GitHub committed 2023-03-16 07:59:39 -05:00
1 parent 3b134fce87
commit 17ce2debce
3 files changed
+15 -4

No files matched your search

+11 -4
View File
@@ -45,6 +45,10 @@ ReceivedSignal receivedSignal[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
//Time used to wait for an interval before checking system measures
unsigned long timer_sys_measures = 0;
// Time used to wait before system checkings
unsigned long timer_sys_checks = 0;
# define ARDUINOJSON_USE_LONG_LONG 1
# define ARDUINOJSON_ENABLE_STD_STRING 1
#endif
@@ -1544,10 +1548,6 @@ void loop() {
connected = true;
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
if (now > (timer_sys_measures + (TimeBetweenReadingSYS * 1000)) || !timer_sys_measures) {
# if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
if (!timer_sys_measures) // Only check for updates at start for ESP32
checkForUpdates();
# endif
timer_sys_measures = millis();
stateMeasures();
# ifdef ZgatewayBT
@@ -1560,6 +1560,12 @@ void loop() {
stateSSD1306Display();
# endif
}
if (now > (timer_sys_checks + (TimeBetweenCheckingSYS * 1000)) || !timer_sys_checks) {
# if defined(ESP32) && defined(MQTT_HTTPS_FW_UPDATE)
checkForUpdates();
# endif
timer_sys_checks = millis();
}
#endif
#ifdef ZsensorBME280
MeasureTempHumAndPressure(); //Addon to measure Temperature, Humidity, Pressure and Altitude with a Bosch BME280/BMP280
@@ -1998,6 +2004,7 @@ String latestVersion;
* Only available for ESP32
*/
bool checkForUpdates() {
Log.notice(F("Update check"));
HTTPClient http;
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
http.begin(OTA_JSON_URL, OTAserver_cert);