-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBACnetBase.py
5729 lines (4769 loc) · 223 KB
/
BACnetBase.py
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
# MIT License
#
# Copyright (c) 2020 chr1s-t0pher
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from BACnetEnum import *
from bitstring import BitArray
from datetime import datetime, date, time
import enum
import struct
import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
class ASN1encodeInterface:
def ASN1encode(self) -> bytes:
pass
class Network_Priority(enum.IntEnum):
Life_Safety_Message = 1
Critical_Equipment_Message = 2
Urgent_Message = 3
Normal_Message = 4
class NetworkLayerMessageType(enum.IntEnum):
WHO_IS_ROUTER_TO_NETWORK = 0
I_AM_ROUTER_TO_NETWORK = 1
I_COULD_BE_ROUTER_TO_NETWORK = 2
REJECT_MESSAGE_TO_NETWORK = 3
ROUTER_BUSY_TO_NETWORK = 4
ROUTER_AVAILABLE_TO_NETWORK = 5
INIT_RT_TABLE = 6
INIT_RT_TABLE_ACK = 7
ESTABLISH_CONNECTION_TO_NETWORK = 8
DISCONNECT_CONNECTION_TO_NETWORK = 9
Challenge_Request = 10
Security_Payload = 11
Security_Response = 12
Request_Key_Update = 13
Update_Key_Set = 14
Update_Distribution_Key = 15
Request_Master_Key = 16
Set_Master_Key = 17
What_Is_Network_Number = 18
Network_Number_Is = 19
class BacnetMaxSegments(enum.IntEnum):
MAX_SEG0 = 0
MAX_SEG2 = 0x10
MAX_SEG4 = 0x20
MAX_SEG8 = 0x30
MAX_SEG16 = 0x40
MAX_SEG32 = 0x50
MAX_SEG64 = 0x60
MAX_SEG65 = 0x70
class BacnetMaxAdpu(enum.IntEnum):
MAX_APDU50 = 0
MAX_APDU128 = 1
MAX_APDU206 = 2
MAX_APDU480 = 3
MAX_APDU1024 = 4
MAX_APDU1476 = 5
class BacnetPduTypes(enum.IntEnum):
PDU_TYPE_CONFIRMED_SERVICE_REQUEST = 0
SERVER = 1
NEGATIVE_ACK = 2
SEGMENTED_RESPONSE_ACCEPTED = 2
MORE_FOLLOWS = 4
SEGMENTED_MESSAGE = 8
PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST = 0x10
PDU_TYPE_SIMPLE_ACK = 0x20
PDU_TYPE_COMPLEX_ACK = 0x30
PDU_TYPE_SEGMENT_ACK = 0x40
PDU_TYPE_ERROR = 0x50
PDU_TYPE_REJECT = 0x60
PDU_TYPE_ABORT = 0x70
PDU_TYPE_MASK = 0xF0
class BacnetCharacterStringEncodings(enum.IntEnum):
CHARACTER_ANSI_X34 = 0
CHARACTER_UTF8 = 0
CHARACTER_MS_DBCS = 1
CHARACTER_JISC_6226 = 2
CHARACTER_JISX_0208 = 2
CHARACTER_UCS4 = 3
CHARACTER_UCS2 = 4
CHARACTER_ISO8859 = 5
class BACnetApplicationTags(enum.IntEnum):
NULL = 0
BOOLEAN = 1
UNSIGNED_INT = 2
SIGNED_INT = 3
REAL = 4
DOUBLE = 5
OCTET_STRING = 6
CHARACTER_STRING = 7
BIT_STRING = 8
ENUMERATED = 9
DATE = 10
TIME = 11
BACNETOBJECTIDENTIFIER = 12
RESERVE1 = 13
RESERVE2 = 14
RESERVE3 = 15
class BacnetNpduControls(enum.IntEnum):
PriorityNormalMessage = 0
PriorityUrgentMessage = 1
PriorityCriticalMessage = 2
PriorityLifeSafetyMessage = 3
ExpectingReply = 4
SourceSpecified = 8
DestinationSpecified = 32
NetworkLayerMessage = 128
class BacnetNetworkMessageTypes(enum.IntEnum):
NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK = 0
NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK = 1
NETWORK_MESSAGE_I_COULD_BE_ROUTER_TO_NETWORK = 2
NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK = 3
NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK = 4
NETWORK_MESSAGE_ROUTER_AVAILABLE_TO_NETWORK = 5
NETWORK_MESSAGE_INIT_RT_TABLE = 6
NETWORK_MESSAGE_INIT_RT_TABLE_ACK = 7
NETWORK_MESSAGE_ESTABLISH_CONNECTION_TO_NETWORK = 8
NETWORK_MESSAGE_DISCONNECT_CONNECTION_TO_NETWORK = 9
NETWORK_MESSAGE_Challenge_Request = 10
NETWORK_MESSAGE_Security_Payload = 11
NETWORK_MESSAGE_Security_Response = 12
NETWORK_MESSAGE_Request_Key_Update = 13
NETWORK_MESSAGE_Update_Key_Set = 14
NETWORK_MESSAGE_Update_Distribution_Key = 15
NETWORK_MESSAGE_Request_Master_Key = 16
NETWORK_MESSAGE_Set_Master_Key = 17
NETWORK_MESSAGE_What_Is_Network_Number = 18
NETWORK_MESSAGE_Network_Number_Is = 19
class error_class_enum(enum.IntEnum):
device = 0
object = 1
property = 2
resources = 3
security = 4
services = 5
vt = 6
communication = 7
class error_code_enum(enum.IntEnum):
other = 0
authentication_failed = 1 # formerly: removed version 1 revision 11
configuration_in_progress = 2
device_busy = 3
dynamic_creation_not_supported = 4
file_access_denied = 5
incompatible_security_levels = 6 # formerly:removed in version 1 revision 11
inconsistent_parameters = 7
inconsistent_selection_criterion = 8
invalid_data_type = 9
invalid_file_access_method = 10
invalid_file_start_position = 11
invalid_operator_name = 12 # formerly:removed in version 1 revision 11
invalid_parameter_data_type = 13
invalid_timestamp = 14
key_generation_error = 15 # formerly:removed in version 1 revision 11
missing_required_parameter = 16
no_objects_of_specified_type = 17
no_space_for_object = 18
no_space_to_add_list_element = 19
no_space_to_write_property = 20
no_vt_sessions_available = 21
property_is_not_a_list = 22
object_deletion_not_permitted = 23
object_identifier_already_exists = 24
operational_problem = 25
password_failure = 26
read_access_denied = 27
security_not_supported = 28 # formerly:removed in version 1 revision 11
service_request_denied = 29
timeout = 30
unknown_object = 31
unknown_property = 32
# this enumeration was removed = 33
unknown_vt_class = 34
unknown_vt_session = 35
unsupported_object_type = 36
value_out_of_range = 37
vt_session_already_closed = 38
vt_session_termination_failure = 39
write_access_denied = 40
character_set_not_supported = 41
invalid_array_index = 42
cov_subscription_failed = 43
not_cov_property = 44
optional_functionality_not_supported = 45
invalid_configuration_data = 46
datatype_not_supported = 47
duplicate_name = 48
duplicate_object_id = 49
property_is_not_an_array = 50
abort_buffer_overflow = 51
abort_invalid_apdu_in_this_state = 52
abort_preempted_by_higher_priority_task = 53
abort_segmentation_not_supported = 54
abort_proprietary = 55
abort_other = 56
invalid_tag = 57
network_down = 58
reject_buffer_overflow = 59
reject_inconsistent_parameters = 60
reject_invalid_parameter_data_type = 61
reject_invalid_tag = 62
reject_missing_required_parameter = 63
reject_parameter_out_of_range = 64
reject_too_many_arguments = 65
reject_undefined_enumeration = 66
reject_unrecognized_service = 67
reject_proprietary = 68
reject_other = 69
unknown_device = 70
unknown_route = 71
value_not_initialized = 72
invalid_event_state = 73
no_alarm_configured = 74
log_buffer_full = 75
logged_value_purged = 76
no_property_specified = 77
not_configured_for_triggered_logging = 78
unknown_subscription = 79
parameter_out_of_range = 80
list_element_not_found = 81
busy = 82
communication_disabled = 83
success = 84
access_denied = 85
bad_destination_address = 86
bad_destination_device_id = 87
bad_signature = 88
bad_source_address = 89
bad_timestamp = 90
cannot_use_key = 91
cannot_verify_message_id = 92
correct_key_revision = 93
destination_device_id_required = 94
duplicate_message = 95
encryption_not_configured = 96
encryption_required = 97
incorrect_key = 98
invalid_key_data = 99
key_update_in_progress = 100
malformed_message = 101
not_key_server = 102
security_not_configured = 103
source_security_required = 104
too_many_keys = 105
unknown_authentication_type = 106
unknown_key = 107
unknown_key_revision = 108
unknown_source_message = 109
not_router_to_dnet = 110
router_busy = 111
unknown_network_message = 112
message_too_long = 113
security_error = 114
addressing_error = 115
write_bdt_failed = 116
read_bdt_failed = 117
register_foreign_device_failed = 118
read_fdt_failed = 119
delete_fdt_entry_failed = 120
distribute_broadcast_failed = 121
unknown_file_size = 122
abort_apdu_too_long = 123
abort_application_exceeded_reply_time = 124
abort_out_of_resources = 125
abort_tsm_timeout = 126
abort_window_size_out_of_range = 127
file_full = 128
inconsistent_configuration = 129
inconsistent_object_type = 130
internal_error = 131
not_configured = 132
out_of_memory = 133
value_too_long = 134
abort_insufficient_security = 135
abort_security_error = 136
duplicate_entry = 137
invalid_value_in_this_state = 138
class BACnetObjectIdentifier():
def __init__(self, Type: BACnetObjectType = None,
Instance: int = None):
self.Type = Type
self.Instance = Instance
def __str__(self):
return str(self.Type) + ":" + str(self.Instance)
def ASN1decode(self, buffer, offset, apdu_len) -> int:
leng = 0
(leng1, value) = ASN1.decode_unsigned(buffer, offset + leng, 4)
leng += leng1
self.Instance = (value & ASN1.BACNET_MAX_INSTANCE)
self.Type = BACnetObjectType((int(value) >> ASN1.BACNET_INSTANCE_BITS) & ASN1.BACNET_MAX_OBJECT)
return leng
def ASN1decode_context(self, buffer, offset, apdu_len, tag_number) -> int:
leng = 0
if (ASN1.decode_is_context_tag(buffer, offset + leng, tag_number)):
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
leng += self.ASN1decode(buffer, offset + leng, len_value)
else:
return -1
return leng
def ASN1encode(self) -> bytes:
return (((self.Type & ASN1.BACNET_MAX_OBJECT) << ASN1.BACNET_INSTANCE_BITS) | (
self.Instance & ASN1.BACNET_MAX_INSTANCE)).to_bytes(4, byteorder='big')
def ASN1encode_app(self) -> bytes:
tmp = self.ASN1encode()
return ASN1.encode_tag(BACnetApplicationTags.BACNETOBJECTIDENTIFIER, False, len(tmp)) + tmp
def ASN1encode_context(self, tag_number: int) -> bytes:
tmp = self.ASN1encode()
return ASN1.encode_tag(tag_number, True, len(tmp)) + tmp
class BACnetDateTime(ASN1encodeInterface):
def __init__(self, DATE: date = None, TIME: time = None):
self.DATE = DATE
self.TIME = TIME
def __str__(self):
return str(datetime.combine(self.DATE, self.TIME))
def ASN1decode(self, buffer, offset, apdu_len):
leng = 0
(leng1, self.DATE) = ASN1.decode_application_date(buffer, offset + leng)
leng += leng1
(leng1, self.TIME) = ASN1.decode_application_time(buffer, offset + leng)
leng += leng1
return leng
def ASN1encode(self):
return ASN1.encode_application_date(self.DATE) + ASN1.encode_application_time(self.TIME)
#todo BACnetPropertyValue add ASN1encodeInterface
class BACnetPropertyValue(ASN1encodeInterface):
def __init__(self, identifier=None, arrayindex=None, value=None, priority=None):
self.identifier = identifier
self.arrayindex = arrayindex
self.value = value
self.priority = priority
def __str__(self):
ret = "identifier: " + str(self.identifier)
if self.arrayindex != None:
ret += "\narrayindex: " + str(self.arrayindex)
for val in self.value:
ret += "\n\tvalue: " + str(val)
if self.priority != None:
ret += "\npriority: " + str(self.priority)
return ret
def ASN1decode(self, buffer, offset, apdu_len, objectidentifier):
leng = 0
# tag 0 propertyidentifier
if (ASN1.decode_is_context_tag(buffer, offset + leng, 0)):
leng1, tag_number, len_value = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.identifier) = ASN1.decode_enumerated(buffer, offset + leng, len_value,
prop_id=BACnetPropertyIdentifier.PROPERTY_LIST)
leng += leng1
else:
return -1
# tag 1 - propertyArrayIndex OPTIONAL
if (ASN1.decode_is_context_tag(buffer, offset + leng, 1)):
leng1, tag_number, len_value = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.arrayindex) = ASN1.decode_unsigned(buffer, offset + leng, len_value)
leng += leng1
# Value
if not ASN1.decode_is_opening_tag_number(buffer, offset + leng, 2):
return -1
# a tag number of 2 is not extended so only one octet */
leng += 1
b_values = []
while not ASN1.decode_is_closing_tag_number(buffer, offset + leng, 2):
b_value = BACnetValue()
leng1 = b_value.ASN1decode(buffer, offset + leng, apdu_len - leng,
objectidentifier.Type,
self.identifier)
if leng1 < 0:
return -1
leng += leng1
b_values.append(b_value)
self.value = b_values
# a tag number of 2 is not extended so only one octet */
leng += 1
# tag 3 - priority OPTIONAL */
if ASN1.decode_is_context_tag(buffer, offset + leng, 3):
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.priority) = ASN1.decode_unsigned(buffer, offset + leng, len_value)
leng += leng1
# else:
# self.priority = ASN1.BACNET_NO_PRIORITY
return leng
# todo Error add ASN1encodeInterface
class BACnetError(ASN1encodeInterface):
# Error renamed to BACnetError
def __init__(self, error_class: error_class_enum = None,
error_code: error_code_enum = None):
self.error_class = error_class
self.error_code = error_code
def __str__(self):
return "\n"+str(self.error_class) + ": " + str(self.error_code)
def ASN1decode(self, buffer, offset, apdu_len) -> int:
leng = 0
# error_class
leng1, tag_number, len_value = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
if tag_number == BACnetApplicationTags.ENUMERATED:
(leng1, e_val) = ASN1.decode_enumerated(buffer, offset + leng, len_value)
leng += leng1
self.error_class = error_class_enum(e_val)
else:
return -1
# error_code
leng1, tag_number, len_value = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
if tag_number == BACnetApplicationTags.ENUMERATED:
(leng1, e_val) = ASN1.decode_enumerated(buffer, offset + leng, len_value)
leng += leng1
self.error_code = error_code_enum(e_val)
else:
return -1
return leng
# todo is ABSTRACT-SYNTAX.&Type
class BACnetValue(ASN1encodeInterface):
def __init__(self, tag=None, value=None):
self.Tag = tag
self.Value = value
def __str__(self):
if self.Tag == None:
return "\n\t\tContext Specific: " + str(self.Value)
else:
return str(self.Tag) + ":" + str(self.Value)
def ASN1decode(self, buffer, offset, apdu_len, obj_type: BACnetObjectType = None,
prop_id: BACnetPropertyIdentifier = None):
leng = 0
# FIXME: use max_apdu_len!
if not (ASN1.IS_CONTEXT_SPECIFIC(buffer[offset])):
(tag_len, tag_number, len_value_type) = ASN1.decode_tag_number_and_value(buffer, offset)
if tag_len > 0:
self.Tag = BACnetApplicationTags(tag_number)
leng += tag_len
decode_len = 0
if self.Tag == BACnetApplicationTags.NULL:
self.Value = None
decode_len = 0
# fixme fix null type nothing else to do, some Error occurs!!!!
elif self.Tag == BACnetApplicationTags.BOOLEAN:
if len_value_type > 0:
self.Value = True
else:
self.Value = False
elif self.Tag == BACnetApplicationTags.UNSIGNED_INT:
# some context specific!
if prop_id == BACnetPropertyIdentifier.ROUTING_TABLE:
# fixme untested! not supported by CBMS Devicesimulator
self.Tag = None
self.Value = BACnetRouterEntry()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset + leng, apdu_len)
elif prop_id == BACnetPropertyIdentifier.ACTIVE_VT_SESSIONS:
self.Tag = None
self.Value = BACnetVTSession()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset + leng, apdu_len)
elif prop_id == BACnetPropertyIdentifier.THREAT_LEVEL or prop_id == BACnetPropertyIdentifier.THREAT_AUTHORITY:
self.Tag = None
self.Value = BACnetAccessThreatLevel()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset + leng, apdu_len)
else:
(decode_len, uint_value) = ASN1.decode_unsigned(buffer, offset+leng, len_value_type)
self.Value = uint_value
elif self.Tag == BACnetApplicationTags.SIGNED_INT:
(decode_len, int_value) = ASN1.decode_signed(buffer, offset+leng, len_value_type)
self.Value = int_value
elif self.Tag == BACnetApplicationTags.REAL:
(decode_len, float_value) = ASN1.decode_real_safe(buffer, offset+leng, len_value_type)
self.Value = float_value
elif self.Tag == BACnetApplicationTags.DOUBLE:
(decode_len, double_value) = ASN1.decode_double_safe(buffer, offset+leng, len_value_type)
self.Value = double_value
elif self.Tag == BACnetApplicationTags.OCTET_STRING:
(decode_len, octet_value) = ASN1.decode_octet_string(buffer, offset+leng, len_value_type)
self.Value = octet_value
elif self.Tag == BACnetApplicationTags.CHARACTER_STRING:
(decode_len, string_value) = ASN1.decode_character_string(buffer, offset+leng, apdu_len, len_value_type)
self.Value = string_value
elif self.Tag == BACnetApplicationTags.BIT_STRING:
# some context specific!
if prop_id == BACnetPropertyIdentifier.RECIPIENT_LIST:
self.Tag = None
self.Value = BACnetDestination()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset + leng, apdu_len)
elif prop_id == BACnetPropertyIdentifier.STATUS_FLAGS:
self.Tag = None
bit_value = BACnetStatusFlags()
decode_len = bit_value.ASN1decode(buffer, offset, len_value_type)
self.Value = bit_value
elif prop_id == BACnetPropertyIdentifier.EVENT_ENABLE or \
prop_id == BACnetPropertyIdentifier.ACKED_TRANSITIONS:
self.Tag = None
bit_value = BACnetEventTransitionBits()
decode_len = bit_value.ASN1decode(buffer, offset, len_value_type)
self.Value = bit_value
elif prop_id == BACnetPropertyIdentifier.LIMIT_ENABLE:
self.Tag = None
bit_value = BACnetLimitEnable()
decode_len = bit_value.ASN1decode(buffer, offset, len_value_type)
self.Value = bit_value
elif prop_id == BACnetPropertyIdentifier.PROTOCOL_OBJECT_TYPES_SUPPORTED:
self.Tag = None
bit_value = BACnetObjectTypesSupported()
decode_len = bit_value.ASN1decode(buffer, offset, len_value_type)
self.Value = bit_value
elif prop_id == BACnetPropertyIdentifier.PROTOCOL_SERVICES_SUPPORTED:
self.Tag = None
bit_value = BACnetServicesSupported()
decode_len = bit_value.ASN1decode(buffer, offset, len_value_type)
self.Value = bit_value
else:
bit_value = BACnetBitString()
decode_len = bit_value.ASN1decode(buffer, offset, len_value_type)
self.Value = bit_value
elif self.Tag == BACnetApplicationTags.ENUMERATED:
(decode_len, uint_value) = ASN1.decode_enumerated(buffer, offset+leng, len_value_type, obj_type,
prop_id)
self.Value = uint_value
elif self.Tag == BACnetApplicationTags.DATE:
# some context specific!
if prop_id == BACnetPropertyIdentifier.EFFECTIVE_PERIOD:
self.Tag = None
self.Value = BACnetDateRange()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset+leng, apdu_len)
elif prop_id == BACnetPropertyIdentifier.MINIMUM_VALUE_TIMESTAMP or\
prop_id == BACnetPropertyIdentifier.MAXIMUM_VALUE_TIMESTAMP or\
prop_id == BACnetPropertyIdentifier.CHANGE_OF_STATE_TIME or\
prop_id == BACnetPropertyIdentifier.TIME_OF_STATE_COUNT_RESET or\
prop_id == BACnetPropertyIdentifier.TIME_OF_ACTIVE_TIME_RESET or\
prop_id == BACnetPropertyIdentifier.MODIFICATION_DATE or\
prop_id == BACnetPropertyIdentifier.UPDATE_TIME or\
prop_id == BACnetPropertyIdentifier.COUNT_CHANGE_TIME or\
prop_id == BACnetPropertyIdentifier.START_TIME or\
prop_id == BACnetPropertyIdentifier.STOP_TIME or\
prop_id == BACnetPropertyIdentifier.LAST_CREDENTIAL_ADDED_TIME or\
prop_id == BACnetPropertyIdentifier.LAST_CREDENTIAL_REMOVED_TIME or\
prop_id == BACnetPropertyIdentifier.ACTIVATION_TIME or\
prop_id == BACnetPropertyIdentifier.EXPIRY_TIME or\
prop_id == BACnetPropertyIdentifier.LAST_USE_TIME or\
prop_id == BACnetPropertyIdentifier.TIME_OF_STRIKE_COUNT_RESET or\
prop_id == BACnetPropertyIdentifier.VALUE_CHANGE_TIME or\
((obj_type == BACnetObjectType.DateTime_Value or obj_type == BACnetObjectType.DateTime_Pattern_Value) and (prop_id == BACnetPropertyIdentifier.PRESENT_VALUE or prop_id == BACnetPropertyIdentifier.RELINQUISH_DEFAULT)):
self.Tag = None
self.Value = BACnetDateTime()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset + leng, apdu_len)
else:
(decode_len, date_value) = ASN1.decode_date_safe(buffer, offset+leng, len_value_type)
self.Value = date_value;
elif self.Tag == BACnetApplicationTags.TIME:
(decode_len, time_value) = ASN1.decode_bacnet_time_safe(buffer, offset+leng, len_value_type)
self.Value = time_value
elif self.Tag == BACnetApplicationTags.BACNETOBJECTIDENTIFIER:
#context specific
if prop_id == BACnetPropertyIdentifier.LAST_KEY_SERVER or \
prop_id == BACnetPropertyIdentifier.MANUAL_SLAVE_ADDRESS_BINDING or \
prop_id == BACnetPropertyIdentifier.SLAVE_ADDRESS_BINDING or\
prop_id == BACnetPropertyIdentifier.DEVICE_ADDRESS_BINDING:
self.Tag = None
self.Value = BACnetAddressBinding()
leng -= 1
decode_len = self.Value.ASN1decode(buffer, offset + leng, apdu_len)
else:
(decode_len, object_type, instance) = ASN1.decode_object_id_safe(buffer, offset+leng, len_value_type)
self.Value = BACnetObjectIdentifier(object_type, instance)
if (decode_len < 0):
return -1
leng += decode_len
else:
if prop_id == BACnetPropertyIdentifier.BACNET_IP_GLOBAL_ADDRESS or\
prop_id == BACnetPropertyIdentifier.FD_BBMD_ADDRESS:
self.Value = BACnetHostNPort()
leng += self.Value.ASN1decode(buffer, offset+leng, apdu_len-leng)
elif prop_id == BACnetPropertyIdentifier.UTC_TIME_SYNCHRONIZATION_RECIPIENTS or\
prop_id == BACnetPropertyIdentifier.RESTART_NOTIFICATION_RECIPIENTS or\
prop_id == BACnetPropertyIdentifier.TIME_SYNCHRONIZATION_RECIPIENTS or\
prop_id == BACnetPropertyIdentifier.COVU_RECIPIENTS:
self.Value = BACnetRecipient()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.KEY_SETS:
self.Value = BACnetSecurityKeySet()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.EVENT_TIME_STAMPS or\
prop_id == BACnetPropertyIdentifier.LAST_COMMAND_TIME or\
prop_id == BACnetPropertyIdentifier.COMMAND_TIME_ARRAY or\
prop_id == BACnetPropertyIdentifier.LAST_RESTORE_TIME or\
prop_id == BACnetPropertyIdentifier.TIME_OF_DEVICE_RESTART or\
prop_id == BACnetPropertyIdentifier.ACCESS_EVENT_TIME or\
prop_id == BACnetPropertyIdentifier.UPDATE_TIME:
#UPDATE_TIME once in context specific BACnetTimeStamp and non context specific BACnetDateTime
self.Value = BACnetTimeStamp()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.LIST_OF_GROUP_MEMBERS:
self.Value = ReadAccessSpecification()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.LIST_OF_OBJECT_PROPERTY_REFERENCES:
self.Value = BACnetDeviceObjectPropertyReference()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.MEMBER_OF or\
prop_id == BACnetPropertyIdentifier.ZONE_MEMBERS or\
prop_id == BACnetPropertyIdentifier.DOOR_MEMBERS or\
prop_id == BACnetPropertyIdentifier.SUBORDINATE_LIST or\
prop_id == BACnetPropertyIdentifier.REPRESENTS or\
prop_id == BACnetPropertyIdentifier.ACCESS_EVENT_CREDENTIAL or\
prop_id == BACnetPropertyIdentifier.ACCESS_DOORS or\
prop_id == BACnetPropertyIdentifier.ZONE_TO or\
prop_id == BACnetPropertyIdentifier.ZONE_FROM or\
prop_id == BACnetPropertyIdentifier.CREDENTIALS_IN_ZONE or\
prop_id == BACnetPropertyIdentifier.LAST_CREDENTIAL_ADDED or\
prop_id == BACnetPropertyIdentifier.LAST_CREDENTIAL_REMOVED or\
prop_id == BACnetPropertyIdentifier.ENTRY_POINTS or\
prop_id == BACnetPropertyIdentifier.EXIT_POINTS or\
prop_id == BACnetPropertyIdentifier.MEMBERS or\
prop_id == BACnetPropertyIdentifier.CREDENTIALS or\
prop_id == BACnetPropertyIdentifier.ACCOMPANIMENT or\
prop_id == BACnetPropertyIdentifier.BELONGS_TO or\
prop_id == BACnetPropertyIdentifier.LAST_ACCESS_POINT or\
prop_id == BACnetPropertyIdentifier.ENERGY_METER_REF:
self.Value = BACnetDeviceObjectReference()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.EVENT_ALGORITHM_INHIBIT_REF or\
prop_id == BACnetPropertyIdentifier.INPUT_REFERENCE or\
prop_id == BACnetPropertyIdentifier.MANIPULATED_VARIABLE_REFERENCE or\
prop_id == BACnetPropertyIdentifier.CONTROLLED_VARIABLE_REFERENCE:
self.Value = BACnetObjectPropertyReference()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.LOGGING_RECORD:
self.Value = BACnetAccumulatorRecord()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.ACTION:
#exists once enumerated (non context specific) and context specific
self.Value = BACnetActionList()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.SCALE:
self.Value = BACnetScale()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.LIGHTING_COMMAND:
self.Value = BACnetLightingCommand()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.PRESCALE:
self.Value = BACnetPrescale()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.REQUESTED_SHED_LEVEL or\
prop_id == BACnetPropertyIdentifier.EXPECTED_SHED_LEVEL or\
prop_id == BACnetPropertyIdentifier.ACTUAL_SHED_LEVEL:
self.Value = BACnetShedLevel()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.LOG_BUFFER and obj_type == BACnetObjectType.TrendLog:
self.Value = BACnetLogRecord()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.DATE_LIST:
self.Value = BACnetCalendarEntry()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.LOG_BUFFER and obj_type == BACnetObjectType.Event_Log:
self.Value = BACnetEventLogRecord()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.PRESENT_VALUE and obj_type == BACnetObjectType.Group:
self.Value = ReadAccessResult()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.NEGATIVE_ACCESS_RULES or\
prop_id == BACnetPropertyIdentifier.POSITIVE_ACCESS_RULES:
self.Value = BACnetAccessRule()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.TAGS:
self.Value = BACnetNameValue()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.SUBORDINATE_TAGS:
self.Value = BACnetNameValueCollection()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.NETWORK_ACCESS_SECURITY_POLICIES:
self.Value = BACnetNetworkSecurityPolicy()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.PORT_FILTER:
self.Value = BACnetPortPermission()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.PRIORITY_ARRAY:
self.Value = BACnetPriorityArray()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.PROCESS_IDENTIFIER_FILTER:
self.Value = BACnetProcessIdSelection()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif obj_type == BACnetObjectType.Global_Group and prop_id == BACnetPropertyIdentifier.PRESENT_VALUE:
self.Value = BACnetPropertyAccessResult()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.SETPOINT_REFERENCE:
self.Value = BACnetSetpointReference()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.EXCEPTION_SCHEDULE:
self.Value = BACnetSpecialEvent()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.STATE_CHANGE_VALUES:
self.Value = BACnetTimerStateChangeValue()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.VALUE_SOURCE or\
prop_id == BACnetPropertyIdentifier.VALUE_SOURCE_ARRAY:
self.Value = BACnetValueSource()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.VIRTUAL_MAC_ADDRESS_TABLE:
self.Value = BACnetVMACEntry()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.ASSIGNED_ACCESS_RIGHTS:
self.Value = BACnetAssignedAccessRights()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.ASSIGNED_LANDING_CALLS:
self.Value = BACnetAssignedLandingCalls()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.ACCESS_EVENT_AUTHENTICATION_FACTOR or\
(obj_type == BACnetObjectType.Credential_Data_Input and prop_id == BACnetPropertyIdentifier.PRESENT_VALUE):
self.Value = BACnetAuthenticationFactor()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.SUPPORTED_FORMATS:
self.Value = BACnetAuthenticationFactorFormat()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.AUTHENTICATION_POLICY_LIST:
self.Value = BACnetAuthenticationPolicy()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif obj_type == BACnetObjectType.Channel and prop_id == BACnetPropertyIdentifier.PRESENT_VALUE:
self.Value = BACnetChannelValue()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.ACTIVE_COV_SUBSCRIPTIONS:
self.Value = BACnetCOVSubscription()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.AUTHENTICATION_FACTORS:
self.Value = BACnetCredentialAuthenticationFactor()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.WEEKLY_SCHEDULE:
self.Value = BACnetDailySchedule()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.SUBSCRIBED_RECIPIENTS:
self.Value = BACnetEventNotificationSubscription()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.EVENT_PARAMETERS:
self.Value = BACnetEventParameter()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
elif prop_id == BACnetPropertyIdentifier.FAULT_PARAMETERS:
self.Value = BACnetFaultParameter()
leng += self.Value.ASN1decode(buffer, offset + leng, apdu_len - leng)
else:
logging.debug("context specific!!!! needs to be addded")
leng = apdu_len
return leng
def ASN1encode(self):
if self.Tag == BACnetApplicationTags.NULL:
# fixme NULL
pass
elif self.Tag == BACnetApplicationTags.BOOLEAN:
return ASN1.encode_application_boolean(self.Value)
elif self.Tag == BACnetApplicationTags.UNSIGNED_INT:
return ASN1.encode_application_unsigned(self.Value)
elif self.Tag == BACnetApplicationTags.SIGNED_INT:
return ASN1.encode_application_signed(self.Value)
elif self.Tag == BACnetApplicationTags.REAL:
return ASN1.encode_application_real(self.Value)
elif self.Tag == BACnetApplicationTags.DOUBLE:
return ASN1.encode_application_double(self.Value)
elif self.Tag == BACnetApplicationTags.OCTET_STRING:
return ASN1.encode_application_octet_string(self.Value, 0, len(self.Value))
elif self.Tag == BACnetApplicationTags.CHARACTER_STRING:
return ASN1.encode_application_character_string(self.Value)
elif self.Tag == BACnetApplicationTags.BIT_STRING:
return ASN1.encode_application_bitstring(self.Value)
elif self.Tag == BACnetApplicationTags.ENUMERATED or type(self.value) == enum.IntEnum:
return ASN1.encode_application_enumerated(self.Value)
elif self.Tag == BACnetApplicationTags.DATE:
return ASN1.encode_application_date(self.Value)
elif self.Tag == BACnetApplicationTags.TIME:
return ASN1.encode_application_time(self.Value)
elif self.Tag == BACnetApplicationTags.BACNETOBJECTIDENTIFIER:
return self.Value.ASN1encode_app()
elif type(self.value) == ASN1encodeInterface:
return self.Value.ASN1encode()
else:
logging.debug("something else to encode!!!!")
# todo BACnetPropertyReference add ASN1encodeInterface
class BACnetPropertyReference(ASN1encodeInterface):
def __init__(self, propertyIdentifier: BACnetPropertyIdentifier = None, propertyArrayIndex: int = None):
self.propertyIdentifier = propertyIdentifier
self.propertyArrayIndex = propertyArrayIndex
def __str__(self):
return str(self.propertyIdentifier) + ":" + str(self.propertyArrayIndex)
def ASN1decode(self, buffer, offset, apdu_len):
leng = 0
# propertyidentifier
if (ASN1.decode_is_context_tag(buffer, offset + leng, 0)):
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.propertyIdentifier) = ASN1.decode_enumerated(buffer, offset + leng, len_value,
prop_id=BACnetPropertyIdentifier.PROPERTY_LIST)
leng += leng1
else:
return -1
if leng < apdu_len:
if (ASN1.decode_is_context_tag(buffer, offset + leng, 1) and not ASN1.decode_is_closing_tag_number(buffer,
offset + leng,
1)):
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.propertyArrayIndex) = ASN1.decode_unsigned(buffer, offset + leng, len_value)
leng += leng1
return leng
# todo BACnetTimeStamp add ASN1encodeInterface
class BACnetTimeStamp(ASN1encodeInterface):
def __init__(self, value=None):
self.value = value
def __str__(self):
if type(self.value) == int:
return "sequence number: " + str(self.value)
elif type(self.value) == BACnetDateTime:
return "DateTime: " + str(self.value)
elif type(self.value) == time:
return "Time: " + str(self.value)
def ASN1decode(self, buffer, offset, apdu_len):
leng = 0
if (ASN1.decode_is_context_tag(buffer, offset + leng, 2)):
# BACnetDateTime
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
self.value = BACnetDateTime()
leng += BACnetDateTime.ASN1decode(self.value, buffer, offset + leng, len_value)
# leng += 1
elif (ASN1.decode_is_context_tag(buffer, offset + leng, 1)):
# sequencenumber
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.value) = ASN1.decode_unsigned(buffer, offset + leng, len_value)
leng += leng1
# leng += 1
elif (ASN1.decode_is_context_tag(buffer, offset + leng, 0)):
# time
(leng1, tag_number, len_value) = ASN1.decode_tag_number_and_value(buffer, offset + leng)
leng += leng1
(leng1, self.value) = ASN1.decode_bacnet_time_safe(buffer, offset + leng, len_value)
leng += leng1
else:
return -1
return leng
def ASN1encode(self):
pass
def ASN1encode_context(self, tag_number) -> bytes:
tmp = self.ASN1encode()
return ASN1.encode_tag(tag_number, True, len(tmp)) + tmp
class BACnetPropertyStatesChoice(enum.IntEnum):
BOOLEAN_VALUE = 0
BINARY_VALUE = 1
EVENT_TYPE = 2
POLARITY = 3
PROGRAM_CHANGE = 4
PROGRAM_STATE = 5
REASON_FOR_HALT = 6
RELIABILITY = 7
STATE = 8
SYSTEM_STATUS = 9
UNITS = 10
UNSIGNED_VALUE = 11
LIFE_SAFETY_MODE = 12
LIFE_SAFETY_STATE = 13
RESTART_REASON = 14
DOOR_ALARM_STATE = 15
ACTION = 16
DOOR_SECURED_STATUS = 17
DOOR_STATUS = 18
DOOR_VALUE = 19
FILE_ACCESS_METHOD = 20
LOCK_STATUS = 21
LIFE_SAFETY_OPERATION = 22
MAINTENANCE = 23
NODE_TYPE = 24
NOTIFY_TYPE = 25
SECURITY_LEVEL = 26
SHED_STATE = 27
SILENCED_STATE = 28
ACCESS_EVENT = 30
ZONE_OCCUPANCY_STATE = 31
ACCESS_CREDENTIAL_DISABLE_REASON = 32
ACCESS_CREDENTIAL_DISABLE = 33
AUTHENTICATION_STATUS = 34
BACKUP_STATE = 36
WRITE_STATUS = 37
LIGHTING_IN_PROGRESS = 38
LIGHTING_OPERATION = 39
LIGHTING_TRANSITION = 40