7#ifndef WEATHER_STATION_H
8#define WEATHER_STATION_H
10#include <zcl/zb_zcl_temp_measurement_addons.h>
15#define ZCL_TEMPERATURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER 100
17#define ZCL_PRESSURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER 10
19#define ZCL_HUMIDITY_MEASUREMENT_MEASURED_VALUE_MULTIPLIER 100
22#define WEATHER_STATION_ATTR_TEMP_MIN ( \
23 SENSOR_TEMP_CELSIUS_MIN * \
24 ZCL_TEMPERATURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
25#define WEATHER_STATION_ATTR_TEMP_MAX ( \
26 SENSOR_TEMP_CELSIUS_MAX * \
27 ZCL_TEMPERATURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
28#define WEATHER_STATION_ATTR_TEMP_TOLERANCE ( \
29 SENSOR_TEMP_CELSIUS_TOLERANCE * \
30 ZCL_TEMPERATURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
31#define WEATHER_STATION_ATTR_PRESSURE_MIN ( \
32 SENSOR_PRESSURE_KPA_MIN * \
33 ZCL_PRESSURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
34#define WEATHER_STATION_ATTR_PRESSURE_MAX ( \
35 SENSOR_PRESSURE_KPA_MAX * \
36 ZCL_PRESSURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
37#define WEATHER_STATION_ATTR_PRESSURE_TOLERANCE ( \
38 SENSOR_PRESSURE_KPA_TOLERANCE * \
39 ZCL_PRESSURE_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
40#define WEATHER_STATION_ATTR_HUMIDITY_MIN ( \
41 SENSOR_HUMIDITY_PERCENT_MIN * \
42 ZCL_HUMIDITY_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
43#define WEATHER_STATION_ATTR_HUMIDITY_MAX ( \
44 SENSOR_HUMIDITY_PERCENT_MAX * \
45 ZCL_HUMIDITY_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
46#define WEATHER_STATION_ATTR_HUMIDITY_TOLERANCE ( \
47 SENSOR_HUMIDITY_PERCENT_TOLERANCE * \
48 ZCL_HUMIDITY_MEASUREMENT_MEASURED_VALUE_MULTIPLIER)
51#define WEATHER_STATION_ENDPOINT_NB 42
54#define ZB_HA_DEVICE_VER_TEMPERATURE_SENSOR 0
56#define ZB_HA_WEATHER_STATION_IN_CLUSTER_NUM 5
58#define ZB_HA_WEATHER_STATION_OUT_CLUSTER_NUM 1
61#define ZB_HA_WEATHER_STATION_REPORT_ATTR_COUNT 3
63#define ZB_HA_DECLARE_WEATHER_STATION_CLUSTER_LIST( \
66 identify_client_attr_list, \
67 identify_server_attr_list, \
68 temperature_measurement_attr_list, \
69 pressure_measurement_attr_list, \
70 humidity_measurement_attr_list \
72 zb_zcl_cluster_desc_t cluster_list_name[] = \
74 ZB_ZCL_CLUSTER_DESC( \
75 ZB_ZCL_CLUSTER_ID_BASIC, \
76 ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t), \
78 ZB_ZCL_CLUSTER_SERVER_ROLE, \
79 ZB_ZCL_MANUF_CODE_INVALID \
81 ZB_ZCL_CLUSTER_DESC( \
82 ZB_ZCL_CLUSTER_ID_IDENTIFY, \
83 ZB_ZCL_ARRAY_SIZE(identify_server_attr_list, zb_zcl_attr_t), \
84 (identify_server_attr_list), \
85 ZB_ZCL_CLUSTER_SERVER_ROLE, \
86 ZB_ZCL_MANUF_CODE_INVALID \
88 ZB_ZCL_CLUSTER_DESC( \
89 ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, \
90 ZB_ZCL_ARRAY_SIZE(temperature_measurement_attr_list, zb_zcl_attr_t), \
91 (temperature_measurement_attr_list), \
92 ZB_ZCL_CLUSTER_SERVER_ROLE, \
93 ZB_ZCL_MANUF_CODE_INVALID \
95 ZB_ZCL_CLUSTER_DESC( \
96 ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, \
97 ZB_ZCL_ARRAY_SIZE(pressure_measurement_attr_list, zb_zcl_attr_t), \
98 (pressure_measurement_attr_list), \
99 ZB_ZCL_CLUSTER_SERVER_ROLE, \
100 ZB_ZCL_MANUF_CODE_INVALID \
102 ZB_ZCL_CLUSTER_DESC( \
103 ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, \
104 ZB_ZCL_ARRAY_SIZE(humidity_measurement_attr_list, zb_zcl_attr_t), \
105 (humidity_measurement_attr_list), \
106 ZB_ZCL_CLUSTER_SERVER_ROLE, \
107 ZB_ZCL_MANUF_CODE_INVALID \
109 ZB_ZCL_CLUSTER_DESC( \
110 ZB_ZCL_CLUSTER_ID_IDENTIFY, \
111 ZB_ZCL_ARRAY_SIZE(identify_client_attr_list, zb_zcl_attr_t), \
112 (identify_client_attr_list), \
113 ZB_ZCL_CLUSTER_CLIENT_ROLE, \
114 ZB_ZCL_MANUF_CODE_INVALID \
118#define ZB_ZCL_DECLARE_WEATHER_STATION_DESC( \
123 ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num); \
124 ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name = \
127 ZB_AF_HA_PROFILE_ID, \
128 ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID, \
129 ZB_HA_DEVICE_VER_TEMPERATURE_SENSOR, \
134 ZB_ZCL_CLUSTER_ID_BASIC, \
135 ZB_ZCL_CLUSTER_ID_IDENTIFY, \
136 ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, \
137 ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, \
138 ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, \
139 ZB_ZCL_CLUSTER_ID_IDENTIFY, \
143#define ZB_HA_DECLARE_WEATHER_STATION_EP(ep_name, ep_id, cluster_list) \
144 ZB_ZCL_DECLARE_WEATHER_STATION_DESC( \
147 ZB_HA_WEATHER_STATION_IN_CLUSTER_NUM, \
148 ZB_HA_WEATHER_STATION_OUT_CLUSTER_NUM); \
149 ZBOSS_DEVICE_DECLARE_REPORTING_CTX( \
150 reporting_info##ep_name, \
151 ZB_HA_WEATHER_STATION_REPORT_ATTR_COUNT); \
152 ZB_AF_DECLARE_ENDPOINT_DESC( \
155 ZB_AF_HA_PROFILE_ID, \
158 ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
160 (zb_af_simple_desc_1_1_t *)&simple_desc_##ep_name, \
161 ZB_HA_WEATHER_STATION_REPORT_ATTR_COUNT, reporting_info##ep_name, 0, NULL)
zb_zcl_identify_attrs_t identify_attr
Definition weather_station.h:178
struct zb_zcl_humidity_measurement_attrs_t humidity_attrs
Definition weather_station.h:181
zb_zcl_basic_attrs_t basic_attr
Definition weather_station.h:177
struct zb_zcl_pressure_measurement_attrs_t pres_attrs
Definition weather_station.h:180
zb_zcl_temp_measurement_attrs_t temp_attrs
Definition weather_station.h:179
Definition weather_station.h:176
zb_int16_t measure_value
Definition weather_station.h:171
zb_int16_t max_measure_value
Definition weather_station.h:173
zb_int16_t min_measure_value
Definition weather_station.h:172
Definition weather_station.h:170
zb_int16_t measure_value
Definition weather_station.h:164
zb_int16_t max_measure_value
Definition weather_station.h:166
zb_int16_t min_measure_value
Definition weather_station.h:165
zb_uint16_t tolerance
Definition weather_station.h:167
Definition weather_station.h:163
int weather_station_update_pressure(void)
Updates ZCL pressure attribute using value obtained during last weather check.
int weather_station_update_temperature(void)
Updates ZCL temperature attribute using value obtained during last weather check.
int weather_station_update_humidity(void)
Updates ZCL relative humidity attribute using value obtained during last weather check.
int weather_station_check_weather(void)
Updates internal measurements performed by sensor.
int weather_station_init(void)
Initializes HW sensor used for performing measurements.