commit
06627ff85d
14 changed files with 101 additions and 29 deletions
|
|
@ -6,4 +6,4 @@ config BOARD_ENABLE_DCDC
|
||||||
select SOC_DCDC_NRF52X
|
select SOC_DCDC_NRF52X
|
||||||
default y
|
default y
|
||||||
|
|
||||||
endif # BOARD_BPARASITE_NRF52833
|
endif # BOARD_BPARASITE_NRF52833
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@ config BOARD_ENABLE_DCDC_HV
|
||||||
select SOC_DCDC_NRF52X_HV
|
select SOC_DCDC_NRF52X_HV
|
||||||
default y
|
default y
|
||||||
|
|
||||||
endif # BOARD_BPARASITE_NRF52840
|
endif # BOARD_BPARASITE_NRF52840
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,8 @@
|
||||||
|
|
||||||
#define UNUSED_OK(expr) (void)expr;
|
#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_
|
#endif // _PRST_MACROS_H_
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "prstlib/macros.h"
|
#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.
|
// PWM spec for square wave. Input to the soil sensing circuit.
|
||||||
static const struct pwm_dt_spec soil_pwm_dt =
|
static const struct pwm_dt_spec soil_pwm_dt =
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "prstlib/led.h"
|
#include "prstlib/led.h"
|
||||||
#include "prstlib/macros.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 =
|
static struct gpio_dt_spec button =
|
||||||
GPIO_DT_SPEC_GET(DT_NODELABEL(button0), gpios);
|
GPIO_DT_SPEC_GET(DT_NODELABEL(button0), gpios);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "prstlib/macros.h"
|
#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);
|
struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "prstlib/led.h"
|
#include "prstlib/led.h"
|
||||||
#include "prstlib/macros.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) {
|
int prst_sensors_read_all(prst_sensors_t *sensors) {
|
||||||
RET_IF_ERR(prst_adc_batt_read(&sensors->batt));
|
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,
|
LOG_DBG("Batt: %d mV (%.2f%%)", sensors->batt.adc_read.millivolts,
|
||||||
100 * sensors->batt.percentage);
|
100 * sensors->batt.percentage);
|
||||||
LOG_DBG("Soil: %.0f %% (%.3f mV)", 100 * sensors->soil.percentage,
|
LOG_DBG("Soil: %.0f %% (%d mV)", 100 * sensors->soil.percentage,
|
||||||
sensors->soil.adc_read.voltage);
|
sensors->soil.adc_read.millivolts);
|
||||||
LOG_DBG("Photo: %u lx (%.3f mV)", sensors->photo.brightness,
|
LOG_DBG("Photo: %u lx (%d mV)", sensors->photo.brightness,
|
||||||
sensors->soil.adc_read.voltage);
|
sensors->soil.adc_read.millivolts);
|
||||||
LOG_DBG("Temp: %f oC", sensors->shtc3.temp_c);
|
LOG_DBG("Temp: %f oC", sensors->shtc3.temp_c);
|
||||||
LOG_DBG("Humi: %.0f %%", 100 * sensors->shtc3.rel_humi);
|
LOG_DBG("Humi: %.0f %%", 100 * sensors->shtc3.rel_humi);
|
||||||
LOG_DBG("--------------------------------------------------");
|
LOG_DBG("--------------------------------------------------");
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "prstlib/macros.h"
|
#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));
|
static const struct i2c_dt_spec shtc3 = I2C_DT_SPEC_GET(DT_NODELABEL(shtc3));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,24 @@ source "Kconfig.zephyr"
|
||||||
|
|
||||||
config PRST_ZB_SLEEP_DURATION_SEC
|
config PRST_ZB_SLEEP_DURATION_SEC
|
||||||
int "Sleep duration between waking up and reading sensors (in seconds)"
|
int "Sleep duration between waking up and reading sensors (in seconds)"
|
||||||
default 60
|
default 600
|
||||||
|
|
||||||
config PRST_ZB_PARENT_POLL_INTERVAL_SEC
|
config PRST_ZB_PARENT_POLL_INTERVAL_SEC
|
||||||
int "Interval for when b-parasite polls its parent for data (in seconds)"
|
int "Interval for when b-parasite polls its parent for data (in seconds)"
|
||||||
default 60
|
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
|
||||||
|
|
@ -41,6 +41,3 @@ CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI=y
|
||||||
# Enable API for powering down unused RAM parts.
|
# 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
|
# 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_RAM_POWER_DOWN_LIBRARY=y
|
||||||
|
|
||||||
# Config options in Kconfig.
|
|
||||||
# CONFIG_PRST_ZB_SLEEP_DURATION_SEC=5
|
|
||||||
|
|
|
||||||
49
code/nrf-connect/samples/zigbee/prj_debug.conf
Normal file
49
code/nrf-connect/samples/zigbee/prj_debug.conf
Normal file
|
|
@ -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
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#define FACTORY_RESET_BUTTON DK_BTN4_MSK
|
#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;
|
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.app_version,
|
||||||
&dev_ctx.basic_attr.stack_version,
|
&dev_ctx.basic_attr.stack_version,
|
||||||
&dev_ctx.basic_attr.hw_version,
|
&dev_ctx.basic_attr.hw_version,
|
||||||
dev_ctx.basic_attr.mf_name,
|
&dev_ctx.basic_attr.mf_name,
|
||||||
dev_ctx.basic_attr.model_id,
|
&dev_ctx.basic_attr.model_id,
|
||||||
dev_ctx.basic_attr.date_code,
|
&dev_ctx.basic_attr.date_code,
|
||||||
&dev_ctx.basic_attr.power_source,
|
&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.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,
|
ZB_ZCL_DECLARE_TEMP_MEASUREMENT_ATTRIB_LIST(temp_measurement_attr_list,
|
||||||
&dev_ctx.temp_measure_attrs.measure_value,
|
&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(
|
ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(
|
||||||
batt_attr_list,
|
batt_attr_list,
|
||||||
&dev_ctx.batt_attrs.voltage,
|
&dev_ctx.batt_attrs.voltage,
|
||||||
/*battery_size=*/NULL,
|
/*battery_size=*/ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_OTHER,
|
||||||
/*battery_quantity=*/NULL,
|
/*battery_quantity=*/1,
|
||||||
/*battery_rated_voltage=*/NULL,
|
/*battery_rated_voltage=*/NULL,
|
||||||
/*battery_alarm_mask=*/NULL,
|
/*battery_alarm_mask=*/NULL,
|
||||||
/*battery_voltage_min_threshold=*/NULL,
|
/*battery_voltage_min_threshold=*/NULL,
|
||||||
|
|
@ -113,7 +113,7 @@ PRST_ZB_DECLARE_CLUSTER_LIST(
|
||||||
identify_attr_list,
|
identify_attr_list,
|
||||||
temp_measurement_attr_list,
|
temp_measurement_attr_list,
|
||||||
rel_humi_attr_list,
|
rel_humi_attr_list,
|
||||||
basic_attr_list,
|
batt_attr_list,
|
||||||
soil_moisture_attr_list,
|
soil_moisture_attr_list,
|
||||||
illuminance_attr_list);
|
illuminance_attr_list);
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ void update_sensors_cb(zb_uint8_t arg) {
|
||||||
return;
|
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;
|
uint8_t batt_voltage = sensors.batt.adc_read.millivolts / 100;
|
||||||
prst_zb_set_attr_value(ZB_ZCL_CLUSTER_ID_POWER_CONFIG,
|
prst_zb_set_attr_value(ZB_ZCL_CLUSTER_ID_POWER_CONFIG,
|
||||||
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID,
|
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID,
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,15 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) {
|
||||||
|
|
||||||
ZB_ZCL_SET_STRING_VAL(
|
ZB_ZCL_SET_STRING_VAL(
|
||||||
dev_ctx->basic_attr.model_id,
|
dev_ctx->basic_attr.model_id,
|
||||||
PRST_BASIC_MODEL_ID,
|
CONFIG_PRST_ZB_MODEL_ID,
|
||||||
ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_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 =
|
dev_ctx->identify_attr.identify_time =
|
||||||
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;
|
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#define PRST_ZIGBEE_ENDPOINT 10
|
#define PRST_ZIGBEE_ENDPOINT 10
|
||||||
#define PRST_BASIC_MANUF_NAME "b-parasite"
|
#define PRST_BASIC_MANUF_NAME "b-parasite"
|
||||||
#define PRST_BASIC_MODEL_ID "b-parasite"
|
|
||||||
|
|
||||||
#define PRST_ZB_DEVICE_ID 0x0008
|
#define PRST_ZB_DEVICE_ID 0x0008
|
||||||
#define PRST_ZB_DEVICE_VERSION 0
|
#define PRST_ZB_DEVICE_VERSION 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue