From 537d76ef5d4d323224f5513a944453dac53c9767 Mon Sep 17 00:00:00 2001 From: Eduard Iten Date: Tue, 8 Jul 2025 14:41:01 +0200 Subject: [PATCH] feat(app): Integrate application versioning This commit introduces application versioning, exposing version information through the Modbus server and logging it at startup. - Add to provide version information - Update to log the application version at startup - Update to expose firmware version via Modbus - Add file association for in --- software/.vscode/settings.json | 1 + software/apps/slave_node/src/main.c | 3 ++- software/lib/modbus_server/modbus_server.c | 5 +++-- software/lib/valve/valve.c | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/software/.vscode/settings.json b/software/.vscode/settings.json index 4f59a24..148d807 100644 --- a/software/.vscode/settings.json +++ b/software/.vscode/settings.json @@ -8,5 +8,6 @@ // File Associations "files.associations": { + "app_version.h": "c" } } \ No newline at end of file diff --git a/software/apps/slave_node/src/main.c b/software/apps/slave_node/src/main.c index 37ba733..3191bec 100644 --- a/software/apps/slave_node/src/main.c +++ b/software/apps/slave_node/src/main.c @@ -4,12 +4,13 @@ #include #include #include +#include LOG_MODULE_REGISTER(main, LOG_LEVEL_INF); int main(void) { - LOG_INF("Starting Irrigation System Slave Node"); + LOG_INF("Starting Irrigation System Slave Node version %s (Build version %s)", APP_VERSION_STRING, STRINGIFY(APP_BUILD_VERSION)); if (settings_subsys_init() || settings_load()) { LOG_ERR("Settings initialization or loading failed"); diff --git a/software/lib/modbus_server/modbus_server.c b/software/lib/modbus_server/modbus_server.c index 1d78f77..41ab8ad 100644 --- a/software/lib/modbus_server/modbus_server.c +++ b/software/lib/modbus_server/modbus_server.c @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -135,10 +136,10 @@ static int input_reg_rd(uint16_t addr, uint16_t *reg) *reg = fwu_get_last_chunk_crc(); break; case REG_INPUT_FIRMWARE_VERSION_MAJOR_MINOR: - *reg = (0 << 8) | 0; + *reg = (APP_VERSION_MAJOR << 8) | APP_VERSION_MINOR; break; case REG_INPUT_FIRMWARE_VERSION_PATCH: - *reg = 2; + *reg = APP_PATCHLEVEL; break; default: *reg = 0; diff --git a/software/lib/valve/valve.c b/software/lib/valve/valve.c index 059b095..113874e 100644 --- a/software/lib/valve/valve.c +++ b/software/lib/valve/valve.c @@ -52,7 +52,6 @@ void valve_init(void) LOG_INF("Valve initialized: max_open=%us, max_close=%us", max_opening_time_s, max_closing_time_s); } -} void valve_open(void) {