Fix version math

This commit is contained in:
iranl
2024-12-03 11:55:38 +01:00
parent 8a23eb3d03
commit db1cfb0d89
5 changed files with 18 additions and 12 deletions

View File

@@ -3,8 +3,9 @@
#include "sdkconfig.h"
#define NUKI_HUB_VERSION "9.03"
#define NUKI_HUB_VERSION_INT (uint32_t)"903"
#define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2024-12-01"
#define NUKI_HUB_DATE "2024-12-03"
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"

View File

@@ -212,18 +212,16 @@ inline void initPreferences(Preferences* preferences)
else
{
int lastConfigVer = preferences->getInt(preference_config_version);
int currentConfigVer = atof(NUKI_HUB_VERSION) * 100;
Log->print("Last config version: ");
Log->println(lastConfigVer);
Log->print("Current config version: ");
Log->println(currentConfigVer);
if(lastConfigVer >= currentConfigVer) return;
if(lastConfigVer >= NUKI_HUB_VERSION_INT) return;
if (lastConfigVer < 834)
{
Log->println("Migration 834");
Log->println("Migration 8.34");
if(preferences->getInt(preference_keypad_control_enabled))
{
@@ -315,7 +313,7 @@ inline void initPreferences(Preferences* preferences)
}
if (lastConfigVer < 901)
{
Log->println("Migration 901");
Log->println("Migration 9.01");
#if defined(CONFIG_IDF_TARGET_ESP32S3)
if (preferences->getInt(preference_network_hardware) == 3)
@@ -328,10 +326,13 @@ inline void initPreferences(Preferences* preferences)
preferences->putInt(preference_network_hardware, 3);
}
}
if (lastConfigVer < 902)
{
Log->println("Migration 9.02");
preferences->putBool(preference_reset_mqtt_topics, true);
}
preferences->putInt(preference_config_version, currentConfigVer);
preferences->putInt(preference_config_version, NUKI_HUB_VERSION_INT);
}
#endif
}

View File

@@ -875,7 +875,7 @@ esp_err_t WebCfgServer::buildOtaHtml(PsychicRequest *request, bool debug)
String currentVersion = NUKI_HUB_VERSION;
const char* latestVersion;
if(atof(doc["release"]["version"]) >= atof(currentVersion.c_str()))
if(atof(doc["release"]["version_int"]) >= NUKI_HUB_VERSION_INT)
{
latestVersion = doc["release"]["fullversion"];
}