From 228b6f2f165597fe404f39993b14d7af9f2f9f7f Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 11:21:27 +0100 Subject: [PATCH 01/13] Making core log level configurable via Kconfig entry. --- .../prstlib/boards/arm/bparasite_nrf52833/Kconfig | 6 +++++- .../prstlib/boards/arm/bparasite_nrf52840/Kconfig | 6 +++++- code/nrf-connect/prstlib/src/adc.c | 2 +- code/nrf-connect/prstlib/src/button.c | 2 +- code/nrf-connect/prstlib/src/led.c | 2 +- code/nrf-connect/prstlib/src/sensors.c | 2 +- code/nrf-connect/prstlib/src/shtc3.c | 2 +- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig index b6f2e0e..be20e5e 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig @@ -6,4 +6,8 @@ config BOARD_ENABLE_DCDC select SOC_DCDC_NRF52X default y -endif # BOARD_BPARASITE_NRF52833 \ No newline at end of file +endif # BOARD_BPARASITE_NRF52833 + +config CORE_LOG_LEVEL + int "Logging level in core prst library." + default 2 \ No newline at end of file diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig index aa0eeee..e6418be 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig @@ -11,4 +11,8 @@ config BOARD_ENABLE_DCDC_HV select SOC_DCDC_NRF52X_HV default y -endif # BOARD_BPARASITE_NRF52840 \ No newline at end of file +endif # BOARD_BPARASITE_NRF52840 + +config CORE_LOG_LEVEL + int "Logging level in core prst library." + default 2 \ No newline at end of file diff --git a/code/nrf-connect/prstlib/src/adc.c b/code/nrf-connect/prstlib/src/adc.c index 1856f7e..69d32ad 100644 --- a/code/nrf-connect/prstlib/src/adc.c +++ b/code/nrf-connect/prstlib/src/adc.c @@ -9,7 +9,7 @@ #include "prstlib/macros.h" -LOG_MODULE_REGISTER(adc, LOG_LEVEL_WRN); +LOG_MODULE_REGISTER(adc, CONFIG_CORE_LOG_LEVEL); // PWM spec for square wave. Input to the soil sensing circuit. static const struct pwm_dt_spec soil_pwm_dt = diff --git a/code/nrf-connect/prstlib/src/button.c b/code/nrf-connect/prstlib/src/button.c index a27eda2..a545e9b 100644 --- a/code/nrf-connect/prstlib/src/button.c +++ b/code/nrf-connect/prstlib/src/button.c @@ -6,7 +6,7 @@ #include "prstlib/led.h" #include "prstlib/macros.h" -LOG_MODULE_REGISTER(button, LOG_LEVEL_WRN); +LOG_MODULE_REGISTER(button, CONFIG_CORE_LOG_LEVEL); static struct gpio_dt_spec button = GPIO_DT_SPEC_GET(DT_NODELABEL(button0), gpios); diff --git a/code/nrf-connect/prstlib/src/led.c b/code/nrf-connect/prstlib/src/led.c index 415296f..654339c 100644 --- a/code/nrf-connect/prstlib/src/led.c +++ b/code/nrf-connect/prstlib/src/led.c @@ -4,7 +4,7 @@ #include "prstlib/macros.h" -LOG_MODULE_REGISTER(led, LOG_LEVEL_WRN); +LOG_MODULE_REGISTER(led, CONFIG_CORE_LOG_LEVEL); struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios); diff --git a/code/nrf-connect/prstlib/src/sensors.c b/code/nrf-connect/prstlib/src/sensors.c index e0b1ca9..218ea77 100644 --- a/code/nrf-connect/prstlib/src/sensors.c +++ b/code/nrf-connect/prstlib/src/sensors.c @@ -6,7 +6,7 @@ #include "prstlib/led.h" #include "prstlib/macros.h" -LOG_MODULE_REGISTER(sensors, LOG_LEVEL_WRN); +LOG_MODULE_REGISTER(sensors, CONFIG_CORE_LOG_LEVEL); int prst_sensors_read_all(prst_sensors_t *sensors) { RET_IF_ERR(prst_adc_batt_read(&sensors->batt)); diff --git a/code/nrf-connect/prstlib/src/shtc3.c b/code/nrf-connect/prstlib/src/shtc3.c index 90cd6ba..dc1c90b 100644 --- a/code/nrf-connect/prstlib/src/shtc3.c +++ b/code/nrf-connect/prstlib/src/shtc3.c @@ -6,7 +6,7 @@ #include "prstlib/macros.h" -LOG_MODULE_REGISTER(shtc3, LOG_LEVEL_WRN); +LOG_MODULE_REGISTER(shtc3, CONFIG_CORE_LOG_LEVEL); static const struct i2c_dt_spec shtc3 = I2C_DT_SPEC_GET(DT_NODELABEL(shtc3)); From 96e1e851796a0a677a24df584a8385ae3a6992b9 Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 11:21:52 +0100 Subject: [PATCH 02/13] Making zigbee main log level configurable. --- code/nrf-connect/samples/zigbee/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index ae08fcb..b93946e 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -23,7 +23,7 @@ #define FACTORY_RESET_BUTTON DK_BTN4_MSK -LOG_MODULE_REGISTER(app, LOG_LEVEL_INF); +LOG_MODULE_REGISTER(app, CONFIG_LOG_DEFAULT_LEVEL); static struct zb_device_ctx dev_ctx; From 03b45062c0cb9966d7f7fc7dda4caefad25ad3ab Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 11:49:37 +0100 Subject: [PATCH 03/13] Fixing sensor logging millivolts. --- code/nrf-connect/prstlib/src/sensors.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/nrf-connect/prstlib/src/sensors.c b/code/nrf-connect/prstlib/src/sensors.c index 218ea77..42b5e3c 100644 --- a/code/nrf-connect/prstlib/src/sensors.c +++ b/code/nrf-connect/prstlib/src/sensors.c @@ -16,10 +16,10 @@ int prst_sensors_read_all(prst_sensors_t *sensors) { LOG_DBG("Batt: %d mV (%.2f%%)", sensors->batt.adc_read.millivolts, 100 * sensors->batt.percentage); - LOG_DBG("Soil: %.0f %% (%.3f mV)", 100 * sensors->soil.percentage, - sensors->soil.adc_read.voltage); - LOG_DBG("Photo: %u lx (%.3f mV)", sensors->photo.brightness, - sensors->soil.adc_read.voltage); + LOG_DBG("Soil: %.0f %% (%d mV)", 100 * sensors->soil.percentage, + sensors->soil.adc_read.millivolts); + LOG_DBG("Photo: %u lx (%d mV)", sensors->photo.brightness, + sensors->soil.adc_read.millivolts); LOG_DBG("Temp: %f oC", sensors->shtc3.temp_c); LOG_DBG("Humi: %.0f %%", 100 * sensors->shtc3.rel_humi); LOG_DBG("--------------------------------------------------"); From 0a3d7117877fee7d9285bca6c42222b17503d138 Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 12:10:08 +0100 Subject: [PATCH 04/13] Fixed bug in cluster list not connecting power cluster. --- code/nrf-connect/samples/zigbee/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index b93946e..46282bd 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -113,7 +113,7 @@ PRST_ZB_DECLARE_CLUSTER_LIST( identify_attr_list, temp_measurement_attr_list, rel_humi_attr_list, - basic_attr_list, + batt_attr_list, soil_moisture_attr_list, illuminance_attr_list); From 3b91d7525c22d12a339374af5b6bf613f6d6603e Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 12:15:36 +0100 Subject: [PATCH 05/13] Improved basic attribute list to include more properties. --- code/nrf-connect/samples/zigbee/src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index 46282bd..a76b541 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -57,13 +57,13 @@ ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT( &dev_ctx.basic_attr.app_version, &dev_ctx.basic_attr.stack_version, &dev_ctx.basic_attr.hw_version, - dev_ctx.basic_attr.mf_name, - dev_ctx.basic_attr.model_id, - dev_ctx.basic_attr.date_code, + &dev_ctx.basic_attr.mf_name, + &dev_ctx.basic_attr.model_id, + &dev_ctx.basic_attr.date_code, &dev_ctx.basic_attr.power_source, - dev_ctx.basic_attr.location_id, + &dev_ctx.basic_attr.location_id, &dev_ctx.basic_attr.ph_env, - dev_ctx.basic_attr.sw_ver); + &dev_ctx.basic_attr.sw_ver); ZB_ZCL_DECLARE_TEMP_MEASUREMENT_ATTRIB_LIST(temp_measurement_attr_list, &dev_ctx.temp_measure_attrs.measure_value, From 61729aa81abbd8041216e756561124c04e795e65 Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 12:16:42 +0100 Subject: [PATCH 06/13] Made more basic attributes compile time configurable. --- code/nrf-connect/samples/zigbee/Kconfig | 10 +++++++++- code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c | 5 +++++ .../samples/zigbee/src/prst_zb_endpoint_defs.h | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index f604209..d721814 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -6,4 +6,12 @@ config PRST_ZB_SLEEP_DURATION_SEC config PRST_ZB_PARENT_POLL_INTERVAL_SEC int "Interval for when b-parasite polls its parent for data (in seconds)" - default 60 \ No newline at end of file + default 60 + +config BUILD_DATE + string "Zigbee app init basic date code. Can be used as build revision." + default "20221214" + +config MODEL_ID + string "Zigbee app model id." + default "b-parasite" \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c index 95c9873..a21ae28 100644 --- a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c +++ b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c @@ -17,6 +17,11 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) { PRST_BASIC_MODEL_ID, ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MODEL_ID)); + ZB_ZCL_SET_STRING_VAL( + dev_ctx->basic_attr.date_code, + PRST_BASIC_DATE_CODE, + ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_DATE_CODE)); + dev_ctx->identify_attr.identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE; } diff --git a/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h b/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h index 601daa2..149c31f 100644 --- a/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h +++ b/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h @@ -5,7 +5,8 @@ #define PRST_ZIGBEE_ENDPOINT 10 #define PRST_BASIC_MANUF_NAME "b-parasite" -#define PRST_BASIC_MODEL_ID "b-parasite" +#define PRST_BASIC_MODEL_ID CONFIG_MODEL_ID +#define PRST_BASIC_DATE_CODE CONFIG_BUILD_DATE #define PRST_ZB_DEVICE_ID 0x0008 #define PRST_ZB_DEVICE_VERSION 0 From 891a63a1b3e3e0a52dcbba93dd44b1f7a9f23bbc Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Fri, 16 Dec 2022 13:15:51 +0100 Subject: [PATCH 07/13] Added separate debug config to better separate flags during development. --- code/nrf-connect/samples/zigbee/prj.conf | 4 +- .../nrf-connect/samples/zigbee/prj_debug.conf | 52 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 code/nrf-connect/samples/zigbee/prj_debug.conf diff --git a/code/nrf-connect/samples/zigbee/prj.conf b/code/nrf-connect/samples/zigbee/prj.conf index 552b18f..002aa88 100644 --- a/code/nrf-connect/samples/zigbee/prj.conf +++ b/code/nrf-connect/samples/zigbee/prj.conf @@ -43,4 +43,6 @@ CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI=y CONFIG_RAM_POWER_DOWN_LIBRARY=y # Config options in Kconfig. -# CONFIG_PRST_ZB_SLEEP_DURATION_SEC=5 +CONFIG_PRST_ZB_SLEEP_DURATION_SEC=600 +CONFIG_MODEL_ID="Z-Parasite" +CONFIG_BUILD_DATE="20221216" \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/prj_debug.conf b/code/nrf-connect/samples/zigbee/prj_debug.conf new file mode 100644 index 0000000..9f6d537 --- /dev/null +++ b/code/nrf-connect/samples/zigbee/prj_debug.conf @@ -0,0 +1,52 @@ + +CONFIG_LOG=y +CONFIG_PWM=y +CONFIG_I2C=y +CONFIG_ADC=y +CONFIG_GPIO=y + +CONFIG_PM=y +CONFIG_PM_DEVICE=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y + +CONFIG_SERIAL=n + +CONFIG_HEAP_MEM_POOL_SIZE=2048 +CONFIG_MAIN_THREAD_PRIORITY=7 + +CONFIG_ZIGBEE=y +CONFIG_ZIGBEE_APP_UTILS=y +CONFIG_ZIGBEE_ROLE_END_DEVICE=y + +# This example requires more workqueue stack +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +# Enable nRF ECB driver +CONFIG_CRYPTO=y +CONFIG_CRYPTO_NRF_ECB=y +CONFIG_CRYPTO_INIT_PRIORITY=80 + +# Networking +CONFIG_NET_IPV6_MLD=n +CONFIG_NET_IPV6_NBR_CACHE=n +CONFIG_NET_IPV6_RA_RDNSS=n +CONFIG_NET_IP_ADDR_CHECK=n +CONFIG_NET_UDP=n + +# Get Zigbee to scan every channel. +CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI=y + +# Enable API for powering down unused RAM parts. +# https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/nrf/ug_zigbee_configuring.html#power-saving-during-sleep +CONFIG_RAM_POWER_DOWN_LIBRARY=y + +# Config options in Kconfig. +CONFIG_PRST_ZB_SLEEP_DURATION_SEC=10 + +CONFIG_LOG_DEFAULT_LEVEL=4 +CONFIG_CORE_LOG_LEVEL=4 + +CONFIG_MODEL_ID="Z-Parasite" +CONFIG_BUILD_DATE="20221216" From 412188502b220357b94623f44b5d3d29012a1ad3 Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Sun, 18 Dec 2022 16:55:32 +0100 Subject: [PATCH 08/13] Changed name of config value for prstlib default log level. --- code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig | 2 +- code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig | 2 +- code/nrf-connect/prstlib/src/adc.c | 2 +- code/nrf-connect/prstlib/src/button.c | 2 +- code/nrf-connect/prstlib/src/led.c | 2 +- code/nrf-connect/prstlib/src/sensors.c | 2 +- code/nrf-connect/prstlib/src/shtc3.c | 2 +- code/nrf-connect/samples/zigbee/prj_debug.conf | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig index be20e5e..05586ab 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig @@ -8,6 +8,6 @@ config BOARD_ENABLE_DCDC endif # BOARD_BPARASITE_NRF52833 -config CORE_LOG_LEVEL +config PRSTLIB_DEFAULT_LOG_LEVEL int "Logging level in core prst library." default 2 \ No newline at end of file diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig index e6418be..45ac075 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig @@ -13,6 +13,6 @@ config BOARD_ENABLE_DCDC_HV endif # BOARD_BPARASITE_NRF52840 -config CORE_LOG_LEVEL +config PRSTLIB_DEFAULT_LOG_LEVEL int "Logging level in core prst library." default 2 \ No newline at end of file diff --git a/code/nrf-connect/prstlib/src/adc.c b/code/nrf-connect/prstlib/src/adc.c index 69d32ad..06a42ad 100644 --- a/code/nrf-connect/prstlib/src/adc.c +++ b/code/nrf-connect/prstlib/src/adc.c @@ -9,7 +9,7 @@ #include "prstlib/macros.h" -LOG_MODULE_REGISTER(adc, CONFIG_CORE_LOG_LEVEL); +LOG_MODULE_REGISTER(adc, CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL); // PWM spec for square wave. Input to the soil sensing circuit. static const struct pwm_dt_spec soil_pwm_dt = diff --git a/code/nrf-connect/prstlib/src/button.c b/code/nrf-connect/prstlib/src/button.c index a545e9b..2243845 100644 --- a/code/nrf-connect/prstlib/src/button.c +++ b/code/nrf-connect/prstlib/src/button.c @@ -6,7 +6,7 @@ #include "prstlib/led.h" #include "prstlib/macros.h" -LOG_MODULE_REGISTER(button, CONFIG_CORE_LOG_LEVEL); +LOG_MODULE_REGISTER(button, CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL); static struct gpio_dt_spec button = GPIO_DT_SPEC_GET(DT_NODELABEL(button0), gpios); diff --git a/code/nrf-connect/prstlib/src/led.c b/code/nrf-connect/prstlib/src/led.c index 654339c..cd99937 100644 --- a/code/nrf-connect/prstlib/src/led.c +++ b/code/nrf-connect/prstlib/src/led.c @@ -4,7 +4,7 @@ #include "prstlib/macros.h" -LOG_MODULE_REGISTER(led, CONFIG_CORE_LOG_LEVEL); +LOG_MODULE_REGISTER(led, CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL); struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios); diff --git a/code/nrf-connect/prstlib/src/sensors.c b/code/nrf-connect/prstlib/src/sensors.c index 42b5e3c..e97a35f 100644 --- a/code/nrf-connect/prstlib/src/sensors.c +++ b/code/nrf-connect/prstlib/src/sensors.c @@ -6,7 +6,7 @@ #include "prstlib/led.h" #include "prstlib/macros.h" -LOG_MODULE_REGISTER(sensors, CONFIG_CORE_LOG_LEVEL); +LOG_MODULE_REGISTER(sensors, CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL); int prst_sensors_read_all(prst_sensors_t *sensors) { RET_IF_ERR(prst_adc_batt_read(&sensors->batt)); diff --git a/code/nrf-connect/prstlib/src/shtc3.c b/code/nrf-connect/prstlib/src/shtc3.c index dc1c90b..5e2103b 100644 --- a/code/nrf-connect/prstlib/src/shtc3.c +++ b/code/nrf-connect/prstlib/src/shtc3.c @@ -6,7 +6,7 @@ #include "prstlib/macros.h" -LOG_MODULE_REGISTER(shtc3, CONFIG_CORE_LOG_LEVEL); +LOG_MODULE_REGISTER(shtc3, CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL); static const struct i2c_dt_spec shtc3 = I2C_DT_SPEC_GET(DT_NODELABEL(shtc3)); diff --git a/code/nrf-connect/samples/zigbee/prj_debug.conf b/code/nrf-connect/samples/zigbee/prj_debug.conf index 9f6d537..da51b99 100644 --- a/code/nrf-connect/samples/zigbee/prj_debug.conf +++ b/code/nrf-connect/samples/zigbee/prj_debug.conf @@ -46,7 +46,7 @@ CONFIG_RAM_POWER_DOWN_LIBRARY=y CONFIG_PRST_ZB_SLEEP_DURATION_SEC=10 CONFIG_LOG_DEFAULT_LEVEL=4 -CONFIG_CORE_LOG_LEVEL=4 +CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL=4 CONFIG_MODEL_ID="Z-Parasite" CONFIG_BUILD_DATE="20221216" From 0933c4a2a63483f2a06d9a90d0bb4a44aecea62d Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Sun, 18 Dec 2022 16:57:50 +0100 Subject: [PATCH 09/13] Fixed default sleep duration in Kconfig to 600s. Removed specific Kconfig values from prj*.conf files. --- code/nrf-connect/samples/zigbee/Kconfig | 2 +- code/nrf-connect/samples/zigbee/prj.conf | 5 ----- code/nrf-connect/samples/zigbee/prj_debug.conf | 3 --- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index d721814..f60ec56 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -2,7 +2,7 @@ source "Kconfig.zephyr" config PRST_ZB_SLEEP_DURATION_SEC int "Sleep duration between waking up and reading sensors (in seconds)" - default 60 + default 600 config PRST_ZB_PARENT_POLL_INTERVAL_SEC int "Interval for when b-parasite polls its parent for data (in seconds)" diff --git a/code/nrf-connect/samples/zigbee/prj.conf b/code/nrf-connect/samples/zigbee/prj.conf index 002aa88..4a91f5d 100644 --- a/code/nrf-connect/samples/zigbee/prj.conf +++ b/code/nrf-connect/samples/zigbee/prj.conf @@ -41,8 +41,3 @@ CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI=y # Enable API for powering down unused RAM parts. # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/nrf/ug_zigbee_configuring.html#power-saving-during-sleep CONFIG_RAM_POWER_DOWN_LIBRARY=y - -# Config options in Kconfig. -CONFIG_PRST_ZB_SLEEP_DURATION_SEC=600 -CONFIG_MODEL_ID="Z-Parasite" -CONFIG_BUILD_DATE="20221216" \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/prj_debug.conf b/code/nrf-connect/samples/zigbee/prj_debug.conf index da51b99..a338a75 100644 --- a/code/nrf-connect/samples/zigbee/prj_debug.conf +++ b/code/nrf-connect/samples/zigbee/prj_debug.conf @@ -47,6 +47,3 @@ CONFIG_PRST_ZB_SLEEP_DURATION_SEC=10 CONFIG_LOG_DEFAULT_LEVEL=4 CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL=4 - -CONFIG_MODEL_ID="Z-Parasite" -CONFIG_BUILD_DATE="20221216" From ac8677f3e827010e341bd890a93009ec54cc0212 Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Sun, 18 Dec 2022 17:12:25 +0100 Subject: [PATCH 10/13] Renamed basic cluster attributes to comply with library defaults. --- code/nrf-connect/samples/zigbee/Kconfig | 6 +++--- code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c | 8 ++++---- .../samples/zigbee/src/prst_zb_endpoint_defs.h | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index f60ec56..a2ef6c4 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -8,10 +8,10 @@ config PRST_ZB_PARENT_POLL_INTERVAL_SEC int "Interval for when b-parasite polls its parent for data (in seconds)" default 60 -config BUILD_DATE - string "Zigbee app init basic date code. Can be used as build revision." +config PRST_ZB_BUILD_DATE + string "Zigbee app init basic date code. Can be used as build revision. (1 byte)" default "20221214" -config MODEL_ID +config PRST_ZB_MODEL_ID string "Zigbee app model id." default "b-parasite" \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c index a21ae28..c241458 100644 --- a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c +++ b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c @@ -14,13 +14,13 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) { ZB_ZCL_SET_STRING_VAL( dev_ctx->basic_attr.model_id, - PRST_BASIC_MODEL_ID, - ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MODEL_ID)); + CONFIG_PRST_ZB_MODEL_ID, + ZB_ZCL_STRING_CONST_SIZE(CONFIG_PRST_ZB_MODEL_ID)); ZB_ZCL_SET_STRING_VAL( dev_ctx->basic_attr.date_code, - PRST_BASIC_DATE_CODE, - ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_DATE_CODE)); + CONFIG_PRST_ZB_BUILD_DATE, + ZB_ZCL_STRING_CONST_SIZE(CONFIG_PRST_ZB_BUILD_DATE)); dev_ctx->identify_attr.identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE; diff --git a/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h b/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h index 149c31f..f66f877 100644 --- a/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h +++ b/code/nrf-connect/samples/zigbee/src/prst_zb_endpoint_defs.h @@ -5,8 +5,6 @@ #define PRST_ZIGBEE_ENDPOINT 10 #define PRST_BASIC_MANUF_NAME "b-parasite" -#define PRST_BASIC_MODEL_ID CONFIG_MODEL_ID -#define PRST_BASIC_DATE_CODE CONFIG_BUILD_DATE #define PRST_ZB_DEVICE_ID 0x0008 #define PRST_ZB_DEVICE_VERSION 0 From 580f425b01cafdd821a6f86e9499c16a2088703d Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Sun, 18 Dec 2022 17:15:58 +0100 Subject: [PATCH 11/13] Added hardware version config value. --- code/nrf-connect/samples/zigbee/Kconfig | 6 +++++- code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index a2ef6c4..2dd871a 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -14,4 +14,8 @@ config PRST_ZB_BUILD_DATE config PRST_ZB_MODEL_ID string "Zigbee app model id." - default "b-parasite" \ No newline at end of file + default "b-parasite" + +config PRST_ZB_HARDWARE_VERSION + int "Zigbee basic cluster hardware version. (1 byte)" + default 2 \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c index c241458..74edf74 100644 --- a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c +++ b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c @@ -22,6 +22,8 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) { CONFIG_PRST_ZB_BUILD_DATE, ZB_ZCL_STRING_CONST_SIZE(CONFIG_PRST_ZB_BUILD_DATE)); + dev_ctx->basic_attr.hw_version = CONFIG_PRST_ZB_HARDWARE_VERSION; + dev_ctx->identify_attr.identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE; } From 0f859c77cddf4539ef4050e0997a425da77ab675 Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Sun, 18 Dec 2022 17:27:43 +0100 Subject: [PATCH 12/13] Slightly improved power cluster with more values. --- code/nrf-connect/samples/zigbee/src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index a76b541..522acce 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -82,8 +82,8 @@ ZB_ZCL_DECLARE_REL_HUMIDITY_MEASUREMENT_ATTRIB_LIST( ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT( batt_attr_list, &dev_ctx.batt_attrs.voltage, - /*battery_size=*/NULL, - /*battery_quantity=*/NULL, + /*battery_size=*/ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_OTHER, + /*battery_quantity=*/1, /*battery_rated_voltage=*/NULL, /*battery_alarm_mask=*/NULL, /*battery_voltage_min_threshold=*/NULL, @@ -163,7 +163,7 @@ void update_sensors_cb(zb_uint8_t arg) { return; } - // Battery voltlage in units of 100 mV. + // Battery voltage in units of 100 mV. uint8_t batt_voltage = sensors.batt.adc_read.millivolts / 100; prst_zb_set_attr_value(ZB_ZCL_CLUSTER_ID_POWER_CONFIG, ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID, From 54382e3356ed3453e2b4d7034c6eb58949401a3a Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Sun, 18 Dec 2022 21:23:10 +0100 Subject: [PATCH 13/13] Removed log level config from board definition. Moved prst lib log level config to application layer with prst lib default fallback behaviour. --- .../nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig | 4 ---- .../nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig | 4 ---- code/nrf-connect/prstlib/include/prstlib/macros.h | 4 ++++ code/nrf-connect/samples/zigbee/Kconfig | 4 ++++ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig index 05586ab..a0c83d3 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig @@ -7,7 +7,3 @@ config BOARD_ENABLE_DCDC default y endif # BOARD_BPARASITE_NRF52833 - -config PRSTLIB_DEFAULT_LOG_LEVEL - int "Logging level in core prst library." - default 2 \ No newline at end of file diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig index 45ac075..4ce925f 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig @@ -12,7 +12,3 @@ config BOARD_ENABLE_DCDC_HV default y endif # BOARD_BPARASITE_NRF52840 - -config PRSTLIB_DEFAULT_LOG_LEVEL - int "Logging level in core prst library." - default 2 \ No newline at end of file diff --git a/code/nrf-connect/prstlib/include/prstlib/macros.h b/code/nrf-connect/prstlib/include/prstlib/macros.h index dc3f82f..694d7e6 100644 --- a/code/nrf-connect/prstlib/include/prstlib/macros.h +++ b/code/nrf-connect/prstlib/include/prstlib/macros.h @@ -21,4 +21,8 @@ #define UNUSED_OK(expr) (void)expr; +#ifndef CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL +#define CONFIG_PRSTLIB_DEFAULT_LOG_LEVEL LOG_LEVEL_WRN +#endif + #endif // _PRST_MACROS_H_ \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index 2dd871a..f23bfef 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -8,6 +8,10 @@ config PRST_ZB_PARENT_POLL_INTERVAL_SEC int "Interval for when b-parasite polls its parent for data (in seconds)" default 60 +config PRSTLIB_DEFAULT_LOG_LEVEL + int "Logging level in core prst library. (0: NONE, 2: WARN, 4: DEBUG) See Zephyr logging for more." + default 2 + config PRST_ZB_BUILD_DATE string "Zigbee app init basic date code. Can be used as build revision. (1 byte)" default "20221214"