/src/wireshark/epan/dissectors/packet-zbee-zcl-meas-sensing.c
Line | Count | Source |
1 | | /* packet-zbee-zcl-meas-sensing.c |
2 | | * Dissector routines for the ZigBee ZCL Measurement & Sensing clusters like |
3 | | * Illuminance Measurement, Temperature Measurement ... |
4 | | * By Fabio Tarabelloni <fabio.tarabelloni@reloc.it> |
5 | | * Copyright 2013 RELOC s.r.l. |
6 | | * |
7 | | * Wireshark - Network traffic analyzer |
8 | | * By Gerald Combs <gerald@wireshark.org> |
9 | | * Copyright 1998 Gerald Combs |
10 | | * |
11 | | * SPDX-License-Identifier: GPL-2.0-or-later |
12 | | */ |
13 | | |
14 | | /* Include Files */ |
15 | | #include "config.h" |
16 | | |
17 | | #include <math.h> |
18 | | #include <epan/packet.h> |
19 | | |
20 | | #include <wsutil/utf8_entities.h> |
21 | | |
22 | | #include "packet-zbee.h" |
23 | | #include "packet-zbee-aps.h" |
24 | | #include "packet-zbee-zcl.h" |
25 | | |
26 | | |
27 | | /* ########################################################################## */ |
28 | | /* #### (0x0400) ILLUMINANCE MEASUREMENT CLUSTER ############################ */ |
29 | | /* ########################################################################## */ |
30 | | |
31 | | /*************************/ |
32 | | /* Defines */ |
33 | | /*************************/ |
34 | | |
35 | | #define ZBEE_ZCL_ILLUM_MEAS_NUM_GENERIC_ETT 1 |
36 | | #define ZBEE_ZCL_ILLUM_MEAS_NUM_ETT ZBEE_ZCL_ILLUM_MEAS_NUM_GENERIC_ETT |
37 | | |
38 | | /* Attributes */ |
39 | 196 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MEASURED_VALUE 0x0000 /* Measured Value */ |
40 | 14 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_MEASURED_VALUE 0x0001 /* Min Measured Value */ |
41 | 17 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_MEASURED_VALUE 0x0002 /* Max Measured Value */ |
42 | 12 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOLERANCE 0x0003 /* Tolerance */ |
43 | 22 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_LIGHT_SENSOR_TYPE 0x0004 /* Light Sensor Type */ |
44 | | |
45 | | /* Server Commands Received - None */ |
46 | | |
47 | | /* Server Commands Generated - None */ |
48 | | |
49 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOO_LOW_VALUE 0x0000 /* Too Low Value */ |
50 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_INVALID_VALUE 0x8000 /* Invalid Value */ |
51 | | |
52 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_LO_VALUE 0x0002 /* Minimum Value (Low Bound) */ |
53 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_HI_VALUE 0xfffd /* Minimum Value (High Bound) */ |
54 | | |
55 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_LO_VALUE 0x0001 /* Maximum Value (Low Bound) */ |
56 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_HI_VALUE 0xfffe /* Maximum Value (High Bound) */ |
57 | | |
58 | | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOL_LO_VALUE 0x0000 /* Tolerance (Low Bound) */ |
59 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOL_HI_VALUE 0x0800 /* Tolerance (Low Bound) */ |
60 | | |
61 | | #define ZBEE_ZCL_ILLUM_MEAS_SENSOR_TYPE_PHOTODIODE 0x00 /* Photodiode */ |
62 | | #define ZBEE_ZCL_ILLUM_MEAS_SENSOR_TYPE_CMOS 0x01 /* CMOS */ |
63 | | |
64 | | /*************************/ |
65 | | /* Function Declarations */ |
66 | | /*************************/ |
67 | | |
68 | | void proto_register_zbee_zcl_illum_meas(void); |
69 | | void proto_reg_handoff_zbee_zcl_illum_meas(void); |
70 | | |
71 | | /* Private functions prototype */ |
72 | | static void decode_illum_meas_value (char *s, uint16_t value); |
73 | | static void decode_illum_meas_min_value (char *s, uint16_t value); |
74 | | static void decode_illum_meas_max_value (char *s, uint16_t value); |
75 | | static void decode_illum_meas_tolerance (char *s, uint16_t value); |
76 | | |
77 | | /*************************/ |
78 | | /* Global Variables */ |
79 | | /*************************/ |
80 | | |
81 | | /* Initialize the protocol and registered fields */ |
82 | | static int proto_zbee_zcl_illum_meas; |
83 | | |
84 | | static int hf_zbee_zcl_illum_meas_attr_id; |
85 | | static int hf_zbee_zcl_illum_meas_measured_value; |
86 | | static int hf_zbee_zcl_illum_meas_min_measured_value; |
87 | | static int hf_zbee_zcl_illum_meas_max_measured_value; |
88 | | static int hf_zbee_zcl_illum_meas_tolerance; |
89 | | static int hf_zbee_zcl_illum_meas_sensor_type; |
90 | | |
91 | | /* Initialize the subtree pointers */ |
92 | | static int ett_zbee_zcl_illum_meas; |
93 | | |
94 | | /* Attributes */ |
95 | | static const value_string zbee_zcl_illum_meas_attr_names[] = { |
96 | | { ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MEASURED_VALUE, "Measured Value" }, |
97 | | { ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_MEASURED_VALUE, "Min Measured Value" }, |
98 | | { ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_MEASURED_VALUE, "Max Measured Value" }, |
99 | | { ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOLERANCE, "Tolerance" }, |
100 | | { ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_LIGHT_SENSOR_TYPE, "Light Sensor Type" }, |
101 | | { 0, NULL } |
102 | | }; |
103 | | |
104 | | static const value_string zbee_zcl_illum_meas_sensor_type_names[] = { |
105 | | { ZBEE_ZCL_ILLUM_MEAS_SENSOR_TYPE_PHOTODIODE, "Photodiode" }, |
106 | | { ZBEE_ZCL_ILLUM_MEAS_SENSOR_TYPE_CMOS, "CMOS" }, |
107 | | { 0, NULL } |
108 | | }; |
109 | | |
110 | | /*************************/ |
111 | | /* Function Bodies */ |
112 | | /*************************/ |
113 | | |
114 | | /** |
115 | | *ZigBee ZCL Illuminance Measurement cluster dissector for wireshark. |
116 | | * |
117 | | *@param tvb pointer to buffer containing raw packet. |
118 | | *@param pinfo pointer to packet information fields |
119 | | *@param tree pointer to data tree Wireshark uses to display packet. |
120 | | */ |
121 | | static int |
122 | | dissect_zbee_zcl_illum_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
123 | 2 | { |
124 | 2 | return tvb_captured_length(tvb); |
125 | 2 | } /*dissect_zbee_zcl_illum_meas*/ |
126 | | |
127 | | /** |
128 | | *This function is called by ZCL foundation dissector in order to decode |
129 | | * |
130 | | *@param tree pointer to data tree Wireshark uses to display packet. |
131 | | *@param tvb pointer to buffer containing raw packet. |
132 | | *@param offset pointer to buffer offset |
133 | | *@param attr_id attribute identifier |
134 | | *@param data_type attribute data type |
135 | | *@param client_attr ZCL client |
136 | | */ |
137 | | static void |
138 | | dissect_zcl_illum_meas_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
139 | 936 | { |
140 | | /* Dissect attribute data type and data */ |
141 | 936 | switch ( attr_id ) { |
142 | | |
143 | 196 | case ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MEASURED_VALUE: |
144 | 196 | proto_tree_add_item(tree, hf_zbee_zcl_illum_meas_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
145 | 196 | *offset += 2; |
146 | 196 | break; |
147 | | |
148 | 14 | case ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_MEASURED_VALUE: |
149 | 14 | proto_tree_add_item(tree, hf_zbee_zcl_illum_meas_min_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
150 | 14 | *offset += 2; |
151 | 14 | break; |
152 | | |
153 | 17 | case ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_MEASURED_VALUE: |
154 | 17 | proto_tree_add_item(tree, hf_zbee_zcl_illum_meas_max_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
155 | 17 | *offset += 2; |
156 | 17 | break; |
157 | | |
158 | 12 | case ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOLERANCE: |
159 | 12 | proto_tree_add_item(tree, hf_zbee_zcl_illum_meas_tolerance, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
160 | 12 | *offset += 2; |
161 | 12 | break; |
162 | | |
163 | 22 | case ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_LIGHT_SENSOR_TYPE: |
164 | 22 | proto_tree_add_item(tree, hf_zbee_zcl_illum_meas_sensor_type, tvb, *offset, 1, ENC_LITTLE_ENDIAN); |
165 | 22 | *offset += 1; |
166 | 22 | break; |
167 | | |
168 | 675 | default: |
169 | 675 | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
170 | 675 | break; |
171 | 936 | } |
172 | 936 | } /*dissect_zcl_illum_meas_attr_data*/ |
173 | | |
174 | | /** |
175 | | *This function decodes illuminance value |
176 | | * |
177 | | *@param s string to display |
178 | | *@param value value to decode |
179 | | */ |
180 | | static void |
181 | | decode_illum_meas_value(char *s, uint16_t value) |
182 | 0 | { |
183 | 0 | if (value == ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOO_LOW_VALUE) |
184 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Value too low to be measured"); |
185 | 0 | else if (value == ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_INVALID_VALUE) |
186 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Invalid value"); |
187 | 0 | else |
188 | | /* calculate lux value from measured value according to doc 07-5123-04 */ |
189 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [lx])", value, pow(10,value/10000.0)-1); |
190 | |
|
191 | 0 | return; |
192 | 0 | } /*decode_illum_meas_value*/ |
193 | | |
194 | | /** |
195 | | *This function decodes minimum illuminance value |
196 | | * |
197 | | *@param s string to display |
198 | | *@param value value to decode |
199 | | */ |
200 | | static void |
201 | | decode_illum_meas_min_value(char *s, uint16_t value) |
202 | 0 | { |
203 | 0 | if ( (value < ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_LO_VALUE) || |
204 | 0 | (value > ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MIN_HI_VALUE) ) |
205 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
206 | 0 | else |
207 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [lx])", value, pow(10,value/10000.0)-1); |
208 | |
|
209 | 0 | return; |
210 | 0 | } /*decode_illum_meas_min_value*/ |
211 | | |
212 | | /** |
213 | | *This function decodes maximum illuminance value |
214 | | * |
215 | | *@param s string to display |
216 | | *@param value value to decode |
217 | | */ |
218 | | static void |
219 | | decode_illum_meas_max_value(char *s, uint16_t value) |
220 | 0 | { |
221 | 0 | if ( (value < ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_LO_VALUE) || |
222 | 0 | (value > ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_MAX_HI_VALUE) ) |
223 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
224 | 0 | else |
225 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [lx])", value, pow(10,value/10000.0)-1); |
226 | |
|
227 | 0 | return; |
228 | 0 | } /*decode_illum_meas_max_value*/ |
229 | | |
230 | | /** |
231 | | *This function decodes tolerance value |
232 | | * |
233 | | *@param s string to display |
234 | | *@param value value to decode |
235 | | */ |
236 | | static void |
237 | | decode_illum_meas_tolerance(char *s, uint16_t value) |
238 | 0 | { |
239 | 0 | if (value > ZBEE_ZCL_ATTR_ID_ILLUM_MEAS_TOL_HI_VALUE) |
240 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
241 | 0 | else |
242 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d", value); |
243 | |
|
244 | 0 | return; |
245 | 0 | } /*decode_illum_meas_tolerance*/ |
246 | | |
247 | | /** |
248 | | *This function registers the ZCL Illuminance Measurement dissector |
249 | | * |
250 | | */ |
251 | | void |
252 | | proto_register_zbee_zcl_illum_meas(void) |
253 | 14 | { |
254 | 14 | static hf_register_info hf[] = { |
255 | | |
256 | 14 | { &hf_zbee_zcl_illum_meas_attr_id, |
257 | 14 | { "Attribute", "zbee_zcl_meas_sensing.illummeas.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_illum_meas_attr_names), |
258 | 14 | 0x0, NULL, HFILL } }, |
259 | | |
260 | 14 | { &hf_zbee_zcl_illum_meas_measured_value, |
261 | 14 | { "Measured Value", "zbee_zcl_meas_sensing.illummeas.attr.value", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_illum_meas_value), |
262 | 14 | 0x0, NULL, HFILL } }, |
263 | | |
264 | 14 | { &hf_zbee_zcl_illum_meas_min_measured_value, |
265 | 14 | { "Min Measured Value", "zbee_zcl_meas_sensing.illummeas.attr.value.min", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_illum_meas_min_value), |
266 | 14 | 0x0, NULL, HFILL } }, |
267 | | |
268 | 14 | { &hf_zbee_zcl_illum_meas_max_measured_value, |
269 | 14 | { "Max Measured Value", "zbee_zcl_meas_sensing.illummeas.attr.value.max", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_illum_meas_max_value), |
270 | 14 | 0x0, NULL, HFILL } }, |
271 | | |
272 | 14 | { &hf_zbee_zcl_illum_meas_tolerance, |
273 | 14 | { "Tolerance", "zbee_zcl_meas_sensing.illummeas.attr.tolerance", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_illum_meas_tolerance), |
274 | 14 | 0x0, NULL, HFILL } }, |
275 | | |
276 | 14 | { &hf_zbee_zcl_illum_meas_sensor_type, |
277 | 14 | { "Sensor Type", "zbee_zcl_meas_sensing.illummeas.attr.sensor_type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_illum_meas_sensor_type_names), |
278 | 14 | 0x0, NULL, HFILL } } |
279 | 14 | }; |
280 | | |
281 | | /* ZCL Illuminance Measurement subtrees */ |
282 | 14 | int *ett[] = { |
283 | 14 | &ett_zbee_zcl_illum_meas |
284 | 14 | }; |
285 | | |
286 | | /* Register the ZigBee ZCL Illuminance Measurement cluster protocol name and description */ |
287 | 14 | proto_zbee_zcl_illum_meas = proto_register_protocol("ZigBee ZCL Illuminance Meas.", "ZCL Illuminance Meas.", ZBEE_PROTOABBREV_ZCL_ILLUMMEAS); |
288 | 14 | proto_register_field_array(proto_zbee_zcl_illum_meas, hf, array_length(hf)); |
289 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
290 | | |
291 | | /* Register the ZigBee ZCL Illuminance Measurement dissector. */ |
292 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_ILLUMMEAS, dissect_zbee_zcl_illum_meas, proto_zbee_zcl_illum_meas); |
293 | | |
294 | 14 | } /*proto_register_zbee_zcl_illum_meas*/ |
295 | | |
296 | | |
297 | | /** |
298 | | *Hands off the ZCL Illuminance Measurement dissector. |
299 | | * |
300 | | */ |
301 | | void |
302 | | proto_reg_handoff_zbee_zcl_illum_meas(void) |
303 | 14 | { |
304 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_ILLUMMEAS, |
305 | 14 | proto_zbee_zcl_illum_meas, |
306 | 14 | ett_zbee_zcl_illum_meas, |
307 | 14 | ZBEE_ZCL_CID_ILLUMINANCE_MEASUREMENT, |
308 | 14 | ZBEE_MFG_CODE_NONE, |
309 | 14 | hf_zbee_zcl_illum_meas_attr_id, |
310 | 14 | hf_zbee_zcl_illum_meas_attr_id, |
311 | 14 | -1, -1, |
312 | 14 | dissect_zcl_illum_meas_attr_data |
313 | 14 | ); |
314 | 14 | } /*proto_reg_handoff_zbee_zcl_illum_meas*/ |
315 | | |
316 | | |
317 | | /* ########################################################################## */ |
318 | | /* #### (0x0401) ILLUMINANCE LEVEL SENSING CLUSTER ########################## */ |
319 | | /* ########################################################################## */ |
320 | | |
321 | | /*************************/ |
322 | | /* Defines */ |
323 | | /*************************/ |
324 | | |
325 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_NUM_GENERIC_ETT 1 |
326 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_NUM_ETT ZBEE_ZCL_ILLUM_LEVEL_SEN_NUM_GENERIC_ETT |
327 | | |
328 | | /* Attributes */ |
329 | 189 | #define ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_LEVEL_STATUS 0x0000 /* Level Status */ |
330 | 12 | #define ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_LIGHT_SENSOR_TYPE 0x0001 /* Light Sensor Type */ |
331 | 11 | #define ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_ILLUM_TARGET_LEVEL 0x0010 /* Illuminance Target Level */ |
332 | | |
333 | | /* Server Commands Received - None */ |
334 | | |
335 | | /* Server Commands Generated - None */ |
336 | | |
337 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_TOO_LOW_VALUE 0x0000 /* Too Low Value */ |
338 | 0 | #define ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_INVALID_VALUE 0x8000 /* Invalid Value */ |
339 | | |
340 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_SENSOR_TYPE_PHOTODIODE 0x00 /* Photodiode */ |
341 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_SENSOR_TYPE_CMOS 0x01 /* CMOS */ |
342 | | |
343 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_ILLUM_ON_TARGET 0x00 /* Illuminance on Target */ |
344 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_ILLUM_BELOW_TARGET 0x01 /* Illuminance below Target */ |
345 | | #define ZBEE_ZCL_ILLUM_LEVEL_SEN_ILLUM_ABOVE_TARGET 0x02 /* Illuminance above Target */ |
346 | | |
347 | | /*************************/ |
348 | | /* Function Declarations */ |
349 | | /*************************/ |
350 | | |
351 | | void proto_register_zbee_zcl_illum_level_sen(void); |
352 | | void proto_reg_handoff_zbee_zcl_illum_level_sen(void); |
353 | | |
354 | | /* Private functions prototype */ |
355 | | static void decode_illum_level_sen_target_level (char *s, uint16_t value); |
356 | | |
357 | | /*************************/ |
358 | | /* Global Variables */ |
359 | | /*************************/ |
360 | | |
361 | | /* Initialize the protocol and registered fields */ |
362 | | static int proto_zbee_zcl_illum_level_sen; |
363 | | |
364 | | static int hf_zbee_zcl_illum_level_sen_attr_id; |
365 | | static int hf_zbee_zcl_illum_level_sen_level_status; |
366 | | static int hf_zbee_zcl_illum_level_sen_light_sensor_type; |
367 | | static int hf_zbee_zcl_illum_level_sen_illum_target_level; |
368 | | |
369 | | /* Initialize the subtree pointers */ |
370 | | static int ett_zbee_zcl_illum_level_sen; |
371 | | |
372 | | /* Attributes */ |
373 | | static const value_string zbee_zcl_illum_level_sen_attr_names[] = { |
374 | | { ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_LEVEL_STATUS, "Level Status" }, |
375 | | { ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_LIGHT_SENSOR_TYPE, "Light Sensor Type" }, |
376 | | { ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_ILLUM_TARGET_LEVEL, "Illuminance Target Level" }, |
377 | | { 0, NULL } |
378 | | }; |
379 | | |
380 | | static const value_string zbee_zcl_illum_level_sen_sensor_type_names[] = { |
381 | | { ZBEE_ZCL_ILLUM_LEVEL_SEN_SENSOR_TYPE_PHOTODIODE, "Photodiode" }, |
382 | | { ZBEE_ZCL_ILLUM_LEVEL_SEN_SENSOR_TYPE_CMOS, "CMOS" }, |
383 | | { 0, NULL } |
384 | | }; |
385 | | |
386 | | static const value_string zbee_zcl_illum_level_sen_level_status_names[] = { |
387 | | { ZBEE_ZCL_ILLUM_LEVEL_SEN_ILLUM_ON_TARGET, "Illuminance on Target" }, |
388 | | { ZBEE_ZCL_ILLUM_LEVEL_SEN_ILLUM_BELOW_TARGET, "Illuminance below Target" }, |
389 | | { ZBEE_ZCL_ILLUM_LEVEL_SEN_ILLUM_ABOVE_TARGET, "Illuminance above Target" }, |
390 | | { 0, NULL } |
391 | | }; |
392 | | |
393 | | /*************************/ |
394 | | /* Function Bodies */ |
395 | | /*************************/ |
396 | | |
397 | | /** |
398 | | *ZigBee ZCL Illuminance Level Sensing cluster dissector for wireshark. |
399 | | * |
400 | | *@param tvb pointer to buffer containing raw packet. |
401 | | *@param pinfo pointer to packet information fields |
402 | | *@param tree pointer to data tree Wireshark uses to display packet. |
403 | | */ |
404 | | static int |
405 | | dissect_zbee_zcl_illum_level_sen(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
406 | 1 | { |
407 | 1 | return tvb_captured_length(tvb); |
408 | 1 | } /*dissect_zbee_zcl_illum_level_sen*/ |
409 | | |
410 | | /** |
411 | | *This function is called by ZCL foundation dissector in order to decode |
412 | | * |
413 | | *@param tree pointer to data tree Wireshark uses to display packet. |
414 | | *@param tvb pointer to buffer containing raw packet. |
415 | | *@param offset pointer to buffer offset |
416 | | *@param attr_id attribute identifier |
417 | | *@param data_type attribute data type |
418 | | *@param client_attr ZCL client |
419 | | */ |
420 | | static void |
421 | | dissect_zcl_illum_level_sen_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
422 | 988 | { |
423 | | /* Dissect attribute data type and data */ |
424 | 988 | switch ( attr_id ) { |
425 | | |
426 | 189 | case ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_LEVEL_STATUS: |
427 | 189 | proto_tree_add_item(tree, hf_zbee_zcl_illum_level_sen_level_status, tvb, *offset, 1, ENC_LITTLE_ENDIAN); |
428 | 189 | *offset += 1; |
429 | 189 | break; |
430 | | |
431 | 12 | case ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_LIGHT_SENSOR_TYPE: |
432 | 12 | proto_tree_add_item(tree, hf_zbee_zcl_illum_level_sen_light_sensor_type, tvb, *offset, 1, ENC_LITTLE_ENDIAN); |
433 | 12 | *offset += 1; |
434 | 12 | break; |
435 | | |
436 | 11 | case ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_ILLUM_TARGET_LEVEL: |
437 | 11 | proto_tree_add_item(tree, hf_zbee_zcl_illum_level_sen_illum_target_level, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
438 | 11 | *offset += 2; |
439 | 11 | break; |
440 | | |
441 | 776 | default: |
442 | 776 | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
443 | 776 | break; |
444 | 988 | } |
445 | 988 | } /*dissect_zcl_illum_level_sen_attr_data*/ |
446 | | |
447 | | /** |
448 | | *This function decodes illuminance value |
449 | | * |
450 | | *@param s string to display |
451 | | *@param value value to decode |
452 | | */ |
453 | | static void |
454 | | decode_illum_level_sen_target_level(char *s, uint16_t value) |
455 | 0 | { |
456 | 0 | if (value == ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_TOO_LOW_VALUE) |
457 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Value too low to be measured"); |
458 | 0 | else if (value == ZBEE_ZCL_ATTR_ID_ILLUM_LEVEL_SEN_INVALID_VALUE) |
459 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Invalid value"); |
460 | 0 | else |
461 | | /* calculate lux value from measured value according to doc 07-5123-04 */ |
462 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [lx])", value, pow(10,value/10000.0)-1); |
463 | |
|
464 | 0 | return; |
465 | 0 | } /*decode_illum_level_sen_value*/ |
466 | | |
467 | | /** |
468 | | *This function registers the ZCL Illuminance Level Sensing dissector |
469 | | * |
470 | | */ |
471 | | void |
472 | | proto_register_zbee_zcl_illum_level_sen(void) |
473 | 14 | { |
474 | 14 | static hf_register_info hf[] = { |
475 | | |
476 | 14 | { &hf_zbee_zcl_illum_level_sen_attr_id, |
477 | 14 | { "Attribute", "zbee_zcl_meas_sensing.illumlevelsen.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_illum_level_sen_attr_names), |
478 | 14 | 0x0, NULL, HFILL } }, |
479 | | |
480 | 14 | { &hf_zbee_zcl_illum_level_sen_level_status, |
481 | 14 | { "Level Status", "zbee_zcl_meas_sensing.illumlevelsen.attr.level_status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_illum_level_sen_level_status_names), |
482 | 14 | 0x0, NULL, HFILL } }, |
483 | | |
484 | 14 | { &hf_zbee_zcl_illum_level_sen_light_sensor_type, |
485 | 14 | { "Light Sensor Type", "zbee_zcl_meas_sensing.illumlevelsen.attr.light_sensor_type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_illum_level_sen_sensor_type_names), |
486 | 14 | 0x0, NULL, HFILL } }, |
487 | | |
488 | 14 | { &hf_zbee_zcl_illum_level_sen_illum_target_level, |
489 | 14 | { "Target Level", "zbee_zcl_meas_sensing.illumlevelsen.attr.target_level", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_illum_level_sen_target_level), |
490 | 14 | 0x0, NULL, HFILL } } |
491 | 14 | }; |
492 | | |
493 | | /* ZCL Illuminance Level Sensing subtrees */ |
494 | 14 | int *ett[] = { |
495 | 14 | &ett_zbee_zcl_illum_level_sen |
496 | 14 | }; |
497 | | |
498 | | /* Register the ZigBee ZCL Illuminance Level Sensing cluster protocol name and description */ |
499 | 14 | proto_zbee_zcl_illum_level_sen = proto_register_protocol("ZigBee ZCL Illuminance Level Sensing", "ZCL Illuminance Level Sensing", ZBEE_PROTOABBREV_ZCL_ILLUMLEVELSEN); |
500 | 14 | proto_register_field_array(proto_zbee_zcl_illum_level_sen, hf, array_length(hf)); |
501 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
502 | | |
503 | | /* Register the ZigBee ZCL Illuminance Level Sensing dissector. */ |
504 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_ILLUMLEVELSEN, dissect_zbee_zcl_illum_level_sen, proto_zbee_zcl_illum_level_sen); |
505 | | |
506 | 14 | } /*proto_register_zbee_zcl_illum_level_sen*/ |
507 | | |
508 | | |
509 | | /** |
510 | | *Hands off the ZCL Illuminance Level Sensing dissector. |
511 | | * |
512 | | */ |
513 | | void |
514 | | proto_reg_handoff_zbee_zcl_illum_level_sen(void) |
515 | 14 | { |
516 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_ILLUMLEVELSEN, |
517 | 14 | proto_zbee_zcl_illum_level_sen, |
518 | 14 | ett_zbee_zcl_illum_level_sen, |
519 | 14 | ZBEE_ZCL_CID_ILLUMINANCE_LEVEL_SENSING, |
520 | 14 | ZBEE_MFG_CODE_NONE, |
521 | 14 | hf_zbee_zcl_illum_level_sen_attr_id, |
522 | 14 | hf_zbee_zcl_illum_level_sen_attr_id, |
523 | 14 | -1, -1, |
524 | 14 | dissect_zcl_illum_level_sen_attr_data |
525 | 14 | ); |
526 | 14 | } /*proto_reg_handoff_zbee_zcl_illum_level_sen*/ |
527 | | |
528 | | |
529 | | |
530 | | /* ########################################################################## */ |
531 | | /* #### (0x0402) TEMPERATURE MEASUREMENT CLUSTER ############################ */ |
532 | | /* ########################################################################## */ |
533 | | |
534 | | /*************************/ |
535 | | /* Defines */ |
536 | | /*************************/ |
537 | | |
538 | | #define ZBEE_ZCL_TEMP_MEAS_NUM_GENERIC_ETT 1 |
539 | | #define ZBEE_ZCL_TEMP_MEAS_NUM_ETT ZBEE_ZCL_TEMP_MEAS_NUM_GENERIC_ETT |
540 | | |
541 | | /* Attributes */ |
542 | 249 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MEASURED_VALUE 0x0000 /* Measured Value */ |
543 | 23 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_MEASURED_VALUE 0x0001 /* Min Measured Value */ |
544 | 25 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MAX_MEASURED_VALUE 0x0002 /* Max Measured Value */ |
545 | 10 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_TOLERANCE 0x0003 /* Tolerance */ |
546 | | |
547 | | /* Server Commands Received - None */ |
548 | | |
549 | | /* Server Commands Generated - None */ |
550 | | |
551 | 0 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_INVALID_VALUE 0x8000 /* Invalid Value */ |
552 | | |
553 | 0 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_LO_VALUE 0x954d /* Minimum Value (Low Bound) */ |
554 | 0 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_HI_VALUE 0x7ffe /* Minimum Value (High Bound) */ |
555 | | |
556 | 0 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MAX_LO_VALUE 0x954e /* Maximum Value (Low Bound) */ |
557 | | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MAX_HI_VALUE 0x7fff /* Maximum Value (High Bound) */ |
558 | | |
559 | | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_TOL_LO_VALUE 0x0000 /* Tolerance (Low Bound) */ |
560 | 0 | #define ZBEE_ZCL_ATTR_ID_TEMP_MEAS_TOL_HI_VALUE 0x0800 /* Tolerance (Low Bound) */ |
561 | | |
562 | | /*************************/ |
563 | | /* Function Declarations */ |
564 | | /*************************/ |
565 | | |
566 | | void proto_register_zbee_zcl_temp_meas(void); |
567 | | void proto_reg_handoff_zbee_zcl_temp_meas(void); |
568 | | |
569 | | /* Private functions prototype */ |
570 | | static void decode_temp_meas_value (char *s, int16_t value); |
571 | | static void decode_temp_meas_min_value (char *s, int16_t value); |
572 | | static void decode_temp_meas_max_value (char *s, int16_t value); |
573 | | static void decode_temp_meas_tolerance (char *s, uint16_t value); |
574 | | |
575 | | /*************************/ |
576 | | /* Global Variables */ |
577 | | /*************************/ |
578 | | |
579 | | /* Initialize the protocol and registered fields */ |
580 | | static int proto_zbee_zcl_temp_meas; |
581 | | |
582 | | static int hf_zbee_zcl_temp_meas_attr_id; |
583 | | static int hf_zbee_zcl_temp_meas_measured_value; |
584 | | static int hf_zbee_zcl_temp_meas_min_measured_value; |
585 | | static int hf_zbee_zcl_temp_meas_max_measured_value; |
586 | | static int hf_zbee_zcl_temp_meas_tolerance; |
587 | | |
588 | | /* Initialize the subtree pointers */ |
589 | | static int ett_zbee_zcl_temp_meas; |
590 | | |
591 | | /* Attributes */ |
592 | | static const value_string zbee_zcl_temp_meas_attr_names[] = { |
593 | | { ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MEASURED_VALUE, "Measured Value" }, |
594 | | { ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_MEASURED_VALUE, "Min Measured Value" }, |
595 | | { ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MAX_MEASURED_VALUE, "Max Measured Value" }, |
596 | | { ZBEE_ZCL_ATTR_ID_TEMP_MEAS_TOLERANCE, "Tolerance" }, |
597 | | { 0, NULL } |
598 | | }; |
599 | | |
600 | | /*************************/ |
601 | | /* Function Bodies */ |
602 | | /*************************/ |
603 | | |
604 | | /** |
605 | | *ZigBee ZCL Temperature Measurement cluster dissector for wireshark. |
606 | | * |
607 | | *@param tvb pointer to buffer containing raw packet. |
608 | | *@param pinfo pointer to packet information fields |
609 | | *@param tree pointer to data tree Wireshark uses to display packet. |
610 | | */ |
611 | | static int |
612 | | dissect_zbee_zcl_temp_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
613 | 1 | { |
614 | 1 | return tvb_captured_length(tvb); |
615 | 1 | } /*dissect_zbee_zcl_temp_meas*/ |
616 | | |
617 | | /** |
618 | | *This function is called by ZCL foundation dissector in order to decode |
619 | | * |
620 | | *@param tree pointer to data tree Wireshark uses to display packet. |
621 | | *@param tvb pointer to buffer containing raw packet. |
622 | | *@param offset pointer to buffer offset |
623 | | *@param attr_id attribute identifier |
624 | | *@param data_type attribute data type |
625 | | *@param client_attr ZCL client |
626 | | */ |
627 | | static void |
628 | | dissect_zcl_temp_meas_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
629 | 1.41k | { |
630 | | /* Dissect attribute data type and data */ |
631 | 1.41k | switch ( attr_id ) { |
632 | | |
633 | 249 | case ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MEASURED_VALUE: |
634 | 249 | proto_tree_add_item(tree, hf_zbee_zcl_temp_meas_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
635 | 249 | *offset += 2; |
636 | 249 | break; |
637 | | |
638 | 23 | case ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_MEASURED_VALUE: |
639 | 23 | proto_tree_add_item(tree, hf_zbee_zcl_temp_meas_min_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
640 | 23 | *offset += 2; |
641 | 23 | break; |
642 | | |
643 | 25 | case ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MAX_MEASURED_VALUE: |
644 | 25 | proto_tree_add_item(tree, hf_zbee_zcl_temp_meas_max_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
645 | 25 | *offset += 2; |
646 | 25 | break; |
647 | | |
648 | 10 | case ZBEE_ZCL_ATTR_ID_TEMP_MEAS_TOLERANCE: |
649 | 10 | proto_tree_add_item(tree, hf_zbee_zcl_temp_meas_tolerance, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
650 | 10 | *offset += 2; |
651 | 10 | break; |
652 | | |
653 | 1.10k | default: |
654 | 1.10k | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
655 | 1.10k | break; |
656 | 1.41k | } |
657 | | |
658 | 1.41k | } /*dissect_zcl_temp_meas_attr_data*/ |
659 | | |
660 | | /** |
661 | | *This function decodes temperature value |
662 | | * |
663 | | *@param s string to display |
664 | | *@param value value to decode |
665 | | */ |
666 | | static void |
667 | | decode_temp_meas_value(char *s, int16_t value) |
668 | 0 | { |
669 | 0 | if (value == (int16_t)ZBEE_ZCL_ATTR_ID_TEMP_MEAS_INVALID_VALUE) |
670 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Invalid value"); |
671 | 0 | else |
672 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%.2f [" UTF8_DEGREE_SIGN "C]", value/100.0); |
673 | |
|
674 | 0 | return; |
675 | 0 | } /*decode_temp_meas_value*/ |
676 | | |
677 | | /** |
678 | | *This function decodes minimum temperature value |
679 | | * |
680 | | *@param s string to display |
681 | | *@param value value to decode |
682 | | */ |
683 | | static void |
684 | | decode_temp_meas_min_value(char *s, int16_t value) |
685 | 0 | { |
686 | 0 | if ( (value < (int16_t)ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_LO_VALUE) || |
687 | 0 | (value > (int16_t)ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MIN_HI_VALUE) ) |
688 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
689 | 0 | else |
690 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%.2f [" UTF8_DEGREE_SIGN "C]", value/100.0); |
691 | |
|
692 | 0 | return; |
693 | 0 | } /*decode_temp_meas_min_value*/ |
694 | | |
695 | | /** |
696 | | *This function decodes maximum temperature value |
697 | | * |
698 | | *@param s string to display |
699 | | *@param value value to decode |
700 | | */ |
701 | | static void |
702 | | decode_temp_meas_max_value(char *s, int16_t value) |
703 | 0 | { |
704 | 0 | if (value < (int16_t)ZBEE_ZCL_ATTR_ID_TEMP_MEAS_MAX_LO_VALUE) |
705 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
706 | 0 | else |
707 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%.2f [" UTF8_DEGREE_SIGN "C]", value/100.0); |
708 | |
|
709 | 0 | return; |
710 | 0 | } /*decode_temp_meas_max_value*/ |
711 | | |
712 | | /** |
713 | | *This function decodes tolerance value |
714 | | * |
715 | | *@param s string to display |
716 | | *@param value value to decode |
717 | | */ |
718 | | static void |
719 | | decode_temp_meas_tolerance(char *s, uint16_t value) |
720 | 0 | { |
721 | 0 | if (value > ZBEE_ZCL_ATTR_ID_TEMP_MEAS_TOL_HI_VALUE) |
722 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
723 | 0 | else |
724 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%d [" UTF8_DEGREE_SIGN "C]", value/100, value%100); |
725 | |
|
726 | 0 | return; |
727 | 0 | } /*decode_temp_meas_tolerance*/ |
728 | | |
729 | | /** |
730 | | *This function registers the ZCL Temperature Measurement dissector |
731 | | * |
732 | | */ |
733 | | void |
734 | | proto_register_zbee_zcl_temp_meas(void) |
735 | 14 | { |
736 | 14 | static hf_register_info hf[] = { |
737 | | |
738 | 14 | { &hf_zbee_zcl_temp_meas_attr_id, |
739 | 14 | { "Attribute", "zbee_zcl_meas_sensing.tempmeas.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_temp_meas_attr_names), |
740 | 14 | 0x0, NULL, HFILL } }, |
741 | | |
742 | 14 | { &hf_zbee_zcl_temp_meas_measured_value, |
743 | 14 | { "Measured Value", "zbee_zcl_meas_sensing.tempmeas.attr.value", FT_INT16, BASE_CUSTOM, CF_FUNC(decode_temp_meas_value), |
744 | 14 | 0x0, NULL, HFILL } }, |
745 | | |
746 | 14 | { &hf_zbee_zcl_temp_meas_min_measured_value, |
747 | 14 | { "Min Measured Value", "zbee_zcl_meas_sensing.tempmeas.attr.value.min", FT_INT16, BASE_CUSTOM, CF_FUNC(decode_temp_meas_min_value), |
748 | 14 | 0x0, NULL, HFILL } }, |
749 | | |
750 | 14 | { &hf_zbee_zcl_temp_meas_max_measured_value, |
751 | 14 | { "Max Measured Value", "zbee_zcl_meas_sensing.tempmeas.attr.value.max", FT_INT16, BASE_CUSTOM, CF_FUNC(decode_temp_meas_max_value), |
752 | 14 | 0x0, NULL, HFILL } }, |
753 | | |
754 | 14 | { &hf_zbee_zcl_temp_meas_tolerance, |
755 | 14 | { "Tolerance", "zbee_zcl_meas_sensing.tempmeas.attr.tolerance", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_temp_meas_tolerance), |
756 | 14 | 0x0, NULL, HFILL } } |
757 | | |
758 | 14 | }; |
759 | | |
760 | | /* ZCL Temperature Measurement subtrees */ |
761 | 14 | int *ett[] = { |
762 | 14 | &ett_zbee_zcl_temp_meas |
763 | 14 | }; |
764 | | |
765 | | /* Register the ZigBee ZCL Temperature Measurement cluster protocol name and description */ |
766 | 14 | proto_zbee_zcl_temp_meas = proto_register_protocol("ZigBee ZCL Temperature Meas.", "ZCL Temperature Meas.", ZBEE_PROTOABBREV_ZCL_TEMPMEAS); |
767 | 14 | proto_register_field_array(proto_zbee_zcl_temp_meas, hf, array_length(hf)); |
768 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
769 | | |
770 | | /* Register the ZigBee ZCL Temperature Measurement dissector. */ |
771 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_TEMPMEAS, dissect_zbee_zcl_temp_meas, proto_zbee_zcl_temp_meas); |
772 | 14 | } /*proto_register_zbee_zcl_temp_meas*/ |
773 | | |
774 | | /** |
775 | | *Hands off the ZCL Temperature Measurement dissector. |
776 | | * |
777 | | */ |
778 | | void |
779 | | proto_reg_handoff_zbee_zcl_temp_meas(void) |
780 | 14 | { |
781 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_TEMPMEAS, |
782 | 14 | proto_zbee_zcl_temp_meas, |
783 | 14 | ett_zbee_zcl_temp_meas, |
784 | 14 | ZBEE_ZCL_CID_TEMPERATURE_MEASUREMENT, |
785 | 14 | ZBEE_MFG_CODE_NONE, |
786 | 14 | hf_zbee_zcl_temp_meas_attr_id, |
787 | 14 | hf_zbee_zcl_temp_meas_attr_id, |
788 | 14 | -1, -1, |
789 | 14 | dissect_zcl_temp_meas_attr_data |
790 | 14 | ); |
791 | 14 | } /*proto_reg_handoff_zbee_zcl_temp_meas*/ |
792 | | |
793 | | |
794 | | /* ########################################################################## */ |
795 | | /* #### (0x0403) PRESSURE MEASUREMENT CLUSTER ############################### */ |
796 | | /* ########################################################################## */ |
797 | | |
798 | | /*************************/ |
799 | | /* Defines */ |
800 | | /*************************/ |
801 | | |
802 | | #define ZBEE_ZCL_PRESS_MEAS_NUM_GENERIC_ETT 1 |
803 | | #define ZBEE_ZCL_PRESS_MEAS_NUM_ETT ZBEE_ZCL_PRESS_MEAS_NUM_GENERIC_ETT |
804 | | |
805 | | /* Attributes */ |
806 | 376 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MEASURED_VALUE 0x0000 /* Measured Value */ |
807 | 24 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_MEASURED_VALUE 0x0001 /* Min Measured Value */ |
808 | 11 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_MEASURED_VALUE 0x0002 /* Max Measured Value */ |
809 | 9 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_TOLERANCE 0x0003 /* Tolerance */ |
810 | 16 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALED_VALUE 0x0010 /* Scaled Value */ |
811 | 22 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_SCALED_VALUE 0x0011 /* Min Scaled Value */ |
812 | 14 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_SCALED_VALUE 0x0012 /* Max Scaled Value */ |
813 | 7 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALED_TOLERANCE 0x0013 /* Scaled Tolerance */ |
814 | 6 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALE 0x0014 /* Scale */ |
815 | | |
816 | | /* Server Commands Received - None */ |
817 | | |
818 | | /* Server Commands Generated - None */ |
819 | | |
820 | 0 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_INVALID_VALUE 0x8000 /* Invalid Value */ |
821 | | |
822 | 0 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_LO_VALUE 0x8001 /* Minimum Value (Low Bound) */ |
823 | 0 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_HI_VALUE 0x7ffe /* Minimum Value (High Bound) */ |
824 | | |
825 | 0 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_LO_VALUE 0x8002 /* Maximum Value (Low Bound) */ |
826 | | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_HI_VALUE 0x7fff /* Maximum Value (High Bound) */ |
827 | | |
828 | | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_TOL_LO_VALUE 0x0000 /* Tolerance (Low Bound) */ |
829 | 0 | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_TOL_HI_VALUE 0x0800 /* Tolerance (Low Bound) */ |
830 | | |
831 | | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALE_LO_VALUE 0x81 /* Scale (Low Bound) */ |
832 | | #define ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALE_HI_VALUE 0x7f /* Scale (Low Bound) */ |
833 | | |
834 | | /*************************/ |
835 | | /* Function Declarations */ |
836 | | /*************************/ |
837 | | |
838 | | void proto_register_zbee_zcl_press_meas(void); |
839 | | void proto_reg_handoff_zbee_zcl_press_meas(void); |
840 | | |
841 | | /* Private functions prototype */ |
842 | | static void decode_press_meas_value (char *s, int16_t value); |
843 | | static void decode_press_meas_min_value (char *s, int16_t value); |
844 | | static void decode_press_meas_max_value (char *s, int16_t value); |
845 | | static void decode_press_meas_tolerance (char *s, uint16_t value); |
846 | | |
847 | | /*************************/ |
848 | | /* Global Variables */ |
849 | | /*************************/ |
850 | | |
851 | | /* Initialize the protocol and registered fields */ |
852 | | static int proto_zbee_zcl_press_meas; |
853 | | |
854 | | static int hf_zbee_zcl_press_meas_attr_id; |
855 | | static int hf_zbee_zcl_press_meas_measured_value; |
856 | | static int hf_zbee_zcl_press_meas_min_measured_value; |
857 | | static int hf_zbee_zcl_press_meas_max_measured_value; |
858 | | static int hf_zbee_zcl_press_meas_tolerance; |
859 | | static int hf_zbee_zcl_press_meas_scaled_value; |
860 | | static int hf_zbee_zcl_press_meas_min_scaled_value; |
861 | | static int hf_zbee_zcl_press_meas_max_scaled_value; |
862 | | static int hf_zbee_zcl_press_meas_scaled_tolerance; |
863 | | static int hf_zbee_zcl_press_meas_scale; |
864 | | |
865 | | /* Initialize the subtree pointers */ |
866 | | static int ett_zbee_zcl_press_meas; |
867 | | |
868 | | /* Attributes */ |
869 | | static const value_string zbee_zcl_press_meas_attr_names[] = { |
870 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MEASURED_VALUE, "Measured Value" }, |
871 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_MEASURED_VALUE, "Min Measured Value" }, |
872 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_MEASURED_VALUE, "Max Measured Value" }, |
873 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_TOLERANCE, "Tolerance" }, |
874 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALED_VALUE, "Scaled Value" }, |
875 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_SCALED_VALUE, "Min Scaled Value" }, |
876 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_SCALED_VALUE, "Max Scaled Value" }, |
877 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALED_TOLERANCE, "Scaled Tolerance" }, |
878 | | { ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALE, "Scale" }, |
879 | | { 0, NULL } |
880 | | }; |
881 | | |
882 | | /*************************/ |
883 | | /* Function Bodies */ |
884 | | /*************************/ |
885 | | |
886 | | /** |
887 | | *ZigBee ZCL Pressure Measurement cluster dissector for wireshark. |
888 | | * |
889 | | *@param tvb pointer to buffer containing raw packet. |
890 | | *@param pinfo pointer to packet information fields |
891 | | *@param tree pointer to data tree Wireshark uses to display packet. |
892 | | */ |
893 | | static int |
894 | | dissect_zbee_zcl_press_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
895 | 2 | { |
896 | 2 | return tvb_captured_length(tvb); |
897 | 2 | } /*dissect_zbee_zcl_press_meas*/ |
898 | | |
899 | | /** |
900 | | *This function is called by ZCL foundation dissector in order to decode |
901 | | * |
902 | | *@param tree pointer to data tree Wireshark uses to display packet. |
903 | | *@param tvb pointer to buffer containing raw packet. |
904 | | *@param offset pointer to buffer offset |
905 | | *@param attr_id attribute identifier |
906 | | *@param data_type attribute data type |
907 | | *@param client_attr ZCL client |
908 | | */ |
909 | | static void |
910 | | dissect_zcl_press_meas_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
911 | 1.82k | { |
912 | | /* Dissect attribute data type and data */ |
913 | 1.82k | switch ( attr_id ) { |
914 | | |
915 | 376 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MEASURED_VALUE: |
916 | 376 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
917 | 376 | *offset += 2; |
918 | 376 | break; |
919 | | |
920 | 24 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_MEASURED_VALUE: |
921 | 24 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_min_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
922 | 24 | *offset += 2; |
923 | 24 | break; |
924 | | |
925 | 11 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_MEASURED_VALUE: |
926 | 11 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_max_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
927 | 11 | *offset += 2; |
928 | 11 | break; |
929 | | |
930 | 9 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_TOLERANCE: |
931 | 9 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_tolerance, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
932 | 9 | *offset += 2; |
933 | 9 | break; |
934 | | |
935 | 16 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALED_VALUE: |
936 | 16 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_scaled_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
937 | 16 | *offset += 2; |
938 | 16 | break; |
939 | | |
940 | 22 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_SCALED_VALUE: |
941 | 22 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_min_scaled_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
942 | 22 | *offset += 2; |
943 | 22 | break; |
944 | | |
945 | 14 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_SCALED_VALUE: |
946 | 14 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_max_scaled_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
947 | 14 | *offset += 2; |
948 | 14 | break; |
949 | | |
950 | 7 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALED_TOLERANCE: |
951 | 7 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_scaled_tolerance, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
952 | 7 | *offset += 2; |
953 | 7 | break; |
954 | | |
955 | 6 | case ZBEE_ZCL_ATTR_ID_PRESS_MEAS_SCALE: |
956 | 6 | proto_tree_add_item(tree, hf_zbee_zcl_press_meas_scale, tvb, *offset, 1, ENC_LITTLE_ENDIAN); |
957 | 6 | *offset += 1; |
958 | 6 | break; |
959 | | |
960 | 1.33k | default: |
961 | 1.33k | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
962 | 1.33k | break; |
963 | 1.82k | } |
964 | 1.82k | } /*dissect_zcl_press_meas_attr_data*/ |
965 | | |
966 | | /** |
967 | | *This function decodes pressure value |
968 | | * |
969 | | *@param s string to display |
970 | | *@param value value to decode |
971 | | */ |
972 | | static void |
973 | | decode_press_meas_value(char *s, int16_t value) |
974 | 0 | { |
975 | 0 | if (value == (int16_t)ZBEE_ZCL_ATTR_ID_PRESS_MEAS_INVALID_VALUE) |
976 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Invalid value"); |
977 | 0 | if (value < (int16_t)ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_LO_VALUE) |
978 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
979 | 0 | else |
980 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%d [kPa]", value/10, value%10); |
981 | |
|
982 | 0 | return; |
983 | 0 | } /*decode_press_meas_value*/ |
984 | | |
985 | | /** |
986 | | *This function decodes minimum pressure value |
987 | | * |
988 | | *@param s string to display |
989 | | *@param value value to decode |
990 | | */ |
991 | | static void |
992 | | decode_press_meas_min_value(char *s, int16_t value) |
993 | 0 | { |
994 | 0 | if (value > (int16_t)ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MIN_HI_VALUE) |
995 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
996 | 0 | else |
997 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%d [kPa]", value/10, value%10); |
998 | |
|
999 | 0 | return; |
1000 | 0 | } /*decode_press_meas_min_value*/ |
1001 | | |
1002 | | /** |
1003 | | *This function decodes maximum pressure value |
1004 | | * |
1005 | | *@param s string to display |
1006 | | *@param value value to decode |
1007 | | */ |
1008 | | static void |
1009 | | decode_press_meas_max_value(char *s, int16_t value) |
1010 | 0 | { |
1011 | 0 | if (value < (int16_t)ZBEE_ZCL_ATTR_ID_PRESS_MEAS_MAX_LO_VALUE) |
1012 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1013 | 0 | else |
1014 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%d [kPa]", value/10, value%10); |
1015 | |
|
1016 | 0 | return; |
1017 | 0 | } /*decode_press_meas_max_value*/ |
1018 | | |
1019 | | /** |
1020 | | *This function decodes tolerance value |
1021 | | * |
1022 | | *@param s string to display |
1023 | | *@param value value to decode |
1024 | | */ |
1025 | | static void |
1026 | | decode_press_meas_tolerance(char *s, uint16_t value) |
1027 | 0 | { |
1028 | 0 | if (value > (uint16_t)ZBEE_ZCL_ATTR_ID_PRESS_MEAS_TOL_HI_VALUE) |
1029 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1030 | 0 | else |
1031 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%d [kPa]", value/10, value%10); |
1032 | |
|
1033 | 0 | return; |
1034 | 0 | } /*decode_press_meas_tolerance*/ |
1035 | | |
1036 | | /** |
1037 | | *This function registers the ZCL Pressure Measurement dissector |
1038 | | * |
1039 | | */ |
1040 | | void |
1041 | | proto_register_zbee_zcl_press_meas(void) |
1042 | 14 | { |
1043 | 14 | static hf_register_info hf[] = { |
1044 | | |
1045 | 14 | { &hf_zbee_zcl_press_meas_attr_id, |
1046 | 14 | { "Attribute", "zbee_zcl_meas_sensing.pressmeas.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_press_meas_attr_names), |
1047 | 14 | 0x0, NULL, HFILL } }, |
1048 | | |
1049 | 14 | { &hf_zbee_zcl_press_meas_measured_value, |
1050 | 14 | { "Measured Value", "zbee_zcl_meas_sensing.pressmeas.attr.value", FT_INT16, BASE_CUSTOM, CF_FUNC(decode_press_meas_value), |
1051 | 14 | 0x0, NULL, HFILL } }, |
1052 | | |
1053 | 14 | { &hf_zbee_zcl_press_meas_min_measured_value, |
1054 | 14 | { "Min Measured Value", "zbee_zcl_meas_sensing.pressmeas.attr.value.min", FT_INT16, BASE_CUSTOM, CF_FUNC(decode_press_meas_min_value), |
1055 | 14 | 0x0, NULL, HFILL } }, |
1056 | | |
1057 | 14 | { &hf_zbee_zcl_press_meas_max_measured_value, |
1058 | 14 | { "Max Measured Value", "zbee_zcl_meas_sensing.pressmeas.attr.value.max", FT_INT16, BASE_CUSTOM, CF_FUNC(decode_press_meas_max_value), |
1059 | 14 | 0x0, NULL, HFILL } }, |
1060 | | |
1061 | 14 | { &hf_zbee_zcl_press_meas_tolerance, |
1062 | 14 | { "Tolerance", "zbee_zcl_meas_sensing.pressmeas.attr.tolerance", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_press_meas_tolerance), |
1063 | 14 | 0x0, NULL, HFILL } }, |
1064 | | |
1065 | 14 | { &hf_zbee_zcl_press_meas_scaled_value, |
1066 | 14 | { "Scaled Value", "zbee_zcl_meas_sensing.pressmeas.attr.scaled_value", FT_INT16, BASE_DEC, NULL, |
1067 | 14 | 0x0, NULL, HFILL } }, |
1068 | | |
1069 | 14 | { &hf_zbee_zcl_press_meas_min_scaled_value, |
1070 | 14 | { "Min Scaled Value", "zbee_zcl_meas_sensing.pressmeas.attr.scaled_value.min", FT_INT16, BASE_DEC, NULL, |
1071 | 14 | 0x0, NULL, HFILL } }, |
1072 | | |
1073 | 14 | { &hf_zbee_zcl_press_meas_max_scaled_value, |
1074 | 14 | { "Max Scaled Value", "zbee_zcl_meas_sensing.pressmeas.attr.scaled_value.max", FT_INT16, BASE_DEC, NULL, |
1075 | 14 | 0x0, NULL, HFILL } }, |
1076 | | |
1077 | 14 | { &hf_zbee_zcl_press_meas_scaled_tolerance, |
1078 | 14 | { "Scaled Tolerance", "zbee_zcl_meas_sensing.pressmeas.attr.scaled_tolerance", FT_UINT16, BASE_DEC, NULL, |
1079 | 14 | 0x0, NULL, HFILL } }, |
1080 | | |
1081 | 14 | { &hf_zbee_zcl_press_meas_scale, |
1082 | 14 | { "Scale", "zbee_zcl_meas_sensing.pressmeas.attr.scale", FT_UINT8, BASE_DEC, NULL, |
1083 | 14 | 0x0, NULL, HFILL } } |
1084 | | |
1085 | 14 | }; |
1086 | | |
1087 | | /* ZCL Pressure Measurement subtrees */ |
1088 | 14 | int *ett[] = { |
1089 | 14 | &ett_zbee_zcl_press_meas |
1090 | 14 | }; |
1091 | | |
1092 | | /* Register the ZigBee ZCL Pressure Measurement cluster protocol name and description */ |
1093 | 14 | proto_zbee_zcl_press_meas = proto_register_protocol("ZigBee ZCL Pressure Meas.", "ZCL Pressure Meas.", ZBEE_PROTOABBREV_ZCL_PRESSMEAS); |
1094 | 14 | proto_register_field_array(proto_zbee_zcl_press_meas, hf, array_length(hf)); |
1095 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
1096 | | |
1097 | | /* Register the ZigBee ZCL Pressure Measurement dissector. */ |
1098 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_PRESSMEAS, dissect_zbee_zcl_press_meas, proto_zbee_zcl_press_meas); |
1099 | 14 | } /*proto_register_zbee_zcl_press_meas*/ |
1100 | | |
1101 | | /** |
1102 | | *Hands off the ZCL Pressure Measurement dissector. |
1103 | | * |
1104 | | */ |
1105 | | void |
1106 | | proto_reg_handoff_zbee_zcl_press_meas(void) |
1107 | 14 | { |
1108 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_PRESSMEAS, |
1109 | 14 | proto_zbee_zcl_press_meas, |
1110 | 14 | ett_zbee_zcl_press_meas, |
1111 | 14 | ZBEE_ZCL_CID_PRESSURE_MEASUREMENT, |
1112 | 14 | ZBEE_MFG_CODE_NONE, |
1113 | 14 | hf_zbee_zcl_press_meas_attr_id, |
1114 | 14 | hf_zbee_zcl_press_meas_attr_id, |
1115 | 14 | -1, -1, |
1116 | 14 | dissect_zcl_press_meas_attr_data |
1117 | 14 | ); |
1118 | 14 | } /*proto_reg_handoff_zbee_zcl_press_meas*/ |
1119 | | |
1120 | | /* ########################################################################## */ |
1121 | | /* #### (0x0404) FLOW MEASUREMENT CLUSTER ################################### */ |
1122 | | /* ########################################################################## */ |
1123 | | |
1124 | | /*************************/ |
1125 | | /* Defines */ |
1126 | | /*************************/ |
1127 | | |
1128 | | #define ZBEE_ZCL_FLOW_MEAS_NUM_GENERIC_ETT 1 |
1129 | | #define ZBEE_ZCL_FLOW_MEAS_NUM_ETT ZBEE_ZCL_FLOW_MEAS_NUM_GENERIC_ETT |
1130 | | |
1131 | | /* Attributes */ |
1132 | 199 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MEASURED_VALUE 0x0000 /* Measured Value */ |
1133 | 27 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_MEASURED_VALUE 0x0001 /* Min Measured Value */ |
1134 | 12 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_MEASURED_VALUE 0x0002 /* Max Measured Value */ |
1135 | 13 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOLERANCE 0x0003 /* Tolerance */ |
1136 | | |
1137 | | /* Server Commands Received - None */ |
1138 | | |
1139 | | /* Server Commands Generated - None */ |
1140 | | |
1141 | 0 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOO_LOW_VALUE 0x0000 /* Too Low Value */ |
1142 | 0 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_INVALID_VALUE 0xffff /* Invalid Value */ |
1143 | | |
1144 | | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_LO_VALUE 0x0000 /* Minimum Value (Low Bound) */ |
1145 | 0 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_HI_VALUE 0xfffd /* Minimum Value (High Bound) */ |
1146 | | |
1147 | 0 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_LO_VALUE 0x0001 /* Maximum Value (Low Bound) */ |
1148 | 0 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_HI_VALUE 0xfffe /* Maximum Value (High Bound) */ |
1149 | | |
1150 | | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOL_LO_VALUE 0x0000 /* Tolerance (Low Bound) */ |
1151 | 0 | #define ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOL_HI_VALUE 0x0800 /* Tolerance (Low Bound) */ |
1152 | | |
1153 | | /*************************/ |
1154 | | /* Function Declarations */ |
1155 | | /*************************/ |
1156 | | |
1157 | | void proto_register_zbee_zcl_flow_meas(void); |
1158 | | void proto_reg_handoff_zbee_zcl_flow_meas(void); |
1159 | | |
1160 | | /* Private functions prototype */ |
1161 | | static void decode_flow_meas_value (char *s, uint16_t value); |
1162 | | static void decode_flow_meas_min_value (char *s, uint16_t value); |
1163 | | static void decode_flow_meas_max_value (char *s, uint16_t value); |
1164 | | static void decode_flow_meas_tolerance (char *s, uint16_t value); |
1165 | | |
1166 | | /*************************/ |
1167 | | /* Global Variables */ |
1168 | | /*************************/ |
1169 | | |
1170 | | /* Initialize the protocol and registered fields */ |
1171 | | static int proto_zbee_zcl_flow_meas; |
1172 | | |
1173 | | static int hf_zbee_zcl_flow_meas_attr_id; |
1174 | | static int hf_zbee_zcl_flow_meas_measured_value; |
1175 | | static int hf_zbee_zcl_flow_meas_min_measured_value; |
1176 | | static int hf_zbee_zcl_flow_meas_max_measured_value; |
1177 | | static int hf_zbee_zcl_flow_meas_tolerance; |
1178 | | |
1179 | | /* Initialize the subtree pointers */ |
1180 | | static int ett_zbee_zcl_flow_meas; |
1181 | | |
1182 | | /* Attributes */ |
1183 | | static const value_string zbee_zcl_flow_meas_attr_names[] = { |
1184 | | { ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MEASURED_VALUE, "Measured Value" }, |
1185 | | { ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_MEASURED_VALUE, "Min Measured Value" }, |
1186 | | { ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_MEASURED_VALUE, "Max Measured Value" }, |
1187 | | { ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOLERANCE, "Tolerance" }, |
1188 | | { 0, NULL } |
1189 | | }; |
1190 | | |
1191 | | /*************************/ |
1192 | | /* Function Bodies */ |
1193 | | /*************************/ |
1194 | | |
1195 | | /** |
1196 | | *ZigBee ZCL Flow Measurement cluster dissector for wireshark. |
1197 | | * |
1198 | | *@param tvb pointer to buffer containing raw packet. |
1199 | | *@param pinfo pointer to packet information fields |
1200 | | *@param tree pointer to data tree Wireshark uses to display packet. |
1201 | | */ |
1202 | | static int |
1203 | | dissect_zbee_zcl_flow_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
1204 | 2 | { |
1205 | 2 | return tvb_captured_length(tvb); |
1206 | 2 | } /*dissect_zbee_zcl_flow_meas*/ |
1207 | | |
1208 | | /** |
1209 | | *This function is called by ZCL foundation dissector in order to decode |
1210 | | * |
1211 | | *@param tree pointer to data tree Wireshark uses to display packet. |
1212 | | *@param tvb pointer to buffer containing raw packet. |
1213 | | *@param offset pointer to buffer offset |
1214 | | *@param attr_id attribute identifier |
1215 | | *@param data_type attribute data type |
1216 | | *@param client_attr ZCL client |
1217 | | */ |
1218 | | static void |
1219 | | dissect_zcl_flow_meas_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
1220 | 859 | { |
1221 | | /* Dissect attribute data type and data */ |
1222 | 859 | switch ( attr_id ) { |
1223 | | |
1224 | 199 | case ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MEASURED_VALUE: |
1225 | 199 | proto_tree_add_item(tree, hf_zbee_zcl_flow_meas_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1226 | 199 | *offset += 2; |
1227 | 199 | break; |
1228 | | |
1229 | 27 | case ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_MEASURED_VALUE: |
1230 | 27 | proto_tree_add_item(tree, hf_zbee_zcl_flow_meas_min_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1231 | 27 | *offset += 2; |
1232 | 27 | break; |
1233 | | |
1234 | 12 | case ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_MEASURED_VALUE: |
1235 | 12 | proto_tree_add_item(tree, hf_zbee_zcl_flow_meas_max_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1236 | 12 | *offset += 2; |
1237 | 12 | break; |
1238 | | |
1239 | 13 | case ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOLERANCE: |
1240 | 13 | proto_tree_add_item(tree, hf_zbee_zcl_flow_meas_tolerance, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1241 | 13 | *offset += 2; |
1242 | 13 | break; |
1243 | | |
1244 | 608 | default: |
1245 | 608 | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
1246 | 608 | break; |
1247 | 859 | } |
1248 | 859 | } /*dissect_zcl_flow_meas_attr_data*/ |
1249 | | |
1250 | | /** |
1251 | | *This function decodes flow value |
1252 | | * |
1253 | | *@param s string to display |
1254 | | *@param value value to decode |
1255 | | */ |
1256 | | static void |
1257 | | decode_flow_meas_value(char *s, uint16_t value) |
1258 | 0 | { |
1259 | 0 | if (value == ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOO_LOW_VALUE) |
1260 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Value too low to be measured"); |
1261 | 0 | else if (value == ZBEE_ZCL_ATTR_ID_FLOW_MEAS_INVALID_VALUE) |
1262 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Invalid value"); |
1263 | 0 | else |
1264 | | /* calculate flow value from measured value according to doc 07-5123-04 */ |
1265 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [m^3/h])", value, value/10.0); |
1266 | |
|
1267 | 0 | return; |
1268 | 0 | } /*decode_flow_meas_value*/ |
1269 | | |
1270 | | /** |
1271 | | *This function decodes minimum flow value |
1272 | | * |
1273 | | *@param s string to display |
1274 | | *@param value value to decode |
1275 | | */ |
1276 | | static void |
1277 | | decode_flow_meas_min_value(char *s, uint16_t value) |
1278 | 0 | { |
1279 | 0 | if ( /*(value < ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_LO_VALUE) ||*/ |
1280 | 0 | (value > ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MIN_HI_VALUE) ) |
1281 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1282 | 0 | else |
1283 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [m^3/h])", value, value/10.0); |
1284 | |
|
1285 | 0 | return; |
1286 | 0 | } /*decode_flow_meas_min_value*/ |
1287 | | |
1288 | | /** |
1289 | | *This function decodes maximum flow value |
1290 | | * |
1291 | | *@param s string to display |
1292 | | *@param value value to decode |
1293 | | */ |
1294 | | static void |
1295 | | decode_flow_meas_max_value(char *s, uint16_t value) |
1296 | 0 | { |
1297 | 0 | if ( (value < ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_LO_VALUE) || |
1298 | 0 | (value > ZBEE_ZCL_ATTR_ID_FLOW_MEAS_MAX_HI_VALUE) ) |
1299 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1300 | 0 | else |
1301 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d (=%f [m^3/h])", value, value/10.0); |
1302 | |
|
1303 | 0 | return; |
1304 | 0 | } /*decode_flow_meas_max_value*/ |
1305 | | |
1306 | | /** |
1307 | | *This function decodes tolerance value |
1308 | | * |
1309 | | *@param s string to display |
1310 | | *@param value value to decode |
1311 | | */ |
1312 | | static void |
1313 | | decode_flow_meas_tolerance(char *s, uint16_t value) |
1314 | 0 | { |
1315 | 0 | if (value > ZBEE_ZCL_ATTR_ID_FLOW_MEAS_TOL_HI_VALUE) |
1316 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1317 | 0 | else |
1318 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d", value); |
1319 | |
|
1320 | 0 | return; |
1321 | 0 | } /*decode_flow_meas_tolerance*/ |
1322 | | |
1323 | | /** |
1324 | | *This function registers the ZCL Flow Measurement dissector |
1325 | | * |
1326 | | */ |
1327 | | void |
1328 | | proto_register_zbee_zcl_flow_meas(void) |
1329 | 14 | { |
1330 | 14 | static hf_register_info hf[] = { |
1331 | | |
1332 | 14 | { &hf_zbee_zcl_flow_meas_attr_id, |
1333 | 14 | { "Attribute", "zbee_zcl_meas_sensing.flowmeas.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_flow_meas_attr_names), |
1334 | 14 | 0x0, NULL, HFILL } }, |
1335 | | |
1336 | 14 | { &hf_zbee_zcl_flow_meas_measured_value, |
1337 | 14 | { "Measured Value", "zbee_zcl_meas_sensing.flowmeas.attr.value", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_flow_meas_value), |
1338 | 14 | 0x0, NULL, HFILL } }, |
1339 | | |
1340 | 14 | { &hf_zbee_zcl_flow_meas_min_measured_value, |
1341 | 14 | { "Min Measured Value", "zbee_zcl_meas_sensing.flowmeas.attr.value.min", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_flow_meas_min_value), |
1342 | 14 | 0x0, NULL, HFILL } }, |
1343 | | |
1344 | 14 | { &hf_zbee_zcl_flow_meas_max_measured_value, |
1345 | 14 | { "Max Measured Value", "zbee_zcl_meas_sensing.flowmeas.attr.value.max", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_flow_meas_max_value), |
1346 | 14 | 0x0, NULL, HFILL } }, |
1347 | | |
1348 | 14 | { &hf_zbee_zcl_flow_meas_tolerance, |
1349 | 14 | { "Tolerance", "zbee_zcl_meas_sensing.flowmeas.attr.tolerance", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_flow_meas_tolerance), |
1350 | 14 | 0x0, NULL, HFILL } } |
1351 | 14 | }; |
1352 | | |
1353 | | /* ZCL Flow Measurement subtrees */ |
1354 | 14 | int *ett[] = { |
1355 | 14 | &ett_zbee_zcl_flow_meas |
1356 | 14 | }; |
1357 | | |
1358 | | /* Register the ZigBee ZCL Flow Measurement cluster protocol name and description */ |
1359 | 14 | proto_zbee_zcl_flow_meas = proto_register_protocol("ZigBee ZCL Flow Meas.", "ZCL Flow Meas.", ZBEE_PROTOABBREV_ZCL_FLOWMEAS); |
1360 | 14 | proto_register_field_array(proto_zbee_zcl_flow_meas, hf, array_length(hf)); |
1361 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
1362 | | |
1363 | | /* Register the ZigBee ZCL Flow Measurement dissector. */ |
1364 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_FLOWMEAS, dissect_zbee_zcl_flow_meas, proto_zbee_zcl_flow_meas); |
1365 | | |
1366 | 14 | } /*proto_register_zbee_zcl_flow_meas*/ |
1367 | | |
1368 | | |
1369 | | /** |
1370 | | *Hands off the ZCL Flow Measurement dissector. |
1371 | | * |
1372 | | */ |
1373 | | void |
1374 | | proto_reg_handoff_zbee_zcl_flow_meas(void) |
1375 | 14 | { |
1376 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_FLOWMEAS, |
1377 | 14 | proto_zbee_zcl_flow_meas, |
1378 | 14 | ett_zbee_zcl_flow_meas, |
1379 | 14 | ZBEE_ZCL_CID_FLOW_MEASUREMENT, |
1380 | 14 | ZBEE_MFG_CODE_NONE, |
1381 | 14 | hf_zbee_zcl_flow_meas_attr_id, |
1382 | 14 | hf_zbee_zcl_flow_meas_attr_id, |
1383 | 14 | -1, -1, |
1384 | 14 | dissect_zcl_flow_meas_attr_data |
1385 | 14 | ); |
1386 | 14 | } /*proto_reg_handoff_zbee_zcl_flow_meas*/ |
1387 | | |
1388 | | /* ########################################################################## */ |
1389 | | /* #### (0x0405) RELATIVE HUMIDITY MEASUREMENT CLUSTER ###################### */ |
1390 | | /* ########################################################################## */ |
1391 | | |
1392 | | |
1393 | | /*************************/ |
1394 | | /* Defines */ |
1395 | | /*************************/ |
1396 | | |
1397 | | #define ZBEE_ZCL_RELHUM_MEAS_NUM_GENERIC_ETT 1 |
1398 | | #define ZBEE_ZCL_RELHUM_MEAS_NUM_ETT ZBEE_ZCL_RELHUM_MEAS_NUM_GENERIC_ETT |
1399 | | |
1400 | | /* Attributes */ |
1401 | 198 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MEASURED_VALUE 0x0000 /* Measured Value */ |
1402 | 22 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MIN_MEASURED_VALUE 0x0001 /* Min Measured Value */ |
1403 | 3 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MAX_MEASURED_VALUE 0x0002 /* Max Measured Value */ |
1404 | 2 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_TOLERANCE 0x0003 /* Tolerance */ |
1405 | | |
1406 | | /* Server Commands Received - None */ |
1407 | | |
1408 | | /* Server Commands Generated - None */ |
1409 | | |
1410 | 0 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_INVALID_VALUE 0xffff /* Invalid Value */ |
1411 | | |
1412 | | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MIN_LO_VALUE 0x0000 /* Minimum Value (Low Bound) */ |
1413 | 0 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MIN_HI_VALUE 0x270f /* Minimum Value (High Bound) */ |
1414 | | |
1415 | | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MAX_LO_VALUE 0x0000 /* Maximum Value (Low Bound) */ |
1416 | 0 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MAX_HI_VALUE 0x2710 /* Maximum Value (High Bound) */ |
1417 | | |
1418 | | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_TOL_LO_VALUE 0x0000 /* Tolerance (Low Bound) */ |
1419 | 0 | #define ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_TOL_HI_VALUE 0x0800 /* Tolerance (Low Bound) */ |
1420 | | |
1421 | | /*************************/ |
1422 | | /* Function Declarations */ |
1423 | | /*************************/ |
1424 | | |
1425 | | void proto_register_zbee_zcl_relhum_meas(void); |
1426 | | void proto_reg_handoff_zbee_zcl_relhum_meas(void); |
1427 | | |
1428 | | /* Private functions prototype */ |
1429 | | static void decode_relhum_meas_value (char *s, uint16_t value); |
1430 | | static void decode_relhum_meas_min_value (char *s, uint16_t value); |
1431 | | static void decode_relhum_meas_max_value (char *s, uint16_t value); |
1432 | | static void decode_relhum_meas_tolerance (char *s, uint16_t value); |
1433 | | |
1434 | | /*************************/ |
1435 | | /* Global Variables */ |
1436 | | /*************************/ |
1437 | | |
1438 | | /* Initialize the protocol and registered fields */ |
1439 | | static int proto_zbee_zcl_relhum_meas; |
1440 | | |
1441 | | static int hf_zbee_zcl_relhum_meas_attr_id; |
1442 | | static int hf_zbee_zcl_relhum_meas_measured_value; |
1443 | | static int hf_zbee_zcl_relhum_meas_min_measured_value; |
1444 | | static int hf_zbee_zcl_relhum_meas_max_measured_value; |
1445 | | static int hf_zbee_zcl_relhum_meas_tolerance; |
1446 | | |
1447 | | /* Initialize the subtree pointers */ |
1448 | | static int ett_zbee_zcl_relhum_meas; |
1449 | | |
1450 | | /* Attributes */ |
1451 | | static const value_string zbee_zcl_relhum_meas_attr_names[] = { |
1452 | | { ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MEASURED_VALUE, "Measured Value" }, |
1453 | | { ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MIN_MEASURED_VALUE, "Min Measured Value" }, |
1454 | | { ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MAX_MEASURED_VALUE, "Max Measured Value" }, |
1455 | | { ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_TOLERANCE, "Tolerance" }, |
1456 | | { 0, NULL } |
1457 | | }; |
1458 | | |
1459 | | /*************************/ |
1460 | | /* Function Bodies */ |
1461 | | /*************************/ |
1462 | | |
1463 | | /** |
1464 | | *ZigBee ZCL Relative Humidity Measurement cluster dissector for wireshark. |
1465 | | * |
1466 | | *@param tvb pointer to buffer containing raw packet. |
1467 | | *@param pinfo pointer to packet information fields |
1468 | | *@param tree pointer to data tree Wireshark uses to display packet. |
1469 | | */ |
1470 | | static int |
1471 | | dissect_zbee_zcl_relhum_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
1472 | 1 | { |
1473 | 1 | return tvb_captured_length(tvb); |
1474 | 1 | } /*dissect_zbee_zcl_relhum_meas*/ |
1475 | | |
1476 | | /** |
1477 | | *This function is called by ZCL foundation dissector in order to decode |
1478 | | * |
1479 | | *@param tree pointer to data tree Wireshark uses to display packet. |
1480 | | *@param tvb pointer to buffer containing raw packet. |
1481 | | *@param offset pointer to buffer offset |
1482 | | *@param attr_id attribute identifier |
1483 | | *@param data_type attribute data type |
1484 | | *@param client_attr ZCL client |
1485 | | */ |
1486 | | static void |
1487 | | dissect_zcl_relhum_meas_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
1488 | 538 | { |
1489 | | /* Dissect attribute data type and data */ |
1490 | 538 | switch ( attr_id ) { |
1491 | | |
1492 | 198 | case ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MEASURED_VALUE: |
1493 | 198 | proto_tree_add_item(tree, hf_zbee_zcl_relhum_meas_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1494 | 198 | *offset += 2; |
1495 | 198 | break; |
1496 | | |
1497 | 22 | case ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MIN_MEASURED_VALUE: |
1498 | 22 | proto_tree_add_item(tree, hf_zbee_zcl_relhum_meas_min_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1499 | 22 | *offset += 2; |
1500 | 22 | break; |
1501 | | |
1502 | 3 | case ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MAX_MEASURED_VALUE: |
1503 | 3 | proto_tree_add_item(tree, hf_zbee_zcl_relhum_meas_max_measured_value, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1504 | 3 | *offset += 2; |
1505 | 3 | break; |
1506 | | |
1507 | 2 | case ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_TOLERANCE: |
1508 | 2 | proto_tree_add_item(tree, hf_zbee_zcl_relhum_meas_tolerance, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
1509 | 2 | *offset += 2; |
1510 | 2 | break; |
1511 | | |
1512 | 313 | default: |
1513 | 313 | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
1514 | 313 | break; |
1515 | 538 | } |
1516 | 538 | } /*dissect_zcl_relhum_meas_attr_data*/ |
1517 | | |
1518 | | /** |
1519 | | *This function decodes relative humidity value |
1520 | | * |
1521 | | *@param s string to display |
1522 | | *@param value value to decode |
1523 | | */ |
1524 | | static void |
1525 | | decode_relhum_meas_value(char *s, uint16_t value) |
1526 | 0 | { |
1527 | 0 | if (value == ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_INVALID_VALUE) |
1528 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Invalid value"); |
1529 | 0 | else |
1530 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%02d [%%]", value/100, value%100); |
1531 | |
|
1532 | 0 | return; |
1533 | 0 | } /*decode_relhum_meas_value*/ |
1534 | | |
1535 | | /** |
1536 | | *This function decodes minimum relative humidity value |
1537 | | * |
1538 | | *@param s string to display |
1539 | | *@param value value to decode |
1540 | | */ |
1541 | | static void |
1542 | | decode_relhum_meas_min_value(char *s, uint16_t value) |
1543 | 0 | { |
1544 | 0 | if (value > ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MIN_HI_VALUE) |
1545 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1546 | 0 | else |
1547 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%02d [%%]", value/100, value%100); |
1548 | |
|
1549 | 0 | return; |
1550 | 0 | } /*decode_relhum_meas_min_value*/ |
1551 | | |
1552 | | /** |
1553 | | *This function decodes maximum relative humidity value |
1554 | | * |
1555 | | *@param s string to display |
1556 | | *@param value value to decode |
1557 | | */ |
1558 | | static void |
1559 | | decode_relhum_meas_max_value(char *s, uint16_t value) |
1560 | 0 | { |
1561 | 0 | if (value > ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_MAX_HI_VALUE) |
1562 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1563 | 0 | else |
1564 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%02d [%%]", value/100, value%100); |
1565 | |
|
1566 | 0 | return; |
1567 | 0 | } /*decode_relhum_meas_max_value*/ |
1568 | | |
1569 | | /** |
1570 | | *This function decodes tolerance value |
1571 | | * |
1572 | | *@param s string to display |
1573 | | *@param value value to decode |
1574 | | */ |
1575 | | static void |
1576 | | decode_relhum_meas_tolerance(char *s, uint16_t value) |
1577 | 0 | { |
1578 | 0 | if (value > ZBEE_ZCL_ATTR_ID_RELHUM_MEAS_TOL_HI_VALUE) |
1579 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "Out of range"); |
1580 | 0 | else |
1581 | 0 | snprintf(s, ITEM_LABEL_LENGTH, "%d.%02d [%%]", value/100, value%100); |
1582 | |
|
1583 | 0 | return; |
1584 | 0 | } /*decode_relhum_meas_tolerance*/ |
1585 | | |
1586 | | /** |
1587 | | *This function registers the ZCL Relative Humidity Measurement dissector |
1588 | | * |
1589 | | */ |
1590 | | void |
1591 | | proto_register_zbee_zcl_relhum_meas(void) |
1592 | 14 | { |
1593 | 14 | static hf_register_info hf[] = { |
1594 | | |
1595 | 14 | { &hf_zbee_zcl_relhum_meas_attr_id, |
1596 | 14 | { "Attribute", "zbee_zcl_meas_sensing.relhummeas.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_relhum_meas_attr_names), |
1597 | 14 | 0x0, NULL, HFILL } }, |
1598 | | |
1599 | 14 | { &hf_zbee_zcl_relhum_meas_measured_value, |
1600 | 14 | { "Measured Value", "zbee_zcl_meas_sensing.relhummeas.attr.value", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_relhum_meas_value), |
1601 | 14 | 0x0, NULL, HFILL } }, |
1602 | | |
1603 | 14 | { &hf_zbee_zcl_relhum_meas_min_measured_value, |
1604 | 14 | { "Min Measured Value", "zbee_zcl_meas_sensing.relhummeas.attr.value.min", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_relhum_meas_min_value), |
1605 | 14 | 0x0, NULL, HFILL } }, |
1606 | | |
1607 | 14 | { &hf_zbee_zcl_relhum_meas_max_measured_value, |
1608 | 14 | { "Max Measured Value", "zbee_zcl_meas_sensing.relhummeas.attr.value.max", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_relhum_meas_max_value), |
1609 | 14 | 0x0, NULL, HFILL } }, |
1610 | | |
1611 | 14 | { &hf_zbee_zcl_relhum_meas_tolerance, |
1612 | 14 | { "Tolerance", "zbee_zcl_meas_sensing.relhummeas.attr.tolerance", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_relhum_meas_tolerance), |
1613 | 14 | 0x0, NULL, HFILL } } |
1614 | | |
1615 | 14 | }; |
1616 | | |
1617 | | /* ZCL Relative Humidity Measurement subtrees */ |
1618 | 14 | int *ett[] = { |
1619 | 14 | &ett_zbee_zcl_relhum_meas |
1620 | 14 | }; |
1621 | | |
1622 | | /* Register the ZigBee ZCL Relative Humidity Measurement cluster protocol name and description */ |
1623 | 14 | proto_zbee_zcl_relhum_meas = proto_register_protocol("ZigBee ZCL Rel. Humidity Meas.", "ZCL Relative Humidity Meas.", ZBEE_PROTOABBREV_ZCL_RELHUMMEAS); |
1624 | 14 | proto_register_field_array(proto_zbee_zcl_relhum_meas, hf, array_length(hf)); |
1625 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
1626 | | |
1627 | | /* Register the ZigBee ZCL Relative Humidity Measurement dissector. */ |
1628 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_RELHUMMEAS, dissect_zbee_zcl_relhum_meas, proto_zbee_zcl_relhum_meas); |
1629 | 14 | } /*proto_register_zbee_zcl_relhum_meas*/ |
1630 | | |
1631 | | |
1632 | | /** |
1633 | | *Hands off the ZCL Relative Humidity Measurement dissector. |
1634 | | * |
1635 | | */ |
1636 | | void |
1637 | | proto_reg_handoff_zbee_zcl_relhum_meas(void) |
1638 | 14 | { |
1639 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_RELHUMMEAS, |
1640 | 14 | proto_zbee_zcl_relhum_meas, |
1641 | 14 | ett_zbee_zcl_relhum_meas, |
1642 | 14 | ZBEE_ZCL_CID_REL_HUMIDITY_MEASUREMENT, |
1643 | 14 | ZBEE_MFG_CODE_NONE, |
1644 | 14 | hf_zbee_zcl_relhum_meas_attr_id, |
1645 | 14 | hf_zbee_zcl_relhum_meas_attr_id, |
1646 | 14 | -1, -1, |
1647 | 14 | dissect_zcl_relhum_meas_attr_data |
1648 | 14 | ); |
1649 | 14 | } /*proto_reg_handoff_zbee_zcl_relhum_meas*/ |
1650 | | |
1651 | | |
1652 | | /* ########################################################################## */ |
1653 | | /* #### (0x0406) OCCUPANCY SENSING CLUSTER ################################## */ |
1654 | | /* ########################################################################## */ |
1655 | | |
1656 | | /*************************/ |
1657 | | /* Defines */ |
1658 | | /*************************/ |
1659 | | |
1660 | | #define ZBEE_ZCL_OCC_SEN_NUM_ETT 2 |
1661 | | |
1662 | | /* Attributes */ |
1663 | 233 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_OCCUPANCY 0x0000 /* Occupancy */ |
1664 | 30 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_OCC_SENSOR_TYPE 0x0001 /* Occupancy Sensor Type */ |
1665 | 5 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_OCC_SENSOR_TYPE_BITMAP 0x0002 /* Occupancy Sensor Type Bitmap */ |
1666 | 0 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_OCC_TO_UNOCC_DELAY 0x0010 /* PIR Occupied to Unoccupied Delay */ |
1667 | 0 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_UNOCC_TO_OCC_DELAY 0x0011 /* PIR Unoccupied to Occupied Delay */ |
1668 | 0 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_UNOCC_TO_OCC_THOLD 0x0012 /* PIR Unoccupied to Occupied Threshold */ |
1669 | 1 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_OCC_TO_UNOCC_DELAY 0x0020 /* Ultrasonic Occupied to Unoccupied Threshold */ |
1670 | 1 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_UNOCC_TO_OCC_DELAY 0x0021 /* Ultrasonic Unoccupied to Occupied Delay */ |
1671 | 1 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_UNOCC_TO_OCC_THOLD 0x0022 /* Ultrasonic Unoccupied to Occupied Threshold */ |
1672 | 1 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_OCC_TO_UNOCC_DELAY 0x0030 /* Physical Contact Occupied to Unoccupied Delay */ |
1673 | 1 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_UNOCC_TO_OCC_DELAY 0x0031 /* Physical Contact Unoccupied to Occupied Delay */ |
1674 | 1 | #define ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_UNOCC_TO_OCC_THOLD 0x0032 /* Physical Contact Unoccupied to Occupied Threshold */ |
1675 | | |
1676 | | /* Server Commands Received - None */ |
1677 | | |
1678 | | /* Server Commands Generated - None */ |
1679 | | |
1680 | | /* Occupancy Mask fields */ |
1681 | 14 | #define ZBEE_ZCL_OCCUPANCY_SENSED_OCC 0x01 /* Sensed Occupancy */ |
1682 | | |
1683 | | /* Occupancy Sensor Type */ |
1684 | | #define ZBEE_ZCL_OCC_SENSOR_TYPE_PIR 0x00 /* PIR */ |
1685 | | #define ZBEE_ZCL_OCC_SENSOR_TYPE_USONIC 0x01 /* Ultrasonic */ |
1686 | | #define ZBEE_ZCL_OCC_SENSOR_TYPE_PIR_AND_USONIC 0x02 /* PIR and Ultrasonic */ |
1687 | | #define ZBEE_ZCL_OCC_SENSOR_TYPE_PHYSICAL_CONTACT 0x03 /* Physical Contact */ |
1688 | | |
1689 | | /* Occupancy Sensor Type Bitmap Mask fields */ |
1690 | 14 | #define ZBEE_ZCL_OCC_SENSOR_TYPE_BITMAP_PIR 0x01 /* PIR */ |
1691 | 14 | #define ZBEE_ZCL_OCC_SENSOR_TYPE_BITMAP_ULTRASONIC 0x02 /* Ultrasonic */ |
1692 | 14 | #define ZBEE_ZCL_OCC_SENSOR_TYPE_BITMAP_PHYSICAL_CONTACT 0x04 /* Physical Contact */ |
1693 | | |
1694 | | /*************************/ |
1695 | | /* Function Declarations */ |
1696 | | /*************************/ |
1697 | | |
1698 | | void proto_register_zbee_zcl_occ_sen(void); |
1699 | | void proto_reg_handoff_zbee_zcl_occ_sen(void); |
1700 | | |
1701 | | /*************************/ |
1702 | | /* Global Variables */ |
1703 | | /*************************/ |
1704 | | |
1705 | | /* Initialize the protocol and registered fields */ |
1706 | | static int proto_zbee_zcl_occ_sen; |
1707 | | |
1708 | | static int hf_zbee_zcl_occ_sen_attr_id; |
1709 | | static int hf_zbee_zcl_occ_sen_occupancy; |
1710 | | static int hf_zbee_zcl_occ_sen_occupancy_occupied; |
1711 | | static int hf_zbee_zcl_occ_sen_occ_sensor_type; |
1712 | | static int hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap; |
1713 | | static int hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_pir; |
1714 | | static int hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_ultrasonic; |
1715 | | static int hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_physical_contact; |
1716 | | |
1717 | | /* Initialize the subtree pointers */ |
1718 | | static int ett_zbee_zcl_occ_sen; |
1719 | | static int ett_zbee_zcl_occ_sen_occupancy; |
1720 | | static int ett_zbee_zcl_occ_sen_sensor_type_bitmap; |
1721 | | |
1722 | | /* Attributes */ |
1723 | | static const value_string zbee_zcl_occ_sen_attr_names[] = { |
1724 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_OCCUPANCY, "Occupancy" }, |
1725 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_OCC_SENSOR_TYPE, "Occupancy Sensor Type" }, |
1726 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_OCC_SENSOR_TYPE_BITMAP, "Occupancy Sensor Type Bitmap" }, |
1727 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_OCC_TO_UNOCC_DELAY, "PIR Occupied to Unoccupied Delay" }, |
1728 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_UNOCC_TO_OCC_DELAY, "PIR Unoccupied to Occupied Delay" }, |
1729 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_UNOCC_TO_OCC_THOLD, "PIR Unoccupied to Occupied Threshold" }, |
1730 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_OCC_TO_UNOCC_DELAY, "Ultrasonic Occupied to Unoccupied Threshold" }, |
1731 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_UNOCC_TO_OCC_DELAY, "Ultrasonic Unoccupied to Occupied Delay" }, |
1732 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_UNOCC_TO_OCC_THOLD, "Ultrasonic Unoccupied to Occupied Threshold" }, |
1733 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_OCC_TO_UNOCC_DELAY, "Physical Contact Occupied to Unoccupied Delay" }, |
1734 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_UNOCC_TO_OCC_DELAY, "Physical Contact Unoccupied to Occupied Delay" }, |
1735 | | { ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_UNOCC_TO_OCC_THOLD, "Physical Contact Unoccupied to Occupied Threshold" }, |
1736 | | { 0, NULL } |
1737 | | }; |
1738 | | |
1739 | | /* Occupancy Sensor types */ |
1740 | | static const value_string zbee_zcl_occ_sen_sensor_type_names[] = { |
1741 | | { ZBEE_ZCL_OCC_SENSOR_TYPE_PIR, "PIR" }, |
1742 | | { ZBEE_ZCL_OCC_SENSOR_TYPE_USONIC, "Ultrasonic" }, |
1743 | | { ZBEE_ZCL_OCC_SENSOR_TYPE_PIR_AND_USONIC, "PIR and Ultrasonic" }, |
1744 | | { 0, NULL } |
1745 | | }; |
1746 | | |
1747 | | /*************************/ |
1748 | | /* Function Bodies */ |
1749 | | /*************************/ |
1750 | | |
1751 | | /** |
1752 | | *ZigBee ZCL Occupancy Sensing cluster dissector for wireshark. |
1753 | | * |
1754 | | *@param tvb pointer to buffer containing raw packet. |
1755 | | *@param pinfo pointer to packet information fields |
1756 | | *@param tree pointer to data tree Wireshark uses to display packet. |
1757 | | */ |
1758 | | static int |
1759 | | dissect_zbee_zcl_occ_sen(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void* data _U_) |
1760 | 2 | { |
1761 | 2 | return tvb_captured_length(tvb); |
1762 | 2 | } /*dissect_zbee_zcl_occ_sen*/ |
1763 | | |
1764 | | /** |
1765 | | *This function is called by ZCL foundation dissector in order to decode |
1766 | | * |
1767 | | *@param tree pointer to data tree Wireshark uses to display packet. |
1768 | | *@param tvb pointer to buffer containing raw packet. |
1769 | | *@param offset pointer to buffer offset |
1770 | | *@param attr_id attribute identifier |
1771 | | *@param data_type attribute data type |
1772 | | *@param client_attr ZCL client |
1773 | | */ |
1774 | | static void |
1775 | | dissect_zcl_occ_sen_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
1776 | 720 | { |
1777 | 720 | static int * const occupancy[] = { |
1778 | 720 | &hf_zbee_zcl_occ_sen_occupancy_occupied, |
1779 | 720 | NULL |
1780 | 720 | }; |
1781 | | |
1782 | 720 | static int * const sensor_type_bitmap[] = { |
1783 | 720 | &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_pir, |
1784 | 720 | &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_ultrasonic, |
1785 | 720 | &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_physical_contact, |
1786 | 720 | NULL |
1787 | 720 | }; |
1788 | | |
1789 | | /* Dissect attribute data type and data */ |
1790 | 720 | switch ( attr_id ) { |
1791 | | |
1792 | 233 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_OCCUPANCY: |
1793 | 233 | proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_occ_sen_occupancy, ett_zbee_zcl_occ_sen_occupancy, occupancy, ENC_LITTLE_ENDIAN); |
1794 | 233 | *offset += 1; |
1795 | 233 | break; |
1796 | | |
1797 | 30 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_OCC_SENSOR_TYPE: |
1798 | 30 | proto_tree_add_item(tree, hf_zbee_zcl_occ_sen_occ_sensor_type, tvb, *offset, 1, ENC_LITTLE_ENDIAN); |
1799 | 30 | *offset += 1; |
1800 | 30 | break; |
1801 | | |
1802 | 5 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_OCC_SENSOR_TYPE_BITMAP: |
1803 | 5 | proto_tree_add_bitmask(tree, tvb, *offset, hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap, ett_zbee_zcl_occ_sen_sensor_type_bitmap, sensor_type_bitmap, ENC_LITTLE_ENDIAN); |
1804 | 5 | *offset += 1; |
1805 | 5 | break; |
1806 | | |
1807 | 0 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_OCC_TO_UNOCC_DELAY: |
1808 | 0 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_UNOCC_TO_OCC_DELAY: |
1809 | 0 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_PIR_UNOCC_TO_OCC_THOLD: |
1810 | 1 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_OCC_TO_UNOCC_DELAY: |
1811 | 1 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_UNOCC_TO_OCC_DELAY: |
1812 | 1 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_USONIC_UNOCC_TO_OCC_THOLD: |
1813 | 1 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_OCC_TO_UNOCC_DELAY: |
1814 | 1 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_UNOCC_TO_OCC_DELAY: |
1815 | 1 | case ZBEE_ZCL_ATTR_ID_OCC_SEN_PHYSICAL_CONTACT_UNOCC_TO_OCC_THOLD: |
1816 | 452 | default: |
1817 | 452 | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
1818 | 452 | break; |
1819 | 720 | } |
1820 | 720 | } /*dissect_zcl_occ_sen_attr_data*/ |
1821 | | |
1822 | | /** |
1823 | | *This function registers the ZCL Occupancy Sensing dissector |
1824 | | * |
1825 | | */ |
1826 | | void |
1827 | | proto_register_zbee_zcl_occ_sen(void) |
1828 | 14 | { |
1829 | 14 | static hf_register_info hf[] = { |
1830 | | |
1831 | 14 | { &hf_zbee_zcl_occ_sen_attr_id, |
1832 | 14 | { "Attribute", "zbee_zcl_meas_sensing.occsen.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_occ_sen_attr_names), |
1833 | 14 | 0x0, NULL, HFILL } }, |
1834 | | |
1835 | 14 | { &hf_zbee_zcl_occ_sen_occupancy, |
1836 | 14 | { "Occupancy", "zbee_zcl_meas_sensing.occsen.attr.occupancy", FT_UINT8, BASE_HEX, NULL, |
1837 | 14 | 0x0, NULL, HFILL } }, |
1838 | | |
1839 | 14 | { &hf_zbee_zcl_occ_sen_occupancy_occupied, |
1840 | 14 | { "Occupied", "zbee_zcl_meas_sensing.occsen.attr.occupancy_occupied", FT_BOOLEAN, 8, NULL, |
1841 | 14 | ZBEE_ZCL_OCCUPANCY_SENSED_OCC, NULL, HFILL } }, |
1842 | | |
1843 | 14 | { &hf_zbee_zcl_occ_sen_occ_sensor_type, |
1844 | 14 | { "Occupancy Sensor Type", "zbee_zcl_meas_sensing.occsen.attr.occ_sensor_type", FT_UINT8, BASE_HEX, VALS(zbee_zcl_occ_sen_sensor_type_names), |
1845 | 14 | 0x0, NULL, HFILL } }, |
1846 | | |
1847 | 14 | { &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap, |
1848 | 14 | { "Occupancy Sensor Type Bitmap", "zbee_zcl_meas_sensing.occsen.sensor_type_bitmap", FT_UINT8, BASE_HEX, NULL, |
1849 | 14 | 0x0, NULL, HFILL } }, |
1850 | | |
1851 | 14 | { &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_pir, |
1852 | 14 | { "PIR", "zbee_zcl_meas_sensing.occsen.sensor_type_bitmap_pir", FT_BOOLEAN, 8, NULL, |
1853 | 14 | ZBEE_ZCL_OCC_SENSOR_TYPE_BITMAP_PIR, NULL, HFILL } }, |
1854 | | |
1855 | 14 | { &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_ultrasonic, |
1856 | 14 | { "Ultrasonic", "zbee_zcl_meas_sensing.occsen.sensor_type_bitmap_ultrasonic", FT_BOOLEAN, 8, NULL, |
1857 | 14 | ZBEE_ZCL_OCC_SENSOR_TYPE_BITMAP_ULTRASONIC, NULL, HFILL } }, |
1858 | | |
1859 | 14 | { &hf_zbee_zcl_occ_sen_occ_sensor_type_bitmap_physical_contact, |
1860 | 14 | { "Physical Contact", "zbee_zcl_meas_sensing.occsen.sensor_type_bitmap_physical_contact", FT_BOOLEAN, 8, NULL, |
1861 | 14 | ZBEE_ZCL_OCC_SENSOR_TYPE_BITMAP_PHYSICAL_CONTACT, NULL, HFILL } }, |
1862 | 14 | }; |
1863 | | |
1864 | | |
1865 | | /* ZCL Occupancy Sensing subtrees */ |
1866 | 14 | static int *ett[ZBEE_ZCL_OCC_SEN_NUM_ETT]; |
1867 | 14 | ett[0] = &ett_zbee_zcl_occ_sen; |
1868 | 14 | ett[1] = &ett_zbee_zcl_occ_sen_occupancy; |
1869 | | |
1870 | | /* Register the ZigBee ZCL Occupancy Sensing cluster protocol name and description */ |
1871 | 14 | proto_zbee_zcl_occ_sen = proto_register_protocol("ZigBee ZCL Occupancy Sensing", "ZCL Occupancy Sensing", ZBEE_PROTOABBREV_ZCL_OCCSEN); |
1872 | 14 | proto_register_field_array(proto_zbee_zcl_occ_sen, hf, array_length(hf)); |
1873 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
1874 | | |
1875 | | /* Register the ZigBee ZCL Occupancy Sensing dissector. */ |
1876 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_OCCSEN, dissect_zbee_zcl_occ_sen, proto_zbee_zcl_occ_sen); |
1877 | | |
1878 | 14 | } /*proto_register_zbee_zcl_occ_sen*/ |
1879 | | |
1880 | | |
1881 | | /** |
1882 | | *Hands off the ZCL Occupancy Sensing dissector. |
1883 | | * |
1884 | | */ |
1885 | | void |
1886 | | proto_reg_handoff_zbee_zcl_occ_sen(void) |
1887 | 14 | { |
1888 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_OCCSEN, |
1889 | 14 | proto_zbee_zcl_occ_sen, |
1890 | 14 | ett_zbee_zcl_occ_sen, |
1891 | 14 | ZBEE_ZCL_CID_OCCUPANCY_SENSING, |
1892 | 14 | ZBEE_MFG_CODE_NONE, |
1893 | 14 | hf_zbee_zcl_occ_sen_attr_id, |
1894 | 14 | hf_zbee_zcl_occ_sen_attr_id, |
1895 | 14 | -1, -1, |
1896 | 14 | dissect_zcl_occ_sen_attr_data |
1897 | 14 | ); |
1898 | 14 | } /*proto_reg_handoff_zbee_zcl_occ_sen*/ |
1899 | | |
1900 | | /* ########################################################################## */ |
1901 | | /* #### (0x0b04) ELECTRICAL MEASUREMENT CLUSTER ############################# */ |
1902 | | /* ########################################################################## */ |
1903 | | |
1904 | | /*************************/ |
1905 | | /* Defines */ |
1906 | | /*************************/ |
1907 | | |
1908 | | #define ZBEE_ZCL_ELEC_MES_NUM_ETT 1 |
1909 | | |
1910 | | /* Attributes */ |
1911 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASUREMENT_TYPE 0x0000 |
1912 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE 0x0100 |
1913 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_MIN 0x0101 |
1914 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_MAX 0x0102 |
1915 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT 0x0103 |
1916 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_MIN 0x0104 |
1917 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_MAX 0x0105 |
1918 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER 0x0106 |
1919 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_MIN 0x0107 |
1920 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_MAX 0x0108 |
1921 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_MULTIPLIER 0x0200 |
1922 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_DIVISOR 0x0201 |
1923 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_MULTIPLIER 0x0202 |
1924 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_DIVISOR 0x0203 |
1925 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_MULTIPLIER 0x0204 |
1926 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_DIVISOR 0x0205 |
1927 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY 0x0300 |
1928 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_MIN 0x0301 |
1929 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_MAX 0x0302 |
1930 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_NEUTRAL_CURRENT 0x0303 |
1931 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_TOTAL_ACTIVE_POWER 0x0304 |
1932 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_TOTAL_REACTIVE_POWER 0x0305 |
1933 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_TOTAL_APPARENT_POWER 0x0306 |
1934 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_1ST_HARMONIC_CURRENT 0x0307 |
1935 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_3RD_HARMONIC_CURRENT 0x0308 |
1936 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_5TH_HARMONIC_CURRENT 0x0309 |
1937 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_7TH_HARMONIC_CURRENT 0x030A |
1938 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_9TH_HARMONIC_CURRENT 0x030B |
1939 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_11TH_HARMONIC_CURRENT 0x030C |
1940 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_1ST_HARMONIC_CURRENT 0x030D |
1941 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_3RD_HARMONIC_CURRENT 0x030E |
1942 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_5TH_HARMONIC_CURRENT 0x030F |
1943 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_7TH_HARMONIC_CURRENT 0x0310 |
1944 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_9TH_HARMONIC_CURRENT 0x0311 |
1945 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_11TH_HARMONIC_CURRENT 0x0312 |
1946 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_MULTIPLIER 0x0400 |
1947 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_DIVISOR 0x0401 |
1948 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_MULTIPLIER 0x0402 |
1949 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_DIVISOR 0x0403 |
1950 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_HARMONIC_CURRENT_MULTIPLIER 0x0404 |
1951 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_PHASE_HARMONIC_CURRENT_MULTIPLIER 0x0405 |
1952 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_LINE_CURRENT 0x0501 |
1953 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_CURRENT 0x0502 |
1954 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_CURRENT 0x0503 |
1955 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE 0x0505 |
1956 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MIN 0x0506 |
1957 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MAX 0x0507 |
1958 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT 0x0508 |
1959 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MIN 0x0509 |
1960 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MAX 0x050A |
1961 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER 0x050B |
1962 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MIN 0x050C |
1963 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MAX 0x050D |
1964 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_POWER 0x050E |
1965 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_APPARENT_POWER 0x050F |
1966 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_FACTOR 0x0510 |
1967 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD 0x0511 |
1968 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE_COUNTER 0x0512 |
1969 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER 0x0513 |
1970 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE_PERIOD 0x0514 |
1971 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE_PERIOD 0x0515 |
1972 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG_PERIOD 0x0516 |
1973 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL_PERIOD 0x0517 |
1974 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_VOLTAGE_MULTIPLIER 0x0600 |
1975 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_VOLTAGE_DIVISOR 0x0601 |
1976 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_CURRENT_MULTIPLIER 0x0602 |
1977 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_CURRENT_DIVISOR 0x0603 |
1978 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_POWER_MULTIPLIER 0x0604 |
1979 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_POWER_DIVISOR 0x0605 |
1980 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_OVERLOAD_ALARMS_MASK 0x0700 |
1981 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_OVERLOAD 0x0701 |
1982 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_OVERLOAD 0x0702 |
1983 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_ALARMS_MASK 0x0800 |
1984 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_VOLTAGE_OVERLOAD 0x0801 |
1985 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_CURRENT_OVERLOAD 0x0802 |
1986 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_ACTIVE_POWER_OVERLOAD 0x0803 |
1987 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_REACTIVE_POWER_OVERLOAD 0x0804 |
1988 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE 0x0805 |
1989 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE 0x0806 |
1990 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE 0x0807 |
1991 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE 0x0808 |
1992 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG 0x0809 |
1993 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL 0x080A |
1994 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_LINE_CURRENT_PH_B 0x0901 |
1995 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_CURRENT_PH_B 0x0902 |
1996 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_CURRENT_PH_B 0x0903 |
1997 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_PH_B 0x0905 |
1998 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MIN_PH_B 0x0906 |
1999 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MAX_PH_B 0x0907 |
2000 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_PH_B 0x0908 |
2001 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MIN_PH_B 0x0909 |
2002 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MAX_PH_B 0x090A |
2003 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_PH_B 0x090B |
2004 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MIN_PH_B 0x090C |
2005 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MAX_PH_B 0x090D |
2006 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_POWER_PH_B 0x090E |
2007 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_APPARENT_POWER_PH_B 0x090F |
2008 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_FACTOR_PH_B 0x0910 |
2009 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PH_B 0x0911 |
2010 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_B 0x0912 |
2011 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_B 0x0913 |
2012 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_B 0x0914 |
2013 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_B 0x0915 |
2014 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG_PERIOD_PH_B 0x0916 |
2015 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL_PERIOD_PH_B 0x0917 |
2016 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_LINE_CURRENT_PH_C 0x0A01 |
2017 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_CURRENT_PH_C 0x0A03 |
2018 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_PH_C 0x0A05 |
2019 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MIN_PH_C 0x0A06 |
2020 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MAX_PH_C 0x0A07 |
2021 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_PH_C 0x0A08 |
2022 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MIN_PH_C 0x0A09 |
2023 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MAX_PH_C 0x0A0A |
2024 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_PH_C 0x0A0B |
2025 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MIN_PH_C 0x0A0C |
2026 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MAX_PH_C 0x0A0D |
2027 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_POWER_PH_C 0x0A0E |
2028 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_APPARENT_POWER_PH_C 0x0A0F |
2029 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_FACTOR_PH_C 0x0A10 |
2030 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PH_C 0x0A11 |
2031 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_C 0x0A12 |
2032 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_C 0x0A13 |
2033 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_C 0x0A14 |
2034 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_C 0x0A15 |
2035 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG_PERIOD_PH_C 0x0A16 |
2036 | | #define ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL_PERIOD_PH_C 0x0A17 |
2037 | | |
2038 | | /* Server Commands Received */ |
2039 | 1 | #define ZBEE_ZCL_CMD_GET_PROFILE_INFO 0x00 |
2040 | 0 | #define ZBEE_ZCL_CMD_GET_MEASUREMENT_PROFILE_INFO 0x01 |
2041 | | |
2042 | | /* Server Commands Generated */ |
2043 | 2 | #define ZBEE_ZCL_CMD_GET_PROFILE_INFO_RESPONSE 0x00 |
2044 | 0 | #define ZBEE_ZCL_CMD_GET_MEASUREMENT_PROFILE_INFO_RESPONSE 0x01 |
2045 | | |
2046 | | /* Profile Interval Period */ |
2047 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_DAILY 0 |
2048 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_60_MINUTES 1 |
2049 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_30_MINUTES 2 |
2050 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_15_MINUTES 3 |
2051 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_10_MINUTES 4 |
2052 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_7_5_MINUTES 5 |
2053 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_5_MINUTES 6 |
2054 | | #define ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_2_5_MINUTES 7 |
2055 | | |
2056 | | /* List of Status Valid Values */ |
2057 | | #define ZBEE_ZCL_ELEC_MES_STATUS_SUCCESS 0x00 |
2058 | | #define ZBEE_ZCL_ELEC_MES_STATUS_ATTRIBUTE_PROFILE_NOT_SUPPORTED 0x01 |
2059 | | #define ZBEE_ZCL_ELEC_MES_STATUS_INVALID_START_TIME 0x02 |
2060 | | #define ZBEE_ZCL_ELEC_MES_STATUS_MORE_INTERVALS_REQUESTED_THAN_CAN_BE_RET 0x03 |
2061 | | #define ZBEE_ZCL_ELEC_MES_STATUS_NO_INTERVALS_AVAILABLE_FOR_THE_REQ_TIME 0x04 |
2062 | | |
2063 | | /*************************/ |
2064 | | /* Function Declarations */ |
2065 | | /*************************/ |
2066 | | |
2067 | | void proto_register_zbee_zcl_elec_mes(void); |
2068 | | void proto_reg_handoff_zbee_zcl_elec_mes(void); |
2069 | | |
2070 | | /* Command Dissector Helpers */ |
2071 | | static void dissect_zcl_elec_mes_get_measurement_profile_info (tvbuff_t *tvb, proto_tree *tree, unsigned *offset); |
2072 | | static void dissect_zcl_elec_mes_get_profile_info_response (tvbuff_t *tvb, proto_tree *tree, unsigned *offset); |
2073 | | static void dissect_zcl_elec_mes_get_measurement_profile_info_response (tvbuff_t *tvb, proto_tree *tree, unsigned *offset); |
2074 | | |
2075 | | /*************************/ |
2076 | | /* Global Variables */ |
2077 | | /*************************/ |
2078 | | |
2079 | | /* Initialize the protocol and registered fields */ |
2080 | | static int proto_zbee_zcl_elec_mes; |
2081 | | |
2082 | | static int hf_zbee_zcl_elec_mes_srv_tx_cmd_id; |
2083 | | static int hf_zbee_zcl_elec_mes_srv_rx_cmd_id; |
2084 | | static int hf_zbee_zcl_elec_mes_attr_id; |
2085 | | static int hf_zbee_zcl_elec_mes_start_time; |
2086 | | static int hf_zbee_zcl_elec_mes_number_of_intervals; |
2087 | | static int hf_zbee_zcl_elec_mes_profile_count; |
2088 | | static int hf_zbee_zcl_elec_mes_profile_interval_period; |
2089 | | static int hf_zbee_zcl_elec_mes_max_number_of_intervals; |
2090 | | static int hf_zbee_zcl_elec_mes_status; |
2091 | | static int hf_zbee_zcl_elec_mes_number_of_intervals_delivered; |
2092 | | static int hf_zbee_zcl_elec_mes_intervals; |
2093 | | |
2094 | | /* Initialize the subtree pointers */ |
2095 | | static int ett_zbee_zcl_elec_mes; |
2096 | | |
2097 | | /* Attributes */ |
2098 | | static const value_string zbee_zcl_elec_mes_attr_names[] = { |
2099 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASUREMENT_TYPE, "Measurement Type" }, |
2100 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE, "DC Voltage" }, |
2101 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_MIN, "DC Voltage Min" }, |
2102 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_MAX, "DC Voltage Max" }, |
2103 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT, "DC Current" }, |
2104 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_MIN, "DC Current Min" }, |
2105 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_MAX, "DC Current Max" }, |
2106 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER, "DC Power" }, |
2107 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_MIN, "DC Power Min" }, |
2108 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_MAX, "DC Power Max" }, |
2109 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_MULTIPLIER, "DC Voltage Multiplier" }, |
2110 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_DIVISOR, "DC Voltage Divisor" }, |
2111 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_MULTIPLIER, "DC Current Multiplier" }, |
2112 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_DIVISOR, "DC Current Divisor" }, |
2113 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_MULTIPLIER, "DC Power Multiplier" }, |
2114 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_POWER_DIVISOR, "DC Power Divisor" }, |
2115 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY, "AC Frequency" }, |
2116 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_MIN, "AC Frequency Min" }, |
2117 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_MAX, "AC Frequency Max" }, |
2118 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_NEUTRAL_CURRENT, "Neutral Current" }, |
2119 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_TOTAL_ACTIVE_POWER, "Total Active Power" }, |
2120 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_TOTAL_REACTIVE_POWER, "Total Reactive Power" }, |
2121 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_TOTAL_APPARENT_POWER, "Total Apparent Power" }, |
2122 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_1ST_HARMONIC_CURRENT, "Measured 1st Harmonic Current" }, |
2123 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_3RD_HARMONIC_CURRENT, "Measured 3rd Harmonic Current" }, |
2124 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_5TH_HARMONIC_CURRENT, "Measured 5th Harmonic Current" }, |
2125 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_7TH_HARMONIC_CURRENT, "Measured 7th Harmonic Current" }, |
2126 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_9TH_HARMONIC_CURRENT, "Measured 9th Harmonic Current" }, |
2127 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_11TH_HARMONIC_CURRENT, "Measured 11th Harmonic Current" }, |
2128 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_1ST_HARMONIC_CURRENT, "Measured Phase 1st Harmonic Current" }, |
2129 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_3RD_HARMONIC_CURRENT, "Measured Phase 3rd Harmonic Current" }, |
2130 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_5TH_HARMONIC_CURRENT, "Measured Phase 5th Harmonic Current" }, |
2131 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_7TH_HARMONIC_CURRENT, "Measured Phase 7th Harmonic Current" }, |
2132 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_9TH_HARMONIC_CURRENT, "Measured Phase 9th Harmonic Current" }, |
2133 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_MEASURED_PHASE_11TH_HARMONIC_CURRENT, "Measured Phase 11th Harmonic Current" }, |
2134 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_MULTIPLIER, "AC Frequency Multiplier" }, |
2135 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_FREQUENCY_DIVISOR, "AC Frequency Divisor" }, |
2136 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_MULTIPLIER, "Power Multiplier" }, |
2137 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_DIVISOR, "Power Divisor" }, |
2138 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_HARMONIC_CURRENT_MULTIPLIER, "Harmonic Current Multiplier" }, |
2139 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_PHASE_HARMONIC_CURRENT_MULTIPLIER, "Phase Harmonic Current Multiplier" }, |
2140 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_LINE_CURRENT, "Line Current" }, |
2141 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_CURRENT, "Active Current" }, |
2142 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_CURRENT, "Reactive Current" }, |
2143 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE, "RMS Voltage" }, |
2144 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MIN, "RMS Voltage Min" }, |
2145 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MAX, "RMS Voltage Max" }, |
2146 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT, "RMS Current" }, |
2147 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MIN, "RMS Current Min" }, |
2148 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MAX, "RMS Current Max" }, |
2149 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER, "Active Power" }, |
2150 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MIN, "Active Power Min" }, |
2151 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MAX, "Active Power Max" }, |
2152 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_POWER, "Reactive Power" }, |
2153 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_APPARENT_POWER, "Apparent Power" }, |
2154 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_FACTOR, "Power Factor" }, |
2155 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD, "Average RMS Voltage Measurement Period" }, |
2156 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE_COUNTER, "Average RMS Over Voltage Counter" }, |
2157 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER, "Average RMS Under Voltage Counter" }, |
2158 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE_PERIOD, "RMS Extreme Over Voltage Period" }, |
2159 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE_PERIOD, "RMS Extreme Under Voltage Period" }, |
2160 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG_PERIOD, "RMS Voltage Sag Period" }, |
2161 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL_PERIOD, "RMS Voltage Swell Period" }, |
2162 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_VOLTAGE_MULTIPLIER, "AC Voltage Multiplier" }, |
2163 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_VOLTAGE_DIVISOR, "AC Voltage Divisor" }, |
2164 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_CURRENT_MULTIPLIER, "AC Current Multiplier" }, |
2165 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_CURRENT_DIVISOR, "AC Current Divisor" }, |
2166 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_POWER_MULTIPLIER, "AC Power Multiplier" }, |
2167 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_POWER_DIVISOR, "AC Power Divisor" }, |
2168 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_OVERLOAD_ALARMS_MASK, "DC Overload Alarms Mask" }, |
2169 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_VOLTAGE_OVERLOAD, "DC Voltage Overload" }, |
2170 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_DC_CURRENT_OVERLOAD, "DC Current Overload" }, |
2171 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_ALARMS_MASK, "AC Alarms Mask" }, |
2172 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_VOLTAGE_OVERLOAD, "AC Voltage Overload" }, |
2173 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_CURRENT_OVERLOAD, "AC Current Overload" }, |
2174 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_ACTIVE_POWER_OVERLOAD, "AC Active Power Overload" }, |
2175 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AC_REACTIVE_POWER_OVERLOAD, "AC Reactive Power Overload" }, |
2176 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE, "Average RMS Over Voltage" }, |
2177 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE, "Average RMS Under Voltage" }, |
2178 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE, "RMS Extreme Over Voltage" }, |
2179 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE, "RMS Extreme Under Voltage" }, |
2180 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG, "RMS Voltage Sag" }, |
2181 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL, "RMS Voltage Swell" }, |
2182 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_LINE_CURRENT_PH_B, "Line Current Ph B" }, |
2183 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_CURRENT_PH_B, "Active Current Ph B" }, |
2184 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_CURRENT_PH_B, "Reactive Current Ph B" }, |
2185 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_PH_B, "RMS Voltage Ph B" }, |
2186 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MIN_PH_B, "RMS Voltage Min Ph B" }, |
2187 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MAX_PH_B, "RMS Voltage Max Ph B" }, |
2188 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_PH_B, "RMS Current Ph B" }, |
2189 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MIN_PH_B, "RMS Current Min Ph B" }, |
2190 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MAX_PH_B, "RMS Current Max Ph B" }, |
2191 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_PH_B, "Active Power Ph B" }, |
2192 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MIN_PH_B, "Active Power Min Ph B" }, |
2193 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MAX_PH_B, "Active Power Max Ph B" }, |
2194 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_POWER_PH_B, "Reactive Power Ph B" }, |
2195 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_APPARENT_POWER_PH_B, "Apparent Power Ph B" }, |
2196 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_FACTOR_PH_B, "Power Factor Ph B" }, |
2197 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PH_B, "Average RMS Voltage Measurement Period Ph B" }, |
2198 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_B, "Average RMS Over Voltage Counter Ph B" }, |
2199 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_B, "Average RMS Under Voltage Counter Ph B" }, |
2200 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_B, "RMS Extreme Over Voltage Period Ph B" }, |
2201 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_B, "RMS Extreme Under Voltage Period Ph B" }, |
2202 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG_PERIOD_PH_B, "RMS Voltage Sag Period Ph B" }, |
2203 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL_PERIOD_PH_B, "RMS Voltage Swell Period Ph B" }, |
2204 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_LINE_CURRENT_PH_C, "Line Current Ph C" }, |
2205 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_CURRENT_PH_C, "Reactive Current Ph C" }, |
2206 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_PH_C, "RMS Voltage Ph C" }, |
2207 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MIN_PH_C, "RMS Voltage Min Ph C" }, |
2208 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_MAX_PH_C, "RMS Voltage Max Ph C" }, |
2209 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_PH_C, "RMS Current Ph C" }, |
2210 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MIN_PH_C, "RMS Current Min Ph C" }, |
2211 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_CURRENT_MAX_PH_C, "RMS Current Max Ph C" }, |
2212 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_PH_C, "Active Power Ph C" }, |
2213 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MIN_PH_C, "Active Power Min Ph C" }, |
2214 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_ACTIVE_POWER_MAX_PH_C, "Active Power Max Ph C" }, |
2215 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_REACTIVE_POWER_PH_C, "Reactive Power Ph C" }, |
2216 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_APPARENT_POWER_PH_C, "Apparent Power Ph C" }, |
2217 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_POWER_FACTOR_PH_C, "Power Factor Ph C" }, |
2218 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PH_C, "Average RMS Voltage Measurement Period Ph C" }, |
2219 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_C, "Average RMS Over Voltage Counter Ph C" }, |
2220 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_C, "Average RMS Under Voltage Counter Ph C" }, |
2221 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_C, "RMS Extreme Over Voltage Period Ph C" }, |
2222 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_C, "RMS Extreme Under Voltage Period Ph C" }, |
2223 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SAG_PERIOD_PH_C, "RMS Voltage Sag Period Ph C" }, |
2224 | | { ZBEE_ZCL_ATTR_ID_ELEC_MES_RMS_VOLTAGE_SWELL_PERIOD_PH_C, "RMS Voltage Swell Period Ph C" }, |
2225 | | { 0, NULL } |
2226 | | }; |
2227 | | static value_string_ext zbee_zcl_elec_mes_attr_names_ext = VALUE_STRING_EXT_INIT(zbee_zcl_elec_mes_attr_names); |
2228 | | |
2229 | | /* Server Commands Received */ |
2230 | | static const value_string zbee_zcl_elec_mes_srv_rx_cmd_names[] = { |
2231 | | { ZBEE_ZCL_CMD_GET_PROFILE_INFO, "Get Profile Info", }, |
2232 | | { ZBEE_ZCL_CMD_GET_MEASUREMENT_PROFILE_INFO, "Get Measurement Profile", }, |
2233 | | { 0, NULL } |
2234 | | }; |
2235 | | |
2236 | | /* Server Commands Generated */ |
2237 | | static const value_string zbee_zcl_elec_mes_srv_tx_cmd_names[] = { |
2238 | | { ZBEE_ZCL_CMD_GET_PROFILE_INFO_RESPONSE, "Get Profile Info Response", }, |
2239 | | { ZBEE_ZCL_CMD_GET_MEASUREMENT_PROFILE_INFO_RESPONSE, "Get Measurement Profile Response", }, |
2240 | | { 0, NULL } |
2241 | | }; |
2242 | | |
2243 | | /* Profile Interval Period */ |
2244 | | static const value_string zbee_zcl_elec_mes_profile_interval_period_names[] = { |
2245 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_DAILY, "Daily", }, |
2246 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_60_MINUTES, "60 Minutes", }, |
2247 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_30_MINUTES, "30 Minutes", }, |
2248 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_15_MINUTES, "15 Minutes", }, |
2249 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_10_MINUTES, "10 Minutes", }, |
2250 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_7_5_MINUTES, "7.5 Minutes", }, |
2251 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_5_MINUTES, "5 Minutes", }, |
2252 | | { ZBEE_ZCL_ELEC_MES_PROFILE_INTERVAL_PERIOD_2_5_MINUTES, "2.5 Minutes", }, |
2253 | | { 0, NULL } |
2254 | | }; |
2255 | | |
2256 | | /* List of Status Valid Values */ |
2257 | | static const value_string zbee_zcl_elec_mes_status_names[] = { |
2258 | | { ZBEE_ZCL_ELEC_MES_STATUS_SUCCESS, "Success", }, |
2259 | | { ZBEE_ZCL_ELEC_MES_STATUS_ATTRIBUTE_PROFILE_NOT_SUPPORTED, "Attribute Profile not supported", }, |
2260 | | { ZBEE_ZCL_ELEC_MES_STATUS_INVALID_START_TIME, "Invalid Start Time", }, |
2261 | | { ZBEE_ZCL_ELEC_MES_STATUS_MORE_INTERVALS_REQUESTED_THAN_CAN_BE_RET, "More intervals requested than can be returned", }, |
2262 | | { ZBEE_ZCL_ELEC_MES_STATUS_NO_INTERVALS_AVAILABLE_FOR_THE_REQ_TIME, "No intervals available for the requested time", }, |
2263 | | { 0, NULL } |
2264 | | }; |
2265 | | |
2266 | | /*************************/ |
2267 | | /* Function Bodies */ |
2268 | | /*************************/ |
2269 | | |
2270 | | /** |
2271 | | *ZigBee ZCL Electrical Measurement cluster dissector for wireshark. |
2272 | | * |
2273 | | *@param tvb pointer to buffer containing raw packet. |
2274 | | *@param pinfo pointer to packet information fields |
2275 | | *@param tree pointer to data tree Wireshark uses to display packet. |
2276 | | */ |
2277 | | static int |
2278 | | dissect_zbee_zcl_elec_mes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) |
2279 | 6 | { |
2280 | 6 | proto_tree *payload_tree; |
2281 | 6 | zbee_zcl_packet *zcl; |
2282 | 6 | unsigned offset = 0; |
2283 | 6 | uint8_t cmd_id; |
2284 | 6 | int rem_len; |
2285 | | |
2286 | | /* Reject the packet if data is NULL */ |
2287 | 6 | if (data == NULL) |
2288 | 0 | return 0; |
2289 | 6 | zcl = (zbee_zcl_packet *)data; |
2290 | 6 | cmd_id = zcl->cmd_id; |
2291 | | |
2292 | | /* Create a subtree for the ZCL Command frame, and add the command ID to it. */ |
2293 | 6 | if (zcl->direction == ZBEE_ZCL_FCF_TO_SERVER) { |
2294 | | /* Append the command name to the info column. */ |
2295 | 2 | col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u", |
2296 | 2 | val_to_str_const(cmd_id, zbee_zcl_elec_mes_srv_rx_cmd_names, "Unknown Command"), |
2297 | 2 | zcl->tran_seqno); |
2298 | | |
2299 | | /* Add the command ID. */ |
2300 | 2 | proto_tree_add_uint(tree, hf_zbee_zcl_elec_mes_srv_rx_cmd_id, tvb, offset, 1, cmd_id); |
2301 | | |
2302 | | /* Check is this command has a payload, than add the payload tree */ |
2303 | 2 | rem_len = tvb_reported_length_remaining(tvb, ++offset); |
2304 | 2 | if (rem_len > 0) { |
2305 | 2 | payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_elec_mes, NULL, "Payload"); |
2306 | | |
2307 | | /* Call the appropriate command dissector */ |
2308 | 2 | switch (cmd_id) { |
2309 | | |
2310 | 1 | case ZBEE_ZCL_CMD_GET_PROFILE_INFO: |
2311 | | /* No Payload */ |
2312 | 1 | break; |
2313 | | |
2314 | 0 | case ZBEE_ZCL_CMD_GET_MEASUREMENT_PROFILE_INFO: |
2315 | 0 | dissect_zcl_elec_mes_get_measurement_profile_info(tvb, payload_tree, &offset); |
2316 | 0 | break; |
2317 | | |
2318 | 1 | default: |
2319 | 1 | break; |
2320 | 2 | } |
2321 | 2 | } |
2322 | 2 | } |
2323 | 4 | else { /* ZBEE_ZCL_FCF_TO_CLIENT */ |
2324 | | /* Append the command name to the info column. */ |
2325 | 4 | col_append_fstr(pinfo->cinfo, COL_INFO, "%s, Seq: %u", |
2326 | 4 | val_to_str_const(cmd_id, zbee_zcl_elec_mes_srv_tx_cmd_names, "Unknown Command"), |
2327 | 4 | zcl->tran_seqno); |
2328 | | |
2329 | | /* Add the command ID. */ |
2330 | 4 | proto_tree_add_uint(tree, hf_zbee_zcl_elec_mes_srv_tx_cmd_id, tvb, offset, 1, cmd_id); |
2331 | | |
2332 | | /* Check is this command has a payload, than add the payload tree */ |
2333 | 4 | rem_len = tvb_reported_length_remaining(tvb, ++offset); |
2334 | 4 | if (rem_len > 0) { |
2335 | 4 | payload_tree = proto_tree_add_subtree(tree, tvb, offset, rem_len, ett_zbee_zcl_elec_mes, NULL, "Payload"); |
2336 | | |
2337 | | /* Call the appropriate command dissector */ |
2338 | 4 | switch (cmd_id) { |
2339 | | |
2340 | 2 | case ZBEE_ZCL_CMD_GET_PROFILE_INFO_RESPONSE: |
2341 | 2 | dissect_zcl_elec_mes_get_profile_info_response(tvb, payload_tree, &offset); |
2342 | 2 | break; |
2343 | | |
2344 | 0 | case ZBEE_ZCL_CMD_GET_MEASUREMENT_PROFILE_INFO_RESPONSE: |
2345 | 0 | dissect_zcl_elec_mes_get_measurement_profile_info_response(tvb, payload_tree, &offset); |
2346 | 0 | break; |
2347 | | |
2348 | 2 | default: |
2349 | 2 | break; |
2350 | 4 | } |
2351 | 4 | } |
2352 | 4 | } |
2353 | | |
2354 | 5 | return tvb_captured_length(tvb); |
2355 | 6 | } /*dissect_zbee_zcl_elec_mes*/ |
2356 | | |
2357 | | /** |
2358 | | *This function is called by ZCL foundation dissector in order to decode |
2359 | | * |
2360 | | *@param tree pointer to data tree Wireshark uses to display packet. |
2361 | | *@param tvb pointer to buffer containing raw packet. |
2362 | | *@param offset pointer to buffer offset |
2363 | | *@param attr_id attribute identifier |
2364 | | *@param data_type attribute data type |
2365 | | *@param client_attr ZCL client |
2366 | | */ |
2367 | | static void |
2368 | | dissect_zcl_elec_mes_attr_data(proto_tree *tree, packet_info* pinfo, tvbuff_t *tvb, unsigned *offset, uint16_t attr_id, unsigned data_type, bool client_attr) |
2369 | 186 | { |
2370 | | /* Dissect attribute data type and data */ |
2371 | 186 | switch ( attr_id ) { |
2372 | 186 | default: |
2373 | 186 | dissect_zcl_attr_data(tvb, pinfo, tree, offset, data_type, client_attr); |
2374 | 186 | break; |
2375 | 186 | } |
2376 | 186 | } /*dissect_zcl_elec_mes_attr_data*/ |
2377 | | |
2378 | | /** |
2379 | | *This function manages the Get Measurement Profile Info payload |
2380 | | * |
2381 | | *@param tvb pointer to buffer containing raw packet. |
2382 | | *@param tree pointer to data tree Wireshark uses to display packet. |
2383 | | *@param offset pointer to offset from caller |
2384 | | */ |
2385 | | static void dissect_zcl_elec_mes_get_measurement_profile_info(tvbuff_t *tvb, proto_tree *tree, unsigned *offset) |
2386 | 0 | { |
2387 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_attr_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
2388 | 0 | *offset += 2; |
2389 | |
|
2390 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_start_time, tvb, *offset, 4, ENC_TIME_ZBEE_ZCL|ENC_LITTLE_ENDIAN); |
2391 | 0 | *offset += 4; |
2392 | |
|
2393 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_number_of_intervals, tvb, *offset, 1, ENC_NA); |
2394 | 0 | *offset += 1; |
2395 | 0 | } |
2396 | | |
2397 | | /** |
2398 | | *This function manages the Get Profile Info Response payload |
2399 | | * |
2400 | | *@param tvb pointer to buffer containing raw packet. |
2401 | | *@param tree pointer to data tree Wireshark uses to display packet. |
2402 | | *@param offset pointer to offset from caller |
2403 | | */ |
2404 | | static void dissect_zcl_elec_mes_get_profile_info_response(tvbuff_t *tvb, proto_tree *tree, unsigned *offset) |
2405 | 2 | { |
2406 | 2 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_profile_count, tvb, *offset, 1, ENC_NA); |
2407 | 2 | *offset += 1; |
2408 | | |
2409 | 2 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_profile_interval_period, tvb, *offset, 1, ENC_NA); |
2410 | 2 | *offset += 1; |
2411 | | |
2412 | 2 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_max_number_of_intervals, tvb, *offset, 1, ENC_NA); |
2413 | 2 | *offset += 1; |
2414 | | |
2415 | 38 | while (tvb_reported_length_remaining(tvb, *offset) > 0) { |
2416 | 36 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_attr_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
2417 | 36 | *offset += 2; |
2418 | 36 | } |
2419 | 2 | } |
2420 | | |
2421 | | /** |
2422 | | *This function manages the Get Measurement Profile Info Response payload |
2423 | | * |
2424 | | *@param tvb pointer to buffer containing raw packet. |
2425 | | *@param tree pointer to data tree Wireshark uses to display packet. |
2426 | | *@param offset pointer to offset from caller |
2427 | | */ |
2428 | | static void dissect_zcl_elec_mes_get_measurement_profile_info_response(tvbuff_t *tvb, proto_tree *tree, unsigned *offset) |
2429 | 0 | { |
2430 | 0 | unsigned rem_len; |
2431 | |
|
2432 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_start_time, tvb, *offset, 4, ENC_TIME_ZBEE_ZCL|ENC_LITTLE_ENDIAN); |
2433 | 0 | *offset += 4; |
2434 | |
|
2435 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_status, tvb, *offset, 1, ENC_NA); |
2436 | 0 | *offset += 1; |
2437 | |
|
2438 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_profile_interval_period, tvb, *offset, 1, ENC_NA); |
2439 | 0 | *offset += 1; |
2440 | |
|
2441 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_number_of_intervals_delivered, tvb, *offset, 1, ENC_NA); |
2442 | 0 | *offset += 1; |
2443 | |
|
2444 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_attr_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN); |
2445 | 0 | *offset += 2; |
2446 | |
|
2447 | 0 | rem_len = tvb_reported_length_remaining(tvb, *offset); |
2448 | 0 | proto_tree_add_item(tree, hf_zbee_zcl_elec_mes_intervals, tvb, *offset, rem_len, ENC_NA); |
2449 | 0 | *offset += rem_len; |
2450 | 0 | } |
2451 | | |
2452 | | /** |
2453 | | *This function registers the ZCL Occupancy Sensing dissector |
2454 | | * |
2455 | | */ |
2456 | | void |
2457 | | proto_register_zbee_zcl_elec_mes(void) |
2458 | 14 | { |
2459 | 14 | static hf_register_info hf[] = { |
2460 | | |
2461 | 14 | { &hf_zbee_zcl_elec_mes_srv_tx_cmd_id, |
2462 | 14 | { "Command", "zbee_zcl_meas_sensing.elecmes.cmd.srv_tx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_elec_mes_srv_tx_cmd_names), |
2463 | 14 | 0x0, NULL, HFILL } }, |
2464 | | |
2465 | 14 | { &hf_zbee_zcl_elec_mes_srv_rx_cmd_id, |
2466 | 14 | { "Command", "zbee_zcl_meas_sensing.elecmes.cmd.srv_rx.id", FT_UINT8, BASE_HEX, VALS(zbee_zcl_elec_mes_srv_rx_cmd_names), |
2467 | 14 | 0x0, NULL, HFILL } }, |
2468 | | |
2469 | 14 | { &hf_zbee_zcl_elec_mes_attr_id, |
2470 | 14 | { "Attribute", "zbee_zcl_meas_sensing.elecmes.attr_id", FT_UINT16, BASE_HEX | BASE_EXT_STRING, &zbee_zcl_elec_mes_attr_names_ext, |
2471 | 14 | 0x0, NULL, HFILL } }, |
2472 | | |
2473 | 14 | { &hf_zbee_zcl_elec_mes_start_time, |
2474 | 14 | { "Start Time", "zbee_zcl_meas_sensing.elecmes.start_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, |
2475 | 14 | 0x0, NULL, HFILL } }, |
2476 | | |
2477 | 14 | { &hf_zbee_zcl_elec_mes_number_of_intervals, |
2478 | 14 | { "Number of Intervals", "zbee_zcl_meas_sensing.elecmes.number_of_intervals", FT_UINT8, BASE_DEC, NULL, |
2479 | 14 | 0x0, NULL, HFILL } }, |
2480 | | |
2481 | 14 | { &hf_zbee_zcl_elec_mes_profile_count, |
2482 | 14 | { "Profile Count", "zbee_zcl_meas_sensing.elecmes.profile_count", FT_UINT8, BASE_DEC, NULL, |
2483 | 14 | 0x0, NULL, HFILL } }, |
2484 | | |
2485 | 14 | { &hf_zbee_zcl_elec_mes_profile_interval_period, |
2486 | 14 | { "Profile Interval Period", "zbee_zcl_meas_sensing.elecmes.profile_interval_period", FT_UINT8, BASE_DEC, NULL, |
2487 | 14 | 0x0, NULL, HFILL } }, |
2488 | | |
2489 | 14 | { &hf_zbee_zcl_elec_mes_max_number_of_intervals, |
2490 | 14 | { "Max Number of Intervals", "zbee_zcl_meas_sensing.elecmes.max_number_of_intervals", FT_UINT8, BASE_DEC, VALS(zbee_zcl_elec_mes_profile_interval_period_names), |
2491 | 14 | 0x0, NULL, HFILL } }, |
2492 | | |
2493 | 14 | { &hf_zbee_zcl_elec_mes_status, |
2494 | 14 | { "Status", "zbee_zcl_meas_sensing.elecmes.status", FT_UINT8, BASE_HEX, VALS(zbee_zcl_elec_mes_status_names), |
2495 | 14 | 0x0, NULL, HFILL } }, |
2496 | | |
2497 | 14 | { &hf_zbee_zcl_elec_mes_number_of_intervals_delivered, |
2498 | 14 | { "Number of Intervals Delivered", "zbee_zcl_meas_sensing.elecmes.number_of_intervals_delivered", FT_UINT8, BASE_DEC, NULL, |
2499 | 14 | 0x0, NULL, HFILL } }, |
2500 | | |
2501 | 14 | { &hf_zbee_zcl_elec_mes_intervals, |
2502 | 14 | { "Intervals", "zbee_zcl_meas_sensing.elecmes.intervals", FT_BYTES, BASE_NONE, NULL, |
2503 | 14 | 0x0, NULL, HFILL } } |
2504 | 14 | }; |
2505 | | |
2506 | | /* ZCL Electrical Measurement subtrees */ |
2507 | 14 | static int *ett[ZBEE_ZCL_ELEC_MES_NUM_ETT]; |
2508 | 14 | ett[0] = &ett_zbee_zcl_elec_mes; |
2509 | | |
2510 | | /* Register the ZigBee ZCL Electrical Measurement cluster protocol name and description */ |
2511 | 14 | proto_zbee_zcl_elec_mes = proto_register_protocol("ZigBee ZCL Electrical Measurement", "ZCL Electrical Measurement", ZBEE_PROTOABBREV_ZCL_ELECMES); |
2512 | 14 | proto_register_field_array(proto_zbee_zcl_elec_mes, hf, array_length(hf)); |
2513 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
2514 | | |
2515 | | /* Register the ZigBee ZCL Electrical Measurement dissector. */ |
2516 | 14 | register_dissector(ZBEE_PROTOABBREV_ZCL_ELECMES, dissect_zbee_zcl_elec_mes, proto_zbee_zcl_elec_mes); |
2517 | | |
2518 | 14 | } /*proto_register_zbee_zcl_elec_mes*/ |
2519 | | |
2520 | | |
2521 | | /** |
2522 | | *Hands off the ZCL Electrical Measurement dissector. |
2523 | | * |
2524 | | */ |
2525 | | void |
2526 | | proto_reg_handoff_zbee_zcl_elec_mes(void) |
2527 | 14 | { |
2528 | 14 | zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_ELECMES, |
2529 | 14 | proto_zbee_zcl_elec_mes, |
2530 | 14 | ett_zbee_zcl_elec_mes, |
2531 | 14 | ZBEE_ZCL_CID_ELECTRICAL_MEASUREMENT, |
2532 | 14 | ZBEE_MFG_CODE_NONE, |
2533 | 14 | hf_zbee_zcl_elec_mes_attr_id, |
2534 | 14 | -1, |
2535 | 14 | hf_zbee_zcl_elec_mes_srv_rx_cmd_id, |
2536 | 14 | hf_zbee_zcl_elec_mes_srv_tx_cmd_id, |
2537 | 14 | dissect_zcl_elec_mes_attr_data |
2538 | 14 | ); |
2539 | 14 | } /*proto_reg_handoff_zbee_zcl_elec_mes*/ |
2540 | | |
2541 | | /* |
2542 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
2543 | | * |
2544 | | * Local variables: |
2545 | | * c-basic-offset: 4 |
2546 | | * tab-width: 8 |
2547 | | * indent-tabs-mode: nil |
2548 | | * End: |
2549 | | * |
2550 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
2551 | | * :indentSize=4:tabSize=8:noTabs=true: |
2552 | | */ |