diff --git a/config/zephyr/Kconfig b/config/zephyr/Kconfig index c806ceed805385..95cea7cec1a707 100644 --- a/config/zephyr/Kconfig +++ b/config/zephyr/Kconfig @@ -95,6 +95,7 @@ config CHIP_DEVICE_HARDWARE_VERSION_STRING hardware version string is exposed as an attribute of the Basic Information cluster. +if "$(APPVERSION)"="" config CHIP_DEVICE_SOFTWARE_VERSION int "Software version" default 0 @@ -116,6 +117,7 @@ config CHIP_DEVICE_SOFTWARE_VERSION_STRING software version string is exposed as an attribute of the Basic Information cluster, and included in the header of the generated Matter over-the-air (OTA) update image. +endif config CHIP_DEVICE_MANUFACTURING_DATE string "Manufacturing date (ISO 8601 format)" diff --git a/config/zephyr/ota-image.cmake b/config/zephyr/ota-image.cmake index bd7735648f8302..f254b97ea58b8a 100644 --- a/config/zephyr/ota-image.cmake +++ b/config/zephyr/ota-image.cmake @@ -31,18 +31,33 @@ function(chip_ota_image TARGET_NAME) endif() # Prepare ota_image_tool.py argument list - set(OTA_ARGS - "--vendor-id" - ${CONFIG_CHIP_DEVICE_VENDOR_ID} - "--product-id" - ${CONFIG_CHIP_DEVICE_PRODUCT_ID} - "--version" - ${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION} - "--version-str" - ${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING} - "--digest-algorithm" - "sha256" - ) + if(DEFINED APPVERSION) + set(OTA_ARGS + "--vendor-id" + ${CONFIG_CHIP_DEVICE_VENDOR_ID} + "--product-id" + ${CONFIG_CHIP_DEVICE_PRODUCT_ID} + "--version" + ${APPVERSION} + "--version-str" + ${APP_VERSION_TWEAK_STRING} + "--digest-algorithm" + "sha256" + ) + else() + set(OTA_ARGS + "--vendor-id" + ${CONFIG_CHIP_DEVICE_VENDOR_ID} + "--product-id" + ${CONFIG_CHIP_DEVICE_PRODUCT_ID} + "--version" + ${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION} + "--version-str" + ${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING} + "--digest-algorithm" + "sha256" + ) + endif() separate_arguments(OTA_EXTRA_ARGS NATIVE_COMMAND "${CHIP_OTA_IMAGE_EXTRA_ARGS}") diff --git a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h index 2e3c93289f8516..991c3689425ae7 100644 --- a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h +++ b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h @@ -23,6 +23,9 @@ #pragma once +#ifndef CONFIG_CHIP_DEVICE_SOFTWARE_VERSION +#include "app_version.h" +#endif #include "autoconf.h" // ==================== Platform Adaptations ==================== @@ -33,8 +36,19 @@ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME CONFIG_CHIP_DEVICE_PRODUCT_NAME #define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION CONFIG_CHIP_DEVICE_HARDWARE_VERSION #define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING CONFIG_CHIP_DEVICE_HARDWARE_VERSION_STRING + +#ifdef CONFIG_CHIP_DEVICE_SOFTWARE_VERSION #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION CONFIG_CHIP_DEVICE_SOFTWARE_VERSION +#else +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION APPVERSION +#endif + +#ifdef CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING +#else +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING APP_VERSION_TWEAK_STRING +#endif + #define CHIP_DEVICE_CONFIG_TEST_MANUFACTURING_DATE CONFIG_CHIP_DEVICE_MANUFACTURING_DATE #define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER CONFIG_CHIP_DEVICE_SERIAL_NUMBER #define CHIP_DEVICE_CONFIG_DEVICE_TYPE CONFIG_CHIP_DEVICE_TYPE