mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-10-28 11:14:58 +00:00
add auto check for firmware updates
This commit is contained in:
@@ -121,6 +121,10 @@
|
||||
#define EMSESP_DEFAULT_TELNET_ENABLED true
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_AUTO_FW_CHECK
|
||||
#define EMSESP_DEFAULT_AUTO_FW_CHECK false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_MODBUS_ENABLED
|
||||
#define EMSESP_DEFAULT_MODBUS_ENABLED false
|
||||
#endif
|
||||
|
||||
@@ -720,6 +720,7 @@ void System::store_settings(WebSettings & settings) {
|
||||
system_name_ = settings.system_name;
|
||||
developer_mode_ = settings.developer_mode;
|
||||
disable_reset_ = settings.disable_reset;
|
||||
auto_fw_check_ = settings.auto_fw_check;
|
||||
}
|
||||
|
||||
// Starts up core services
|
||||
@@ -2733,6 +2734,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
||||
node["forceHeatingOff"] = settings.boiler_heatingoff;
|
||||
node["developerMode"] = settings.developer_mode;
|
||||
node["disableReset"] = settings.disable_reset;
|
||||
node["autoFwCheck"] = settings.auto_fw_check;
|
||||
});
|
||||
|
||||
// Devices - show EMS devices if we have any
|
||||
|
||||
@@ -207,6 +207,14 @@ class System {
|
||||
disable_reset_ = disable_reset;
|
||||
}
|
||||
|
||||
bool auto_fw_check() {
|
||||
return auto_fw_check_;
|
||||
}
|
||||
|
||||
void auto_fw_check(bool auto_fw_check) {
|
||||
auto_fw_check_ = auto_fw_check;
|
||||
}
|
||||
|
||||
// Boolean Format API/MQTT
|
||||
uint8_t bool_format() {
|
||||
return bool_format_;
|
||||
@@ -447,6 +455,7 @@ class System {
|
||||
uint32_t modbus_timeout_;
|
||||
bool developer_mode_;
|
||||
bool disable_reset_;
|
||||
bool auto_fw_check_;
|
||||
uint32_t fstotal_;
|
||||
uint32_t psram_;
|
||||
uint32_t appused_;
|
||||
|
||||
@@ -85,6 +85,7 @@ void WebSettings::read(WebSettings & settings, JsonObject root) {
|
||||
root["modbus_timeout"] = settings.modbus_timeout;
|
||||
root["developer_mode"] = settings.developer_mode;
|
||||
root["disable_reset"] = settings.disable_reset;
|
||||
root["auto_fw_check"] = settings.auto_fw_check;
|
||||
root["email_enabled"] = settings.email_enabled;
|
||||
root["email_security"] = settings.email_security;
|
||||
root["email_server"] = settings.email_server;
|
||||
@@ -310,6 +311,12 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
||||
settings.disable_reset = root["disable_reset"];
|
||||
EMSESP::system_.disable_reset(settings.disable_reset);
|
||||
|
||||
settings.auto_fw_check = root["auto_fw_check"] | EMSESP_DEFAULT_AUTO_FW_CHECK;
|
||||
EMSESP::system_.auto_fw_check(settings.auto_fw_check);
|
||||
if (settings.auto_fw_check && !original_settings.auto_fw_check) {
|
||||
EMSESP::webStatusService.schedule_versions_refresh(); // just switched on, so look straight away
|
||||
}
|
||||
|
||||
settings.bool_dashboard = root["bool_dashboard"] | EMSESP_DEFAULT_BOOL_FORMAT;
|
||||
EMSESP::system_.bool_dashboard(settings.bool_dashboard);
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ class WebSettings {
|
||||
|
||||
bool developer_mode; // developer mode
|
||||
bool disable_reset; // disable reset
|
||||
bool auto_fw_check; // periodically check emsesp.org for a newer firmware version
|
||||
|
||||
static void read(WebSettings & settings, JsonObject root);
|
||||
static StateUpdateResult update(JsonObject root, WebSettings & settings);
|
||||
|
||||
@@ -402,10 +402,15 @@ void WebStatusService::schedule_versions_refresh() {
|
||||
versions_next_fetch_ms_ = next;
|
||||
}
|
||||
|
||||
// periodic refresh (1 hour) of the cached versions.json
|
||||
// runs on the main loop task, which has a much bigger stack than AsyncTCP needed for https
|
||||
// periodic refresh (1 hour) of the cached versions.json, only when auto_fw_check is enabled
|
||||
// runs on the main loop task so the blocking fetch never happens in an AsyncTCP callback
|
||||
void WebStatusService::loop() {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
// only reach out to emsesp.org if the user has asked us to
|
||||
if (!EMSESP::system_.auto_fw_check()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// need a network
|
||||
if (!EMSESP::network_.network_connected()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user