mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-05-06 05:55:53 +00:00
refactoring
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
#define EMSESP_SYSTEM_STATUS_SERVICE_PATH "/rest/systemStatus"
|
||||
#define EMSESP_ACTION_SERVICE_PATH "/rest/action"
|
||||
|
||||
#include "../core/EMSESP_Version.h"
|
||||
#define EMSESP_VERSIONS_URL "http://emsesp.org/versions.json"
|
||||
|
||||
#include "../core/firmwareVersion.h"
|
||||
#include "../emsesp_version.h"
|
||||
|
||||
namespace emsesp {
|
||||
@@ -19,8 +21,8 @@ class WebStatusService {
|
||||
return current_version_s;
|
||||
}
|
||||
|
||||
// called from EMSESP::loop() to refresh the cached versions.json from emsesp.org so that the web
|
||||
// request handler never has to do blocking HTTPS on the small AsyncTCP stack
|
||||
// called from EMSESP::loop() to refresh the cached versions.json from emsesp.org
|
||||
// so that the web request handler never has to do blocking HTTPS on the small AsyncTCP stack
|
||||
void loop();
|
||||
|
||||
// true once we've had at least one successful versions.json fetch
|
||||
@@ -28,6 +30,11 @@ class WebStatusService {
|
||||
return versions_cache_valid_;
|
||||
}
|
||||
|
||||
// refresh the versions.json cache
|
||||
void schedule_versions_refresh() {
|
||||
versions_next_fetch_ms_ = 1;
|
||||
}
|
||||
|
||||
bool current_upgradeable() const; // true if a newer version is available
|
||||
|
||||
// make action function public so we can test in the debug and standalone mode
|
||||
@@ -60,13 +67,12 @@ class WebStatusService {
|
||||
VersionInfo versions_stable_;
|
||||
VersionInfo versions_dev_;
|
||||
bool versions_cache_valid_ = false; // true once we've had at least one successful fetch
|
||||
uint32_t versions_next_fetch_ms_ = 0; // uuid::get_uptime() of the next attempt; 0 = ASAP
|
||||
uint32_t versions_next_fetch_ms_ = 0; // uuid::get_uptime() of the next attempt; 0 = idle
|
||||
|
||||
bool refresh_versions_cache(); // does the actual HTTPS fetch + parse, returns true on success
|
||||
|
||||
static constexpr uint32_t VERSIONS_REFRESH_INTERVAL_MS = 60UL * 60UL * 1000UL; // 1 hour on success
|
||||
static constexpr uint32_t VERSIONS_RETRY_INTERVAL_MS = 5UL * 60UL * 1000UL; // 5 min after failure
|
||||
static constexpr uint32_t VERSIONS_INITIAL_DELAY_MS = 30UL * 1000UL; // wait 30s after boot
|
||||
};
|
||||
|
||||
} // namespace emsesp
|
||||
|
||||
Reference in New Issue
Block a user