diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig index b6f2e0e..a0c83d3 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52833/Kconfig @@ -6,4 +6,4 @@ config BOARD_ENABLE_DCDC select SOC_DCDC_NRF52X default y -endif # BOARD_BPARASITE_NRF52833 \ No newline at end of file +endif # BOARD_BPARASITE_NRF52833 diff --git a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig index aa0eeee..4ce925f 100644 --- a/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig +++ b/code/nrf-connect/prstlib/boards/arm/bparasite_nrf52840/Kconfig @@ -11,4 +11,4 @@ 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 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/prstlib/src/adc.c b/code/nrf-connect/prstlib/src/adc.c index 1856f7e..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, LOG_LEVEL_WRN); +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 a27eda2..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, LOG_LEVEL_WRN); +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 415296f..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, LOG_LEVEL_WRN); +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 e0b1ca9..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, LOG_LEVEL_WRN); +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)); @@ -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("--------------------------------------------------"); diff --git a/code/nrf-connect/prstlib/src/shtc3.c b/code/nrf-connect/prstlib/src/shtc3.c index 90cd6ba..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, LOG_LEVEL_WRN); +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/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index f604209..f23bfef 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -2,8 +2,24 @@ 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)" - default 60 \ No newline at end of file + 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" + +config PRST_ZB_MODEL_ID + string "Zigbee app model id." + 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/prj.conf b/code/nrf-connect/samples/zigbee/prj.conf index 552b18f..4a91f5d 100644 --- a/code/nrf-connect/samples/zigbee/prj.conf +++ b/code/nrf-connect/samples/zigbee/prj.conf @@ -41,6 +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=5 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..a338a75 --- /dev/null +++ b/code/nrf-connect/samples/zigbee/prj_debug.conf @@ -0,0 +1,49 @@ + +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_PRSTLIB_DEFAULT_LOG_LEVEL=4 diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index ae08fcb..522acce 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; @@ -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, @@ -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, @@ -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); @@ -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, 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..74edf74 100644 --- a/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c +++ b/code/nrf-connect/samples/zigbee/src/prst_zb_attrs.c @@ -14,8 +14,15 @@ 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, + 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; 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..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,7 +5,6 @@ #define PRST_ZIGBEE_ENDPOINT 10 #define PRST_BASIC_MANUF_NAME "b-parasite" -#define PRST_BASIC_MODEL_ID "b-parasite" #define PRST_ZB_DEVICE_ID 0x0008 #define PRST_ZB_DEVICE_VERSION 0