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