Add buttons to /ota

This commit is contained in:
iranl
2024-02-15 22:46:47 +01:00
parent 533e78e06a
commit 8139c23785
4 changed files with 18 additions and 13 deletions

View File

@@ -4,6 +4,7 @@
#define GITHUB_LATEST_RELEASE_URL "https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_LATEST_RELEASE_API_URL "https://api.github.com/repos/technyon/nuki_hub/releases/latest"
#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/webflash/nuki_hub.bin"
#define MQTT_QOS_LEVEL 1
#define MQTT_CLEAN_SESSIONS false

View File

@@ -375,7 +375,6 @@ bool Network::update()
if (!jsonError) {
_latestVersion = doc["tag_name"];
_latestVersionUrl = doc["assets"][0]["browser_download_url"];
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion);
}
}
@@ -675,11 +674,6 @@ const char* Network::latestHubVersion()
return _latestVersion;
}
const char* Network::latestHubVersionUrl()
{
return _latestVersionUrl;
}
bool Network::encryptionSupported()
{
return _device->supportsEncryption();

View File

@@ -64,7 +64,6 @@ public:
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
const char* latestHubVersion();
const char* latestHubVersionUrl();
bool encryptionSupported();
const String networkDeviceName() const;
@@ -115,7 +114,6 @@ private:
String _lockPath;
const char* _latestVersion;
const char* _latestVersionUrl;
HTTPClient https;
Preferences* _preferences;

View File

@@ -356,7 +356,7 @@ bool WebCfgServer::processArgs(String& message)
{
_preferences->putString(preference_mqtt_hass_cu_url, value);
configChanged = true;
}
}
else if(key == "HOSTNAME")
{
_preferences->putString(preference_hostname, value);
@@ -622,16 +622,16 @@ void WebCfgServer::buildHtml(String& response)
printParameter(response, "Nuki Opener state", lockstateArr);
}
printParameter(response, "Firmware", version.c_str(), "/info");
const char* _latestVersion = _network->latestHubVersion();
if(_preferences->getBool(preference_check_updates))
{
//if(atof(_latestVersion) > atof(NUKI_HUB_VERSION) || (atof(_latestVersion) == atof(NUKI_HUB_VERSION) && _latestVersion != NUKI_HUB_VERSION)) {
printParameter(response, "Latest Firmware", _latestVersion, GITHUB_LATEST_RELEASE_URL);
printParameter(response, "Latest Firmware", _latestVersion, "/ota");
//}
}
response.concat("</table><br><br>");
response.concat("<h3>MQTT and Network Configuration</h3>");
@@ -741,6 +741,18 @@ void WebCfgServer::buildOtaHtml(String &response, bool errored)
response.concat("<form id=\"upform\" enctype=\"multipart/form-data\" action=\"/uploadota\" method=\"POST\"><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\" />Choose the updated nuki_hub.bin file to upload: <input name=\"uploadedfile\" type=\"file\" accept=\".bin\" /><br/>");
response.concat("<br><input id=\"submitbtn\" type=\"submit\" value=\"Upload File\" /></form>");
if(_preferences->getBool(preference_check_updates))
{
response.concat("<button title=\"Open latest release on GitHub\" onclick=\" window.open('");
response.concat(GITHUB_LATEST_RELEASE_URL);
response.concat("', '_blank'); return false;\">Open latest release on GitHub</button>");
response.concat("<br><br><button title=\"Download latest binary from GitHub\" onclick=\" window.open('");
response.concat(GITHUB_LATEST_RELEASE_BINARY_URL);
response.concat("'); return false;\">Download latest binary from GitHub</button>");
}
response.concat("<div id=\"msgdiv\" style=\"visibility:hidden\">Initiating Over-the-air update. This will take about two minutes, please be patient.<br>You will be forwarded automatically when the update is complete.</div>");
response.concat("<script type=\"text/javascript\">");
response.concat("window.addEventListener('load', function () {");