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
|
/* packet-zbee-zcl-misc.c
* Dissector routines for the ZigBee ZCL SE clusters like
* Messaging
* 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 <epan/packet.h>
#include "packet-zbee.h"
#include "packet-zbee-aps.h"
#include "packet-zbee-zcl.h"
/* ########################################################################## */
/* #### (0x0201) THERMOSTAT CLUSTER ######################################### */
/* ########################################################################## */
/* Cluster-specific commands and parameters */
#define ZBEE_ZCL_CSC_POLL_CONTROL_C_CIR 0x00
#define ZBEE_ZCL_CSC_POLL_CONTROL_C_FPS 0x01
#define ZBEE_ZCL_CSC_POLL_CONTROL_C_SLPI 0x02
#define ZBEE_ZCL_CSC_POLL_CONTROL_C_SSPI 0x03
#define ZBEE_ZCL_CSC_POLL_CONTROL_S_CI 0x00
#define ZBEE_ZCL_CSC_THERMOSTAT_C_CWS 0x03
#define ZBEE_ZCL_CSC_THERMOSTAT_C_GWS 0x02
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SRL 0x00
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS 0x01
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_AV 0x80
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_FR 0x20
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_MO 0x02
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_SA 0x40
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_SU 0x01
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_TH 0x10
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_TU 0x04
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_DOW_WE 0x08
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_SP_B 0x03
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_SP_C 0x02
#define ZBEE_ZCL_CSC_THERMOSTAT_C_SWS_SP_H 0x01
#define ZBEE_ZCL_CSC_THERMOSTAT_S_GWSR 0x00
#define ZBEE_ZCL_THERMOSTAT_NUM_ETT 3
/* Thermostat Information Attributes */
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP 0x0000
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OUTDOOR_TEMP 0x0001
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPANCY 0x0002
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_HEAT_SETPOINT 0x0003
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_HEAT_SETPOINT 0x0004
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_COOL_SETPOINT 0x0005
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_COOL_SETPOINT 0x0006
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_COOL_DEMAND 0x0007
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_HEAT_DEMAND 0x0008
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_HVAC_TYPE_CONFIG 0x0009
/* Thermostat Settings Attributes */
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP_CALIBRATION 0x0010
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_COOL_SETPOINT 0x0011
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_HEAT_SETPOINT 0x0012
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_COOL_SETPOINT 0x0013
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_HEAT_SETPOINT 0x0014
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_HEAT_SETPOINT 0x0015
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_HEAT_SETPOINT 0x0016
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_COOL_SETPOINT 0x0017
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_COOL_SETPOINT 0x0018
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_SETPOINT_DEADBAND 0x0019
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_REMOTE_SENSING 0x001A
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_CONTROL_SEQUENCE 0x001B
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SYSTEM_MODE 0x001C
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_ALARM_MASK 0x001D
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_MODE 0x001E
/* Schedule & HVAC Relay Attributes. */
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_START_OF_WEEK 0x0020
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_WEEKLY_TRANSITIONS 0x0021
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_DAILY_TRANSITIONS 0x0022
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD 0x0023
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD_DURATION 0x0024
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_PROGRAMMING_MODE 0x0025
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_STATE 0x0029
/* Setpoint Change Tracking Attributes. */
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_SOURCE 0x0030
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_AMOUNT 0x0031
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_CHANGE_TIME 0x0032
/* Air Conditioning Atrributes. */
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_TYPE 0x0040
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_CAPACITY 0x0041
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_REFRIGERANT_TYPE 0x0042
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_COMPRESSOR_TYPE 0x0043
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_ERROR_CODE 0x0044
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_LOUVER_POSITION 0x0045
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_COIL_TEMPERATURE 0x0046
#define ZBEE_ZCL_ATTR_ID_THERMOSTAT_AC_CAPACITY_FORMAT 0x0047
static const value_string zbee_zcl_thermostat_attr_names[] = {
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP, "LocalTemperature" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_OUTDOOR_TEMP, "OutdoorTemperature" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPANCY, "Occupancy" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_HEAT_SETPOINT, "AbsMinHeatSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_HEAT_SETPOINT, "AbsMaxHeatSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MIN_COOL_SETPOINT, "AbsMinCoolSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_ABS_MAX_COOL_SETPOINT, "AbsMaxCoolSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_COOL_DEMAND, "PICoolingDemand" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_PI_HEAT_DEMAND, "PIHeatingDemand" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_HVAC_TYPE_CONFIG, "HVACSystemTypeConfiguration" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_LOCAL_TEMP_CALIBRATION, "LocalTemperatureCalibration" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_COOL_SETPOINT, "OccupiedCoolingSetpoint" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_OCCUPIED_HEAT_SETPOINT, "OccupiedHeatingSetpoint" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_COOL_SETPOINT, "UnoccupiedCoolingSetpoint" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_UNOCCUPIED_HEAT_SETPOINT, "UnoccupiedHeatingSetpoint" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_HEAT_SETPOINT, "MinHeatSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_HEAT_SETPOINT, "MaxHeatSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_COOL_SETPOINT, "MinCoolSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_MAX_COOL_SETPOINT, "MaxCoolSetpointLimit" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_MIN_SETPOINT_DEADBAND, "MinSetpointDeadBand" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_REMOTE_SENSING, "RemoteSensing" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_CONTROL_SEQUENCE, "ControlSequenceOfOperation" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_SYSTEM_MODE, "SystemMode" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_ALARM_MASK, "AlarmMask" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_MODE, "ThermostatRunningMode" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_START_OF_WEEK, "StartOfWeek" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_WEEKLY_TRANSITIONS, "NumberOfWeeklyTransitions" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_NUM_DAILY_TRANSITIONS, "NumberOfDailyTransitions" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD, "TemperatureSetpointHold" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_SETPOINT_HOLD_DURATION, "TemperatureSetpointHoldDuration" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_PROGRAMMING_MODE, "ThermostatProgrammingOperationMode" },
{ ZBEE_ZCL_ATTR_ID_THERMOSTAT_RUNNING_STATE, "ThermostatRunningState" },
{ 0, NULL }
};
/* RemoteSensing bitmask. */
#define ZBEE_ZCL_THERMOSTAT_REMOTE_SENSE_LOCAL 0x01
#define ZBEE_ZCL_THERMOSTAT_REMOTE_SENSE_OUTDOOR 0x02
#define ZBEE_ZCL_THERMOSTAT_REMOTE_SENSE_OCCUPANCY 0x04
#define ZBEE_ZCL_THERMOSTAT_ALARM_INIT_FAILURE 0x01
#define ZBEE_ZCL_THERMOSTAT_ALARM_HARDWARE_FAILURE 0x02
#define ZBEE_ZCL_THERMOSTAT_ALARM_CALIBRATION_FAILURE 0x04
/* Programming operation mode bits. */
#define ZBEE_ZCL_THERMOSTAT_PROGRAM_MODE_SCHEDULE 0x01
#define ZBEE_ZCL_THERMOSTAT_PROGRAM_MODE_AUTO 0x02
#define ZBEE_ZCL_THERMOSTAT_PROGRAM_MODE_ENERGY_STAR 0x04
/* HVAC Running State bits. */
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_HEAT 0x0001
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_COOL 0x0002
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_FAN 0x0004
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_HEAT2 0x0008
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_COOL2 0x0010
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_FAN2 0x0020
#define ZBEE_ZCL_THERMOSTAT_RUNNING_STATE_FAN3 0x0040
/* Client-to-server commands. */
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_SETPOINT 0x00
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_SET_SCHEDULE 0x01
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE 0x02
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_CLEAR_SCHEDULE 0x03
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG 0x04
static const value_string zbee_zcl_thermostat_srv_rx_cmd_names[] = {
{ ZBEE_ZCL_CMD_ID_THERMOSTAT_SETPOINT, "Setpoint Raise/Lower" },
{ ZBEE_ZCL_CMD_ID_THERMOSTAT_SET_SCHEDULE, "Set Weekly Schedule" },
{ ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE, "Get Weekly Schedule" },
{ ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG, "Get Relay Status Log" },
{ 0, NULL }
};
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE_RESPONSE 0x00
#define ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG_RESPONSE 0x01
static const value_string zbee_zcl_thermostat_srv_tx_cmd_names[] = {
{ ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE_RESPONSE, "Get Weekly Schedule Response" },
{ ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG_RESPONSE,"Get Relay Status Log Response" },
{ 0, NULL }
};
#define ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_HEAT 0x01
#define ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_COOL 0x02
/* Setpoint mode names. */
static const value_string zbee_zcl_thermostat_setpoint_mode_names[] = {
{ 0, "Heat" },
{ 1, "Cool" },
{ 2, "Both" },
{ 0, NULL }
};
/*************************/
/* Global Variables */
/*************************/
static int proto_zbee_zcl_thermostat = -1;
static int hf_zbee_zcl_thermostat_attr_id = -1;
static int hf_zbee_zcl_thermostat_srv_rx_cmd_id = -1;
static int hf_zbee_zcl_thermostat_srv_tx_cmd_id = -1;
static int hf_zbee_zcl_thermostat_setpoint_mode = -1;
static int hf_zbee_zcl_thermostat_setpoint_amount = -1;
static int hf_zbee_zcl_thermostat_schedule_num_trans = -1;
static int hf_zbee_zcl_thermostat_schedule_day_sequence = -1;
static int hf_zbee_zcl_thermostat_schedule_day_sunday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_monday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_tuesday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_wednesday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_thursday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_friday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_saturday = -1;
static int hf_zbee_zcl_thermostat_schedule_day_vacation = -1;
static int hf_zbee_zcl_thermostat_schedule_mode_sequence = -1;
static int hf_zbee_zcl_thermostat_schedule_mode_heat = -1;
static int hf_zbee_zcl_thermostat_schedule_mode_cool = -1;
static int hf_zbee_zcl_thermostat_schedule_time = -1;
static int hf_zbee_zcl_thermostat_schedule_heat = -1;
static int hf_zbee_zcl_thermostat_schedule_cool = -1;
static gint ett_zbee_zcl_thermostat = -1;
static gint ett_zbee_zcl_thermostat_schedule_days = -1;
static gint ett_zbee_zcl_thermostat_schedule_mode = -1;
/*************************/
/* Function Declarations */
/*************************/
void proto_register_zbee_zcl_thermostat(void);
void proto_reg_handoff_zbee_zcl_thermostat(void);
/* Attribute Dissector Helpers */
static void dissect_zcl_thermostat_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr);
static int dissect_zcl_thermostat_schedule(proto_tree *tree, tvbuff_t *tvb, guint offset);
static void dissect_zcl_thermostat_schedule_days(proto_tree *tree, tvbuff_t *tvb, guint offset);
static void dissect_zcl_thermostat_schedule_mode(proto_tree *tree, tvbuff_t *tvb, guint offset);
/**
*Helper function to dissect a Thermostat scheduling days bitmask.
*
*@param tree pointer to data tree Wireshark uses to display packet.
*@param tvb pointer to buffer containing raw packet.
*@param offset payload offset of the ZoneStatus value.
*/
static void
dissect_zcl_thermostat_schedule_days(proto_tree *tree, tvbuff_t *tvb, guint offset)
{
static int * const thermostat_schedule_days[] = {
&hf_zbee_zcl_thermostat_schedule_day_sunday,
&hf_zbee_zcl_thermostat_schedule_day_monday,
&hf_zbee_zcl_thermostat_schedule_day_tuesday,
&hf_zbee_zcl_thermostat_schedule_day_wednesday,
&hf_zbee_zcl_thermostat_schedule_day_thursday,
&hf_zbee_zcl_thermostat_schedule_day_friday,
&hf_zbee_zcl_thermostat_schedule_day_saturday,
&hf_zbee_zcl_thermostat_schedule_day_vacation,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_zcl_thermostat_schedule_day_sequence,
ett_zbee_zcl_thermostat_schedule_days, thermostat_schedule_days, ENC_NA);
} /* dissect_zcl_thermostat_schedule_days */
/**
*Helper function to dissect a Thermostat scheduling mode bitmask.
*
*@param tree pointer to data tree Wireshark uses to display packet.
*@param tvb pointer to buffer containing raw packet.
*@param offset payload offset of the ZoneStatus value.
*/
static void
dissect_zcl_thermostat_schedule_mode(proto_tree *tree, tvbuff_t *tvb, guint offset)
{
static int * const thermostat_schedule_modes[] = {
&hf_zbee_zcl_thermostat_schedule_mode_heat,
&hf_zbee_zcl_thermostat_schedule_mode_cool,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_zcl_thermostat_schedule_mode_sequence,
ett_zbee_zcl_thermostat_schedule_mode, thermostat_schedule_modes, ENC_NA);
}
/**
*Helper function to dissect a Thermostat schedule, which has
*
*@param tree pointer to data tree Wireshark uses to display packet.
*@param tvb pointer to buffer containing raw packet.
*@param offset payload offset of the ZoneStatus value.
*@return length of parsed data.
*/
static int
dissect_zcl_thermostat_schedule(proto_tree *tree, tvbuff_t *tvb, guint offset)
{
guint start = offset;
guint8 num_transitions;
guint8 mode_sequence;
int i;
num_transitions = tvb_get_guint8(tvb, offset);
proto_tree_add_uint(tree, hf_zbee_zcl_thermostat_schedule_num_trans, tvb, offset, 1,
num_transitions);
offset++;
dissect_zcl_thermostat_schedule_days(tree, tvb, offset);
offset++;
mode_sequence = tvb_get_guint8(tvb, offset);
dissect_zcl_thermostat_schedule_mode(tree, tvb, offset);
offset++;
/* Parse the list of setpoint transitions. */
for (i = 0; i < num_transitions; i++) {
nstime_t tv;
tv.secs = tvb_get_letohs(tvb, offset) * 60;
tv.nsecs = 0;
proto_tree_add_time(tree, hf_zbee_zcl_thermostat_schedule_time, tvb, offset, 2, &tv);
offset += 2;
if (mode_sequence & ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_HEAT) {
float setpoint = tvb_get_letohis(tvb, offset);
proto_tree_add_float(tree, hf_zbee_zcl_thermostat_schedule_heat,
tvb, offset, 2, (setpoint / 100.0f));
offset += 2;
}
if (mode_sequence & ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_COOL) {
float setpoint = tvb_get_letohis(tvb, offset);
proto_tree_add_float(tree, hf_zbee_zcl_thermostat_schedule_cool,
tvb, offset, 2, (setpoint / 100.0f));
offset += 2;
}
} /* for */
/* Return the number of bytes parsed. */
return (offset - start);
} /* dissect_zcl_thermostat_cmd_schedule */
/**
*ZigBee ZCL Thermostat 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.
*@param data pointer to ZCL packet structure.
*@return length of parsed data.
*/
static int
dissect_zbee_zcl_thermostat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
zbee_zcl_packet *zcl;
guint offset = 0;
guint8 cmd_id;
float amount;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
zcl = (zbee_zcl_packet *)data;
cmd_id = zcl->cmd_id;
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_thermostat_srv_rx_cmd_names, "Unknown Command"),
zcl->tran_seqno);
/* Add the command ID. */
proto_tree_add_item(tree, hf_zbee_zcl_thermostat_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
/* Handle the command dissection. */
switch (cmd_id) {
case ZBEE_ZCL_CMD_ID_THERMOSTAT_SETPOINT:
/* Setpoint Raise/Lower. */
proto_tree_add_item(tree, hf_zbee_zcl_thermostat_setpoint_mode,
tvb, offset, 1, ENC_NA);
offset++;
amount = tvb_get_gint8(tvb, offset);
proto_tree_add_float(tree, hf_zbee_zcl_thermostat_setpoint_amount,
tvb, offset, 1, (amount / 100.0f));
offset++;
break;
case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE:
/* Get Weekly Schedule. */
dissect_zcl_thermostat_schedule_days(tree, tvb, offset);
offset++;
dissect_zcl_thermostat_schedule_mode(tree, tvb, offset);
offset++;
break;
case ZBEE_ZCL_CMD_ID_THERMOSTAT_SET_SCHEDULE:
/* Set Weekly Schedule. */
dissect_zcl_thermostat_schedule(tree, tvb, offset);
break;
case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG:
/* No Payload - fall-through. */
default:
break;
} /* switch */
} else {
/* 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_thermostat_srv_tx_cmd_names, "Unknown Command"),
zcl->tran_seqno);
/* Add the command ID. */
proto_tree_add_item(tree, hf_zbee_zcl_thermostat_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
/* Handle the command dissection. */
switch (cmd_id) {
case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_SCHEDULE_RESPONSE:
/* Get Weekly Schedule Response. */
dissect_zcl_thermostat_schedule(tree, tvb, offset);
break;
case ZBEE_ZCL_CMD_ID_THERMOSTAT_GET_RELAY_LOG_RESPONSE:
/* TODO: Implement Me! */
default:
break;
} /* switch */
}
return tvb_captured_length(tvb);
} /* dissect_zbee_zcl_thermostat */
/**
*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_thermostat_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean 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_thermostat_attr_data*/
/**
*ZigBee ZCL IAS Zone cluste protocol registration.
*
*/
void
proto_register_zbee_zcl_thermostat(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_zbee_zcl_thermostat_attr_id,
{ "Attribute", "zbee_zcl_hvac.thermostat.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_thermostat_attr_names),
0x0, NULL, HFILL } },
{ &hf_zbee_zcl_thermostat_srv_rx_cmd_id,
{ "Command", "zbee_zcl_hvac.thermostat.cmd.srv_rx.id", FT_UINT8, BASE_HEX,
VALS(zbee_zcl_thermostat_srv_rx_cmd_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_srv_tx_cmd_id,
{ "Command", "zbee_zcl_hvac.thermostat.cmd.srv_tx.id", FT_UINT8, BASE_HEX,
VALS(zbee_zcl_thermostat_srv_tx_cmd_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_setpoint_mode,
{ "Mode", "zbee_zcl_hvac.thermostat.mode", FT_UINT8, BASE_HEX,
VALS(zbee_zcl_thermostat_setpoint_mode_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_setpoint_amount,
{ "Amount", "zbee_zcl_hvac.thermostat.amount", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_num_trans,
{ "Number of Transitions for Sequence", "zbee_zcl_hvac.thermostat.num_trans", FT_UINT8, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_sequence,
{ "Days of Week for Sequence", "zbee_zcl_hvac.thermostat.day_sequence", FT_UINT8, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_sunday,
{ "Sunday", "zbee_zcl_hvac.thermostat.day.sunday", FT_BOOLEAN, 8, NULL, 0x01, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_monday,
{ "Monday", "zbee_zcl_hvac.thermostat.day.monday", FT_BOOLEAN, 8, NULL, 0x02, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_tuesday,
{ "Tuesday", "zbee_zcl_hvac.thermostat.day.tuesday", FT_BOOLEAN, 8, NULL, 0x04, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_wednesday,
{ "Wednesday", "zbee_zcl_hvac.thermostat.day.wednesday", FT_BOOLEAN, 8, NULL, 0x08, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_thursday,
{ "Thursday", "zbee_zcl_hvac.thermostat.day.thursday", FT_BOOLEAN, 8, NULL, 0x10, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_friday,
{ "Friday", "zbee_zcl_hvac.thermostat.day.friday", FT_BOOLEAN, 8, NULL, 0x20, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_saturday,
{ "Saturday", "zbee_zcl_hvac.thermostat.day.saturday", FT_BOOLEAN, 8, NULL, 0x40, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_day_vacation,
{ "Away/Vacation", "zbee_zcl_hvac.thermostat.day.vacation", FT_BOOLEAN, 8, NULL, 0x80, NULL,
HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_mode_sequence,
{ "Mode for Sequence", "zbee_zcl_hvac.thermostat.mode_sequence", FT_UINT8, BASE_HEX, NULL,
0x0, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_mode_heat,
{ "Heating", "zbee_zcl_hvac.thermostat.mode.heat", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_mode_cool,
{ "Cooling", "zbee_zcl_hvac.thermostat.mode.cool", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_time,
{ "Transition Time", "zbee_zcl_hvac.thermostat.time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"Setpoint transition time relative to midnight of the scheduled day", HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_heat,
{ "Heating Setpoint", "zbee_zcl_hvac.thermostat.heat", FT_FLOAT, BASE_NONE, NULL, 0x0,
"Heating setpoint in degrees Celsius", HFILL }},
{ &hf_zbee_zcl_thermostat_schedule_cool,
{ "Cooling Setpoint", "zbee_zcl_hvac.thermostat.cool", FT_FLOAT, BASE_NONE, NULL, 0x0,
"Cooling setpoint in degrees Celsius", HFILL }}
};
/* ZCL IAS Zone subtrees */
static gint *ett[ZBEE_ZCL_THERMOSTAT_NUM_ETT];
ett[0] = &ett_zbee_zcl_thermostat;
ett[1] = &ett_zbee_zcl_thermostat_schedule_days;
ett[2] = &ett_zbee_zcl_thermostat_schedule_mode;
/* Register the ZigBee ZCL IAS Zoben cluster protocol name and description */
proto_zbee_zcl_thermostat = proto_register_protocol("ZigBee ZCL Thermostat", "ZCL Thermostat", ZBEE_PROTOABBREV_ZCL_THERMOSTAT);
proto_register_field_array(proto_zbee_zcl_thermostat, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Register the ZigBee ZCL IAS Zone dissector. */
register_dissector(ZBEE_PROTOABBREV_ZCL_THERMOSTAT, dissect_zbee_zcl_thermostat, proto_zbee_zcl_thermostat);
} /*proto_register_zbee_zcl_thermostat*/
/**
*Hands off the ZCL Thermostat dissector.
*
*/
void
proto_reg_handoff_zbee_zcl_thermostat(void)
{
zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_THERMOSTAT,
proto_zbee_zcl_thermostat,
ett_zbee_zcl_thermostat,
ZBEE_ZCL_CID_THERMOSTAT,
ZBEE_MFG_CODE_NONE,
hf_zbee_zcl_thermostat_attr_id,
hf_zbee_zcl_thermostat_attr_id,
hf_zbee_zcl_thermostat_srv_rx_cmd_id,
hf_zbee_zcl_thermostat_srv_tx_cmd_id,
(zbee_zcl_fn_attr_data)dissect_zcl_thermostat_attr_data
);
} /*proto_reg_handoff_zbee_zcl_thermostat*/
/* ########################################################################## */
/* #### (0x0500) IAS ZONE CLUSTER ########################################### */
/* ########################################################################## */
#define ZBEE_ZCL_IAS_ZONE_NUM_ETT 2
/* IAS Zone Server Attributes */
#define ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATE 0x0000
#define ZBEE_ZCL_ATTR_ID_IAS_ZONE_TYPE 0x0001
#define ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATUS 0x0002
#define ZBEE_ZCL_ATTR_ID_IAS_CIE_ADDRESS 0x0010
static const value_string zbee_zcl_ias_zone_attr_names[] = {
{ ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATE, "ZoneState" },
{ ZBEE_ZCL_ATTR_ID_IAS_ZONE_TYPE, "ZoneType" },
{ ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATUS, "ZoneStatus" },
{ ZBEE_ZCL_ATTR_ID_IAS_CIE_ADDRESS, "IAS_CIE_Address" },
{ 0, NULL }
};
/* IAS Zone States */
#define ZBEE_IAS_ZONE_STATE_NOT_ENROLLED 0x00
#define ZBEE_IAS_ZONE_STATE_ENROLLED 0x01
static const value_string zbee_ias_state_names[] = {
{ ZBEE_IAS_ZONE_STATE_NOT_ENROLLED, "Not Enrolled" },
{ ZBEE_IAS_ZONE_STATE_ENROLLED, "Enrolled" },
{ 0, NULL }
};
/* IAS Zone Type values. */
#define ZBEE_IAS_ZONE_TYPE_STANDARD_CIE 0x0000
#define ZBEE_IAS_ZONE_TYPE_MOTION_SENSOR 0x000D
#define ZBEE_IAS_ZONE_TYPE_CONTACT_SWITCH 0x0015
#define ZBEE_IAS_ZONE_TYPE_FIRE_SENSOR 0x0028
#define ZBEE_IAS_ZONE_TYPE_WATER_SENSOR 0x002A
#define ZBEE_IAS_ZONE_TYPE_GAS_SENSOR 0x002B
#define ZBEE_IAS_ZONE_TYPE_PERSONAL_EMERGENCY 0x002C
#define ZBEE_IAS_ZONE_TYPE_VIBRATION_SENSOR 0x002D
#define ZBEE_IAS_ZONE_TYPE_REMOTE_CONTROL 0x010F
#define ZBEE_IAS_ZONE_TYPE_KEY_FOB 0x0115
#define ZBEE_IAS_ZONE_TYPE_KEYPAD 0x021D
#define ZBEE_IAS_ZONE_TYPE_STANDARD_WARNING 0x0225
#define ZBEE_IAS_ZONE_TYPE_INVALID_ZONE_TYPE 0xFFFF
#define ZBEE_IAS_ZONE_STATUS_ALARM1 0x0001
#define ZBEE_IAS_ZONE_STATUS_ALARM2 0x0002
#define ZBEE_IAS_ZONE_STATUS_TAMPER 0x0004
#define ZBEE_IAS_ZONE_STATUS_BATTERY 0x0008
#define ZBEE_IAS_ZONE_STATUS_SUPERVISION 0x0010
#define ZBEE_IAS_ZONE_STATUS_RESTORE 0x0020
#define ZBEE_IAS_ZONE_STATUS_TROUBLE 0x0040
#define ZBEE_IAS_ZONE_STATUS_AC_MAINS 0x0080
static const value_string zbee_ias_type_names[] = {
{ ZBEE_IAS_ZONE_TYPE_STANDARD_CIE, "Standard CIE" },
{ ZBEE_IAS_ZONE_TYPE_MOTION_SENSOR, "Motion sensor" },
{ ZBEE_IAS_ZONE_TYPE_CONTACT_SWITCH, "Contact switch" },
{ ZBEE_IAS_ZONE_TYPE_FIRE_SENSOR, "Fire sensor" },
{ ZBEE_IAS_ZONE_TYPE_WATER_SENSOR, "Water sensor" },
{ ZBEE_IAS_ZONE_TYPE_GAS_SENSOR, "Gas sensor" },
{ ZBEE_IAS_ZONE_TYPE_PERSONAL_EMERGENCY, "Personal emergency device" },
{ ZBEE_IAS_ZONE_TYPE_VIBRATION_SENSOR, "Vibration/movement sensor" },
{ ZBEE_IAS_ZONE_TYPE_REMOTE_CONTROL, "Remote control" },
{ ZBEE_IAS_ZONE_TYPE_KEY_FOB, "Key fob" },
{ ZBEE_IAS_ZONE_TYPE_KEYPAD, "Keypad" },
{ ZBEE_IAS_ZONE_TYPE_STANDARD_WARNING, "Standard warning device" },
{ ZBEE_IAS_ZONE_TYPE_INVALID_ZONE_TYPE, "Invalid zone type" },
{ 0, NULL }
};
/* Server-to-client command IDs. */
#define ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_NOTIFY 0x00
#define ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_REQUEST 0x01
static const value_string zbee_zcl_ias_zone_srv_tx_cmd_names[] = {
{ ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_REQUEST, "Zone Enroll Request" },
{ ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_NOTIFY, "Zone Status Change Notification" },
{ 0, NULL }
};
/* Client-to-server command IDs. */
#define ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_RESPONSE 0x00
static const value_string zbee_zcl_ias_zone_srv_rx_cmd_names[] = {
{ ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_RESPONSE, "Zone Enroll Response" },
{ 0, NULL }
};
static const value_string zbee_zcl_ias_zone_enroll_code_names[] = {
{ 0, "Success" },
{ 1, "Not Supported" },
{ 2, "No enroll permit" },
{ 3, "Too many zones" },
{ 0, NULL }
};
/*************************/
/* Global Variables */
/*************************/
/* Initialize the protocol and registered fields */
static int proto_zbee_zcl_ias_zone = -1;
static int hf_zbee_zcl_ias_zone_attr_id = -1;
static int hf_zbee_zcl_ias_zone_srv_rx_cmd_id = -1;
static int hf_zbee_zcl_ias_zone_srv_tx_cmd_id = -1;
static int hf_zbee_zcl_ias_zone_enroll_code = -1;
static int hf_zbee_zcl_ias_zone_zone_id = -1;
static int hf_zbee_zcl_ias_zone_state = -1;
static int hf_zbee_zcl_ias_zone_type = -1;
static int hf_zbee_zcl_ias_zone_status = -1;
static int hf_zbee_zcl_ias_zone_delay = -1;
static int hf_zbee_zcl_ias_zone_ext_status = -1;
static int hf_zbee_zcl_ias_zone_manufacturer_code = -1;
static int hf_zbee_zcl_ias_zone_status_ac_mains = -1;
static int hf_zbee_zcl_ias_zone_status_alarm1 = -1;
static int hf_zbee_zcl_ias_zone_status_alarm2 = -1;
static int hf_zbee_zcl_ias_zone_status_battery = -1;
static int hf_zbee_zcl_ias_zone_status_restore_reports = -1;
static int hf_zbee_zcl_ias_zone_status_supervision_reports = -1;
static int hf_zbee_zcl_ias_zone_status_tamper = -1;
static int hf_zbee_zcl_ias_zone_status_trouble = -1;
static const true_false_string tfs_ac_mains = {
"AC/Mains fault",
"AC/Mains OK"
};
static const true_false_string tfs_alarmed_or_not = {
"Opened or alarmed",
"Closed or not alarmed"
};
static const true_false_string tfs_battery = {
"Low battery",
"Battery OK"
};
static const true_false_string tfs_reports_or_not = {
"Reports",
"Does not report"
};
static const true_false_string tfs_reports_restore = {
"Reports restore",
"Does not report restore"
};
static const true_false_string tfs_tampered_or_not = {
"Tampered",
"Not tampered"
};
static const true_false_string tfs_trouble_failure = {
"Trouble/Failure",
"OK"
};
static gint ett_zbee_zcl_ias_zone = -1;
static gint ett_zbee_zcl_ias_zone_status = -1;
/*************************/
/* Function Declarations */
/*************************/
void proto_register_zbee_zcl_ias_zone(void);
void proto_reg_handoff_zbee_zcl_ias_zone(void);
/* Command Dissector Helpers. */
static int dissect_zbee_zcl_ias_zone (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
/* Attribute Dissector Helpers */
static void dissect_zcl_ias_zone_attr_data (proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr);
/* ZoneStatus bitmask helper */
static void dissect_zcl_ias_zone_status (proto_tree *tree, tvbuff_t *tvb, guint offset);
/**
*Helper function to dissect the IAS ZoneStatus bitmask.
*
*@param tree pointer to data tree Wireshark uses to display packet.
*@param tvb pointer to buffer containing raw packet.
*@param offset payload offset of the ZoneStatus value.
*/
static void
dissect_zcl_ias_zone_status(proto_tree *tree, tvbuff_t *tvb, guint offset)
{
static int * const ias_zone_statuses[] = {
&hf_zbee_zcl_ias_zone_status_alarm1,
&hf_zbee_zcl_ias_zone_status_alarm2,
&hf_zbee_zcl_ias_zone_status_tamper,
&hf_zbee_zcl_ias_zone_status_battery,
&hf_zbee_zcl_ias_zone_status_supervision_reports,
&hf_zbee_zcl_ias_zone_status_restore_reports,
&hf_zbee_zcl_ias_zone_status_trouble,
&hf_zbee_zcl_ias_zone_status_ac_mains,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_zcl_ias_zone_status, ett_zbee_zcl_ias_zone_status, ias_zone_statuses, ENC_LITTLE_ENDIAN);
} /* dissect_zcl_ias_zone_status */
/**
*ZigBee ZCL IAS Zone 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.
*@param data pointer to ZCL packet structure.
*@return length of parsed data.
*/
static int
dissect_zbee_zcl_ias_zone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
zbee_zcl_packet *zcl;
guint offset = 0;
guint8 cmd_id;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
zcl = (zbee_zcl_packet *)data;
cmd_id = zcl->cmd_id;
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_ias_zone_srv_rx_cmd_names, "Unknown Command"),
zcl->tran_seqno);
/* Add the command ID. */
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_srv_rx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
/* Handle the command dissection. */
switch (cmd_id) {
case ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_RESPONSE:
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_enroll_code, tvb, offset, 1, ENC_NA);
offset++;
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_zone_id, tvb, offset, 1, ENC_NA);
offset++;
break;
default:
break;
} /* switch */
} else {
/* 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_ias_zone_srv_tx_cmd_names, "Unknown Command"),
zcl->tran_seqno);
/* Add the command ID. */
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_srv_tx_cmd_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
/* Handle the command dissection. */
switch (cmd_id) {
case ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_NOTIFY:
dissect_zcl_ias_zone_status(tree, tvb, offset);
offset += 2;
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_ext_status, tvb, offset,
1, ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_zone_id, tvb, offset, 1,
ENC_NA);
offset += 1;
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_delay, tvb, offset, 2,
ENC_LITTLE_ENDIAN);
break;
case ZBEE_ZCL_CMD_ID_IAS_ZONE_ENROLL_REQUEST:
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_type, tvb, offset, 2,
ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_manufacturer_code,
tvb, offset, 2, ENC_LITTLE_ENDIAN);
break;
default:
break;
} /* switch */
}
return tvb_reported_length(tvb);
} /* dissect_zbee_zcl_ias_zone */
/**
*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_ias_zone_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type, gboolean client_attr)
{
/* Dissect attribute data type and data */
switch (attr_id) {
case ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATE:
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_state, tvb, *offset, 1, ENC_NA);
*offset += 1;
break;
case ZBEE_ZCL_ATTR_ID_IAS_ZONE_TYPE:
proto_tree_add_item(tree, hf_zbee_zcl_ias_zone_type, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
*offset += 2;
break;
case ZBEE_ZCL_ATTR_ID_IAS_ZONE_STATUS:
dissect_zcl_ias_zone_status(tree, tvb, *offset);
*offset += 2;
break;
case ZBEE_ZCL_ATTR_ID_IAS_CIE_ADDRESS:
default:
dissect_zcl_attr_data(tvb, tree, offset, data_type, client_attr);
break;
}
} /*dissect_zcl_ias_zone_attr_data*/
/**
*Hands off the ZCL IAS Zone dissector.
*
*/
void
proto_reg_handoff_zbee_zcl_ias_zone(void)
{
zbee_zcl_init_cluster( ZBEE_PROTOABBREV_ZCL_IAS_ZONE,
proto_zbee_zcl_ias_zone,
ett_zbee_zcl_ias_zone,
ZBEE_ZCL_CID_IAS_ZONE,
ZBEE_MFG_CODE_NONE,
hf_zbee_zcl_ias_zone_attr_id,
hf_zbee_zcl_ias_zone_attr_id,
hf_zbee_zcl_ias_zone_srv_rx_cmd_id,
hf_zbee_zcl_ias_zone_srv_tx_cmd_id,
(zbee_zcl_fn_attr_data)dissect_zcl_ias_zone_attr_data
);
} /*proto_reg_handoff_zbee_zcl_ias_zone*/
/**
*ZigBee ZCL IAS Zone cluste protocol registration.
*
*/
void
proto_register_zbee_zcl_ias_zone(void)
{
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_zbee_zcl_ias_zone_attr_id,
{ "Attribute", "zbee_zcl_ias.zone.attr_id", FT_UINT16, BASE_HEX, VALS(zbee_zcl_ias_zone_attr_names),
0x0, NULL, HFILL } },
{ &hf_zbee_zcl_ias_zone_srv_rx_cmd_id,
{ "Command", "zbee_zcl_ias.zone.cmd.srv_rx.id", FT_UINT8, BASE_HEX,
VALS(zbee_zcl_ias_zone_srv_rx_cmd_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_srv_tx_cmd_id,
{ "Command", "zbee_zcl_ias.zone.cmd.srv_tx.id", FT_UINT8, BASE_HEX,
VALS(zbee_zcl_ias_zone_srv_tx_cmd_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_enroll_code,
{ "Enroll response code", "zbee_zcl_ias.zone.enroll_code", FT_UINT8, BASE_HEX,
VALS(zbee_zcl_ias_zone_enroll_code_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_zone_id,
{ "Zone ID", "zbee_zcl_ias.zone.zone_id", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_state,
{ "ZoneState", "zbee_zcl_ias.zone.state", FT_UINT16, BASE_HEX, VALS(zbee_ias_state_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_type,
{ "ZoneType", "zbee_zcl_ias.zone.type", FT_UINT16, BASE_HEX, VALS(zbee_ias_type_names), 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_manufacturer_code,
{ "ManufacturerCode", "zbee_zcl_ias.zone.manufacturer_code", FT_UINT16, BASE_HEX, VALS(zbee_mfr_code_names),
0x0, NULL, HFILL } },
{ &hf_zbee_zcl_ias_zone_status,
{ "ZoneStatus", "zbee_zcl_ias.zone.status", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_delay,
{ "Delay (in quarterseconds)", "zbee_zcl_ias.zone.delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_ext_status,
{ "Extended Status", "zbee_zcl_ias.zone.ext_status", FT_UINT8, BASE_HEX, NULL, 0x0, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_status_alarm1,
{ "Alarm 1", "zbee_zcl_ias.zone.status.alarm_1", FT_BOOLEAN, 16, TFS(&tfs_alarmed_or_not), ZBEE_IAS_ZONE_STATUS_ALARM1, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_status_alarm2,
{ "Alarm 2", "zbee_zcl_ias.zone.status.alarm_2", FT_BOOLEAN, 16, TFS(&tfs_alarmed_or_not), ZBEE_IAS_ZONE_STATUS_ALARM2, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_status_battery,
{ "Battery", "zbee_zcl_ias.zone.status.battery", FT_BOOLEAN, 16, TFS(&tfs_battery), ZBEE_IAS_ZONE_STATUS_BATTERY, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_status_tamper,
{ "Tamper", "zbee_zcl_ias.zone.status.tamper", FT_BOOLEAN, 16, TFS(&tfs_tampered_or_not), ZBEE_IAS_ZONE_STATUS_TAMPER, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_status_supervision_reports,
{ "Supervision Reports", "zbee_zcl_ias.zone.status.supervision_reports", FT_BOOLEAN, 16,
TFS(&tfs_reports_or_not), ZBEE_IAS_ZONE_STATUS_SUPERVISION, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_status_restore_reports,
{ "Restore Reports", "zbee_zcl_ias.zone.status.restore_reports", FT_BOOLEAN, 16,
TFS(&tfs_reports_restore), ZBEE_IAS_ZONE_STATUS_RESTORE, NULL, HFILL }},
{ &hf_zbee_zcl_ias_zone_status_trouble,
{ "Trouble", "zbee_zcl_ias.zone.status.trouble", FT_BOOLEAN, 16, TFS(&tfs_trouble_failure), ZBEE_IAS_ZONE_STATUS_TROUBLE, NULL,
HFILL }},
{ &hf_zbee_zcl_ias_zone_status_ac_mains,
{ "AC (mains)", "zbee_zcl_ias.zone.status.ac_mains", FT_BOOLEAN, 16, TFS(&tfs_ac_mains), ZBEE_IAS_ZONE_STATUS_AC_MAINS, NULL,
HFILL }}
};
/* ZCL IAS Zone subtrees */
static gint *ett[ZBEE_ZCL_IAS_ZONE_NUM_ETT];
ett[0] = &ett_zbee_zcl_ias_zone;
ett[1] = &ett_zbee_zcl_ias_zone_status;
/* Register the ZigBee ZCL IAS Zoben cluster protocol name and description */
proto_zbee_zcl_ias_zone = proto_register_protocol("ZigBee ZCL IAS Zone", "ZCL IAS Zone", ZBEE_PROTOABBREV_ZCL_IAS_ZONE);
proto_register_field_array(proto_zbee_zcl_ias_zone, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Register the ZigBee ZCL IAS Zone dissector. */
register_dissector(ZBEE_PROTOABBREV_ZCL_IAS_ZONE, dissect_zbee_zcl_ias_zone, proto_zbee_zcl_ias_zone);
} /*proto_register_zbee_zcl_ias_zone*/
/*
* 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:
*/
|