Fix WebCfg ota link

This commit is contained in:
iranl
2024-03-03 23:01:52 +01:00
parent ac37cafc99
commit 63d35e5739
4 changed files with 12 additions and 12 deletions

View File

@@ -369,13 +369,20 @@ bool Network::update()
int httpResponseCode = https.GET(); int httpResponseCode = https.GET();
if (httpResponseCode == HTTP_CODE_OK || httpResponseCode == HTTP_CODE_MOVED_PERMANENTLY) { if (httpResponseCode == HTTP_CODE_OK || httpResponseCode == HTTP_CODE_MOVED_PERMANENTLY)
{
DynamicJsonDocument doc(6144); DynamicJsonDocument doc(6144);
DeserializationError jsonError = deserializeJson(doc, https.getStream()); DeserializationError jsonError = deserializeJson(doc, https.getStream());
if (!jsonError) { if (!jsonError)
{
_latestVersion = doc["tag_name"]; _latestVersion = doc["tag_name"];
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion); publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion);
if (_latestVersion != _preferences->getString(preference_latest_version).c_str())
{
_preferences->setString(_latestVersion);
}
} }
} }
@@ -669,11 +676,6 @@ int Network::mqttConnectionState()
return _mqttConnectionState; return _mqttConnectionState;
} }
const char* Network::latestHubVersion()
{
return _latestVersion;
}
bool Network::encryptionSupported() bool Network::encryptionSupported()
{ {
return _device->supportsEncryption(); return _device->supportsEncryption();

View File

@@ -65,7 +65,6 @@ public:
void publishPresenceDetection(char* csv); void publishPresenceDetection(char* csv);
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
const char* latestHubVersion();
bool encryptionSupported(); bool encryptionSupported();
const String networkDeviceName() const; const String networkDeviceName() const;

View File

@@ -58,6 +58,7 @@
#define preference_has_mac_byte_0 "macb0" #define preference_has_mac_byte_0 "macb0"
#define preference_has_mac_byte_1 "macb1" #define preference_has_mac_byte_1 "macb1"
#define preference_has_mac_byte_2 "macb2" #define preference_has_mac_byte_2 "macb2"
#define preference_latest_version "latest"
class DebugPreferences class DebugPreferences
{ {
@@ -78,7 +79,7 @@ private:
preference_register_as_app, preference_command_nr_of_retries, preference_register_as_app, preference_command_nr_of_retries,
preference_command_retry_delay, preference_cred_user, preference_cred_password, preference_publish_authdata, preference_command_retry_delay, preference_cred_user, preference_cred_password, preference_publish_authdata,
preference_publish_debug_info, preference_presence_detection_timeout, preference_publish_debug_info, preference_presence_detection_timeout,
preference_has_mac_saved, preference_has_mac_byte_0, preference_has_mac_byte_1, preference_has_mac_byte_2, preference_has_mac_saved, preference_has_mac_byte_0, preference_has_mac_byte_1, preference_has_mac_byte_2, preference_latest_version,
}; };
std::vector<char*> _redact = std::vector<char*> _redact =
{ {

View File

@@ -636,12 +636,10 @@ void WebCfgServer::buildHtml(String& response)
} }
printParameter(response, "Firmware", version.c_str(), "/info"); printParameter(response, "Firmware", version.c_str(), "/info");
const char* _latestVersion = _network->latestHubVersion();
if(_preferences->getBool(preference_check_updates)) if(_preferences->getBool(preference_check_updates))
{ {
//if(atof(_latestVersion) > atof(NUKI_HUB_VERSION) || (atof(_latestVersion) == atof(NUKI_HUB_VERSION) && _latestVersion != NUKI_HUB_VERSION)) { //if(atof(_latestVersion) > atof(NUKI_HUB_VERSION) || (atof(_latestVersion) == atof(NUKI_HUB_VERSION) && _latestVersion != NUKI_HUB_VERSION)) {
printParameter(response, "Latest Firmware", _latestVersion, "/ota"); printParameter(response, "Latest Firmware", _preferences->getString(preference_latest_version).c_str(), "/ota");
//} //}
} }