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

@@ -30,11 +30,13 @@ elif (data[args.ota_type]['version'] == version):
else:
number = 1
version_int = version*100
content_new = ""
with open ('src/Config.h', 'r' ) as readfile:
file_content = readfile.read()
content_new = re.sub(regex, "#define NUKI_HUB_VERSION \"" + str(version) + "-" + args.ota_type + str(number) + "\"", file_content, flags = re.M)
content_new = re.sub(regex, "#define NUKI_HUB_VERSION_INT \"" + str(version_int) + "-" + args.ota_type + str(number) + "\"", content_new, flags = re.M)
with open('src/Config.h', 'w') as writefile:
writefile.write(content_new)

View File

@@ -24,6 +24,7 @@ with open('ota/manifest.json', 'r+') as json_file:
if (args.build == 'none'):
data[args.ota_type]['time'] = "0000-00-00"
data[args.ota_type]['version'] = "No beta available"
data[args.ota_type]['version_int'] = "No beta available"
data[args.ota_type]['fullversion'] = "No beta available"
data[args.ota_type]['build'] = ""
data[args.ota_type]['number'] = "0"
@@ -37,6 +38,7 @@ with open('ota/manifest.json', 'r+') as json_file:
data[args.ota_type]['time'] = datetime.now(timezone.utc).strftime("%Y-%m-%d")
data[args.ota_type]['version'] = str(version)
data[args.ota_type]['version_int'] = str(version*100)
if (args.ota_type == "release"):
data[args.ota_type]['fullversion'] = str(version)

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"];
}