[OTA] Add hourly update routine for update check (#1538)
Update check will be done at start and hourly
This commit is contained in:
1 parent
3b134fce87
commit
17ce2debce
3 files changed
+15
-4
No files matched your search
@@ -122,6 +122,9 @@ mosquitto_pub -t "home/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoSYS/firmware_upd
|
|||||||
"version": "v1.2.0"
|
"version": "v1.2.0"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
OpenMQTTGateway checks at start and every hour if an update is available.
|
||||||
|
|
||||||
Alternatively if you want to choose the update URL you can use the command below (ESP32 and ESP8266):
|
Alternatively if you want to choose the update URL you can use the command below (ESP32 and ESP8266):
|
||||||
|
|
||||||
Without certificate, in this case we will use the root certificate defined in User_config.h
|
Without certificate, in this case we will use the root certificate defined in User_config.h
|
||||||
|
|||||||
@@ -605,6 +605,7 @@ CRGB leds2[FASTLED_IND_NUM_LEDS];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TimeBetweenReadingSYS 120 // time between (s) system readings (like memory)
|
#define TimeBetweenReadingSYS 120 // time between (s) system readings (like memory)
|
||||||
|
#define TimeBetweenCheckingSYS 3600 // time between (s) system checkings (like updates)
|
||||||
#define TimeLedON 1 // time LED are ON
|
#define TimeLedON 1 // time LED are ON
|
||||||
#define InitialMQTTConnectionTimeout 10 // time estimated (s) before the board is connected to MQTT
|
#define InitialMQTTConnectionTimeout 10 // time estimated (s) before the board is connected to MQTT
|
||||||
#define subjectSYStoMQTT "/SYStoMQTT"
|
#define subjectSYStoMQTT "/SYStoMQTT"
|
||||||
|
|||||||
+11
-4
@@ -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__)
|
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
|
||||||
//Time used to wait for an interval before checking system measures
|
//Time used to wait for an interval before checking system measures
|
||||||
unsigned long timer_sys_measures = 0;
|
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_USE_LONG_LONG 1
|
||||||
# define ARDUINOJSON_ENABLE_STD_STRING 1
|
# define ARDUINOJSON_ENABLE_STD_STRING 1
|
||||||
#endif
|
#endif
|
||||||
@@ -1544,10 +1548,6 @@ void loop() {
|
|||||||
connected = true;
|
connected = true;
|
||||||
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
|
#if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
|
||||||
if (now > (timer_sys_measures + (TimeBetweenReadingSYS * 1000)) || !timer_sys_measures) {
|
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();
|
timer_sys_measures = millis();
|
||||||
stateMeasures();
|
stateMeasures();
|
||||||
# ifdef ZgatewayBT
|
# ifdef ZgatewayBT
|
||||||
@@ -1560,6 +1560,12 @@ void loop() {
|
|||||||
stateSSD1306Display();
|
stateSSD1306Display();
|
||||||
# endif
|
# 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
|
#endif
|
||||||
#ifdef ZsensorBME280
|
#ifdef ZsensorBME280
|
||||||
MeasureTempHumAndPressure(); //Addon to measure Temperature, Humidity, Pressure and Altitude with a Bosch BME280/BMP280
|
MeasureTempHumAndPressure(); //Addon to measure Temperature, Humidity, Pressure and Altitude with a Bosch BME280/BMP280
|
||||||
@@ -1998,6 +2004,7 @@ String latestVersion;
|
|||||||
* Only available for ESP32
|
* Only available for ESP32
|
||||||
*/
|
*/
|
||||||
bool checkForUpdates() {
|
bool checkForUpdates() {
|
||||||
|
Log.notice(F("Update check"));
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
http.begin(OTA_JSON_URL, OTAserver_cert);
|
http.begin(OTA_JSON_URL, OTAserver_cert);
|
||||||
|
|||||||
Reference in new issue
Block a user