-
Notifications
You must be signed in to change notification settings - Fork 4
/
zb_multi_sensor.h
205 lines (194 loc) · 12.9 KB
/
zb_multi_sensor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ZB_MULTI_SENSOR_H__
#define ZB_MULTI_SENSOR_H__
#include "zboss_api.h"
#include "zboss_api_addons.h"
#include "zb_zcl_pressure_measurement.h"
#include "zigbee_lacking.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Basic cluster attributes initial values. For more information, see section 3.2.2.2 of the ZCL specification. */
#define SENSOR_INIT_BASIC_APP_VERSION 01 /**< Version of the application software (1 byte). */
#define SENSOR_INIT_BASIC_STACK_VERSION 10 /**< Version of the implementation of the Zigbee stack (1 byte). */
#define SENSOR_INIT_BASIC_HW_VERSION 1 /**< Version of the hardware of the device (1 byte). */
#define SENSOR_INIT_BASIC_MANUF_NAME "nrf52840.ru" /**< Manufacturer name (32 bytes). */
#define SENSOR_INIT_BASIC_MODEL_ID "bme280" /**< Model number assigned by the manufacturer (32-bytes long string). */
#define SENSOR_INIT_BASIC_DATE_CODE "20190922" /**< Date provided by the manufacturer of the device in ISO 8601 format (YYYYMMDD), for the first 8 bytes. The remaining 8 bytes are manufacturer-specific. */
#define SENSOR_INIT_BASIC_POWER_SOURCE ZB_ZCL_BASIC_POWER_SOURCE_BATTERY /**< Type of power source or sources available for the device. For possible values, see section 3.2.2.2.8 of the ZCL specification. */
#define SENSOR_INIT_BASIC_LOCATION_DESC "Office desk" /**< Description of the physical location of the device (16 bytes). You can modify it during the commisioning process. */
#define SENSOR_INIT_BASIC_PH_ENV ZB_ZCL_BASIC_ENV_UNSPECIFIED /**< Description of the type of physical environment. For possible values, see section 3.2.2.2.10 of the ZCL specification. */
#define MULTI_SENSOR_ENDPOINT 10 /**< Device endpoint. Used to receive light controlling commands. */
/* Main application customizable context. Stores all settings and static values. */
typedef struct
{
zb_zcl_basic_attrs_ext_t basic_attr;
zb_zcl_identify_attrs_t identify_attr;
zb_zcl_temp_measurement_attrs_t temp_attr;
zb_zcl_humm_measurement_attrs_t humm_attr;
zb_zcl_pressure_measurement_attrs_t pres_attr;
battery_simplified_attr_t power_attr;
} sensor_device_ctx_t;
#define ZB_MULTI_SENSOR_REPORT_ATTR_COUNT 5
#define ZB_DEVICE_VER_MULTI_SENSOR 0 /**< Multisensor device version. */
#define ZB_MULTI_SENSOR_IN_CLUSTER_NUM 6 /**< Number of the input (server) clusters in the multisensor device. */
#define ZB_MULTI_SENSOR_OUT_CLUSTER_NUM 1 /**< Number of the output (client) clusters in the multisensor device. */
/** @brief Declares cluster list for the multisensor device.
*
* @param cluster_list_name Cluster list variable name.
* @param basic_attr_list Attribute list for the Basic cluster.
* @param identify_attr_list Attribute list for the Identify cluster.
* @param temp_measure_attr_list Attribute list for the Temperature Measurement cluster.
* @param pressure_measure_attr_list Attribute list for the Pressure Measurement cluster.
*/
#define ZB_DECLARE_MULTI_SENSOR_CLUSTER_LIST( \
cluster_list_name, \
basic_attr_list, \
identify_attr_list, \
temp_measure_attr_list, \
humm_measure_attr_list, \
pres_measure_attr_list, \
power_measure_attr_list) \
zb_zcl_cluster_desc_t cluster_list_name[] = \
{ \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t), \
(identify_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_BASIC, \
ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t), \
(basic_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, \
ZB_ZCL_ARRAY_SIZE(temp_measure_attr_list, zb_zcl_attr_t), \
(temp_measure_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, \
ZB_ZCL_ARRAY_SIZE(humm_measure_attr_list, zb_zcl_attr_t), \
(humm_measure_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, \
ZB_ZCL_ARRAY_SIZE(pres_measure_attr_list, zb_zcl_attr_t), \
(pres_measure_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_POWER_CONFIG, \
ZB_ZCL_ARRAY_SIZE(power_measure_attr_list, zb_zcl_attr_t),\
(power_measure_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
0, \
NULL, \
ZB_ZCL_CLUSTER_CLIENT_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
) \
}
/** @brief Declares simple descriptor for the "Device_name" device.
*
* @param ep_name Endpoint variable name.
* @param ep_id Endpoint ID.
* @param in_clust_num Number of the supported input clusters.
* @param out_clust_num Number of the supported output clusters.
*/
#define ZB_ZCL_DECLARE_MULTI_SENSOR_DESC(ep_name, ep_id, in_clust_num, out_clust_num) \
ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num); \
ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name = \
{ \
ep_id, \
ZB_AF_HA_PROFILE_ID, \
ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID, \
ZB_DEVICE_VER_MULTI_SENSOR, \
0, \
in_clust_num, \
out_clust_num, \
{ \
ZB_ZCL_CLUSTER_ID_BASIC, \
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, \
ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, \
ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, \
ZB_ZCL_CLUSTER_ID_POWER_CONFIG, \
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
} \
}
/** @brief Declares endpoint for the multisensor device.
*
* @param ep_name Endpoint variable name.
* @param ep_id Endpoint ID.
* @param cluster_list Endpoint cluster list.
*/
#define ZB_ZCL_DECLARE_MULTI_SENSOR_EP(ep_name, ep_id, cluster_list) \
ZB_ZCL_DECLARE_MULTI_SENSOR_DESC(ep_name, \
ep_id, \
ZB_MULTI_SENSOR_IN_CLUSTER_NUM, \
ZB_MULTI_SENSOR_OUT_CLUSTER_NUM); \
ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name, \
ZB_MULTI_SENSOR_REPORT_ATTR_COUNT); \
ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, \
ZB_AF_HA_PROFILE_ID, \
0, \
NULL, \
ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
cluster_list, \
(zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name, \
ZB_MULTI_SENSOR_REPORT_ATTR_COUNT, reporting_info## device_ctx_name, 0, NULL)
#ifdef __cplusplus
}
#endif
#endif // ZB_MULTI_SENSOR_H__