From 94a8bd1c8e811ef9f0ca61bd074ff5d9e53504a6 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 11 Jul 2024 11:35:01 +0200 Subject: [PATCH] Auto update to latest beta version (#420) --- src/Config.h | 10 ++++++++++ src/WebCfgServer.cpp | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Config.h b/src/Config.h index 2068b3e..af6c0ec 100644 --- a/src/Config.h +++ b/src/Config.h @@ -11,19 +11,29 @@ #if defined(CONFIG_IDF_TARGET_ESP32C3) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32c3.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32c3.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32c3.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32c3.bin" #elif defined(CONFIG_IDF_TARGET_ESP32S3) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32s3.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32s3.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32s3.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32s3.bin" #elif defined(CONFIG_IDF_TARGET_ESP32C6) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32c6.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32c6.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32c6.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32c6.bin" #else #if defined(FRAMEWORK_ARDUINO_SOLO1) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32solo1.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32solo1.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32solo1.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32solo1.bin" #else #define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32.bin" #define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32.bin" #endif #endif diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 4447211..c082998 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -321,11 +321,21 @@ void WebCfgServer::initialize() if (_hasCredentials && !_server.authenticate(_credUser, _credPassword)) { return _server.requestAuthentication(); } - String response = ""; - buildConfirmHtml(response, "Rebooting to update Nuki Hub and Nuki Hub updater", 2); + String response = ""; + String key = _server.argName(0); + if(key == "beta") + { + buildConfirmHtml(response, "Rebooting to update Nuki Hub and Nuki Hub updater
Updating to latest BETA version", 2); + _preferences->putString(preference_ota_updater_url, GITHUB_BETA_UPDATER_BINARY_URL); + _preferences->putString(preference_ota_main_url, GITHUB_BETA_RELEASE_BINARY_URL); + } + else + { + buildConfirmHtml(response, "Rebooting to update Nuki Hub and Nuki Hub updater
Updating to latest RELEASE version", 2); + _preferences->putString(preference_ota_updater_url, GITHUB_LATEST_UPDATER_BINARY_URL); + _preferences->putString(preference_ota_main_url, GITHUB_LATEST_RELEASE_BINARY_URL); + } _server.send(200, "text/html", response); - _preferences->putString(preference_ota_updater_url, GITHUB_LATEST_UPDATER_BINARY_URL); - _preferences->putString(preference_ota_main_url, GITHUB_LATEST_RELEASE_BINARY_URL); restartEsp(RestartReason::OTAReboot); }); #endif @@ -393,7 +403,7 @@ void WebCfgServer::buildOtaHtml(String &response, bool errored) response.concat("', '_blank'); return false;\">Open latest release on GitHub"); return; } - + response.concat("
Initiating Over-the-air update. This will take about two minutes, please be patient.
You will be forwarded automatically when the update is complete.
"); #if (ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0, 0))