This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BACnetServerExample.py
1292 lines (1154 loc) · 71.2 KB
/
BACnetServerExample.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
# CAS BACnet Stack Python Server Example
# https://github.com/chipkin/BACnetServerExamplePython
#
import ctypes
import io
import pathlib
import netifaces
import dns.resolver # Package name: dnspython
import socket
import time # Sleep function
from CASBACnetStackAdapter import * # Contains all the Enumerations, and callback prototypes
bacnet_server_example_python27_version = "1.0.0"
# Example database
# -----------------------------------------------------------------------------
# This is an example database. Normally this data would come from your sensor/database
#
# Units.
# no_units (95),celsius (62)
# ...
#
# Reliability
# no-fault-detected (0),or (1)
# ...
db = {
"device": {
"instance": 389001,
"objectName": "Device Rainbow",
"vendorname": "Example Chipkin Automation Systems",
"vendoridentifier": 0},
"analogInput": {
"instance": 0,
"objectName": "AnalogInput Bronze",
"presentValue": 99.6,
"units": 62,
"reliability": 1,
"covIncrement": 1.0},
"binaryInput": {
"instance": 3,
"objectName": "BinaryInput Emerald",
"presentValue": 1,
"reliability": 1,
"activeText": "InAlarm",
"inactiveText": "Normal"},
"multiStateInput": {
"instance": 13,
"objectName": "MultiStateInput Hot Pink",
"presentValue": 3,
"numberOfStates": 3,
"stateText": ["Off", "On", "Blinking"]},
"analogOutput": {
"instance": 1,
"objectName": "AnalogOutput Chartreuse",
"presentValue": 1},
"analogValue": {
"instance": 2,
"objectName": "AnalogValue Diamond",
"presentValue": 1,
"covIncrement": 1.0},
"binaryOutput": {
"instance": 4,
"objectName": "BinaryOutput Fuchsia",
"presentValue": 1},
"binaryValue": {
"instance": 5,
"objectName": "BinaryValue Gold",
"presentValue": 1,
"activeText": "On",
"inactiveText": "Off"},
"multiStateOutput": {
"instance": 14,
"objectName": "MultiStateOutput Indigo",
"presentValue": 1,
"numberOfStates": 4,
"stateText": ["Off", "On", "Restart", "Error"]},
"multiStateValue": {
"instance": 19,
"objectName": "MultiStateValue Kiwi",
"presentValue": 1,
"numberOfStates": 3,
"stateText": ["Off", "On", "Blinking"]},
"characterstringValue": {
"instance": 40,
"objectName": "CharacterstringValue Nickel",
"presentValue": "Hello World"},
"integerValue": {
"instance": 45,
"objectName": "IntegerValue Purple",
"presentValue": 1},
"largeAnalogValue": {
"instance": 46,
"objectName": "LargeAnalogValue Quartz",
"presentValue": 1},
"positiveIntegerValue": {
"instance": 48,
"objectName": "PositiveIntegerValue Silver",
"presentValue": 1},
"networkPort": {
"instance": 50,
"objectName": "NetworkPort Vermillion",
"BACnetIPUDPPort": 47808,
"ipLength": 4,
"ipAddress": [0, 0, 0, 0],
"ipDefaultGateway": [0, 0, 0, 0],
"ipDnsServer": [0, 0, 0, 0],
"ipNumOfDns": 0,
"ipSubnetMask": [0, 0, 0, 0],
"FdBbmdAddressHostIp": [192, 168, 1, 4],
"FdBbmdAddressHostType": 1, # 0 = None, 1 = IpAddress, 2 = Name
"FdBbmdAddressPort": 47808,
"FdSubscriptionLifetime": 3000,
"changesPending": False}
}
# Globals
# -----------------------------------------------------------------------------
udpSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udpSocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
lastTimeValueWasUpdated = 0
def octetStringCopy(source, destination, length, offset=0):
for i in range(length):
destination[i + offset] = source[i]
# Rebuilds string from ctype.c_uint_8 arrray
def rebuildString(strPointer, length):
rebuiltStr = ""
for i in range(0, length):
rebuiltStr = rebuiltStr + chr(strPointer[i])
return rebuiltStr
# Callbacks
# -----------------------------------------------------------------------------
def CallbackReceiveMessage(message, maxMessageLength, receivedConnectionString, maxConnectionStringLength,
receivedConnectionStringLength,
networkType):
try:
data, addr = udpSocket.recvfrom(maxMessageLength)
# if not data:
# print("DEBUG: not data")
# A message was received.
print ("DEBUG: CallbackReceiveMessage. Message Received", addr, data, len(data) )
# Convert the received address to the CAS BACnet Stack connection string format.
ip_as_bytes = map(int, addr[0].split("."))
for i in range(len(ip_as_bytes)):
receivedConnectionString[i] = ip_as_bytes[i]
# UDP Port
receivedConnectionString[4] = int(addr[1] / 256)
receivedConnectionString[5] = addr[1] % 256
# New ConnectionString Length
receivedConnectionStringLength[0] = 6
# Convert the received data to a format that CAS BACnet Stack can process.
for i in range(len(data)):
message[i] = ord(data[i])
# Set the network type
networkType[0] = ctypes.c_uint8(casbacnetstack_networkType["ip"])
return int(len(data))
except socket.timeout:
# No message, We are not waiting for a incoming message so our socket returns a BlockingIOError. This is normal.
return int(0)
except io.BlockingIOError:
# No message, We are not waiting for a incoming message so our socket returns a BlockingIOError. This is normal.
return int(0)
except socket.error:
# No message, We are not waiting for a incoming message so our socket returns a BlockingIOError. This is normal.
return int(0)
# Catch all
return 0
def CallbackSendMessage(message, messageLength, connectionString, connectionStringLength, networkType, broadcast):
# Currently we are only supporting IP
if networkType != casbacnetstack_networkType["ip"]:
print("Error: Unsupported network type. networkType:", networkType)
return int(0)
# Extract the Connection String from CAS BACnet Stack into an IP address and port.
udpPort = connectionString[4] * 256 + connectionString[5]
if broadcast:
# Use broadcast IP address
# ToDo: Get the subnet mask and apply it to the IP address
print("DEBUG: ToDo: Broadcast this message. Local IP: ", db["networkPort"]["ipAddress"], "Subnet: ",
db["networkPort"]["ipSubnetMask"],
"Broadcast IP: ????")
ipAddress = str(connectionString[0]) + "." + str(connectionString[1]) + "." + str(connectionString[2]) + "." + \
str(connectionString[3])
else:
ipAddress = str(connectionString[0]) + "." + str(connectionString[1]) + "." + str(connectionString[2]) + "." + \
str(connectionString[3])
# Extract the message from CAS BACnet Stack to a bytearray
data = bytearray(messageLength)
for i in range(len(data)):
data[i] = message[i]
# Send the message
udpSocket.sendto(data, (ipAddress, udpPort))
return int(messageLength)
def CallbackGetSystemTime():
return int(time.time())
def CallbackGetPropertyReal(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyReal", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
# Check for PresentValue Property
if propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["analogInput"] and objectInstance == db["analogInput"]["instance"]:
value[0] = ctypes.c_float(db["analogInput"]["presentValue"])
return True
if objectType == bacnet_objectType["analogValue"] and objectInstance == db["analogValue"]["instance"]:
value[0] = ctypes.c_float(db["analogValue"]["presentValue"])
return True
# Check for covincrement Property
elif propertyIdentifier == bacnet_propertyIdentifier["covincrement"]:
if objectType == bacnet_objectType["analogInput"] and objectInstance == db["analogInput"]["instance"]:
value[0] = ctypes.c_float(db["analogInput"]["covIncrement"])
return True
if objectType == bacnet_objectType["analogValue"] and objectInstance == db["analogValue"]["instance"]:
value[0] = ctypes.c_float(db["analogValue"]["covIncrement"])
return True
# Return false. The CAS BACnet Stack will use a default value.
return False
def CallbackGetPropertyCharString(deviceInstance, objectType, objectInstance, propertyIdentifier, value,
valueElementCount, maxElementCount,
encodingType, useArrayIndex, propertyArrayIndex):
print(
"CallbackGetPropertyCharString", deviceInstance, objectType, objectInstance, propertyIdentifier,
maxElementCount,
useArrayIndex,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
# Check for vendorname Property
if propertyIdentifier == bacnet_propertyIdentifier["vendorname"] and objectType == bacnet_objectType["device"]:
vendorname = db["device"]["vendorname"]
# Convert the vendorname from a string to a format that CAS BACnet Stack can process.
b_vendorname = vendorname.encode("utf-8")
for i in range(len(b_vendorname)):
value[i] = b_vendorname[i]
# Define how long the vendorname is
valueElementCount[0] = len(b_vendorname)
return True
# Check for objectname Property
elif propertyIdentifier == bacnet_propertyIdentifier["objectname"]:
if objectType == bacnet_objectType["device"] and objectInstance == db["device"]["instance"]:
objectName = db["device"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["analogInput"] and objectInstance == db["analogInput"]["instance"]:
objectName = db["analogInput"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["binaryInput"] and objectInstance == db["binaryInput"]["instance"]:
objectName = db["binaryInput"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["multiStateInput"] \
and objectInstance == db["multiStateInput"]["instance"]:
objectName = db["multiStateInput"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["analogOutput"] and objectInstance == db["analogOutput"]["instance"]:
objectName = db["analogOutput"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["analogValue"] and objectInstance == db["analogValue"]["instance"]:
objectName = db["analogValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["binaryOutput"] and objectInstance == db["binaryOutput"]["instance"]:
objectName = db["binaryOutput"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["binaryValue"] and objectInstance == db["binaryValue"]["instance"]:
objectName = db["binaryValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["multiStateOutput"] and objectInstance == db["multiStateOutput"][
"instance"]:
objectName = db["multiStateOutput"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["multiStateValue"] and objectInstance == db["multiStateValue"][
"instance"]:
objectName = db["multiStateValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["characterstringValue"] \
and objectInstance == db["characterstringValue"]["instance"]:
objectName = db["characterstringValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["integerValue"] and objectInstance == db["integerValue"]["instance"]:
objectName = db["integerValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["largeAnalogValue"] \
and objectInstance == db["largeAnalogValue"]["instance"]:
objectName = db["largeAnalogValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["positiveIntegerValue"] \
and objectInstance == db["positiveIntegerValue"]["instance"]:
objectName = db["positiveIntegerValue"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object name is
valueElementCount[0] = len(b_objectName)
return True
elif objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
objectName = db["networkPort"]["objectName"]
# Convert the Object Name from a string to a format that CAS BACnet Stack can process.
b_objectName = objectName.encode("utf-8")
for i in range(len(b_objectName)):
value[i] = b_objectName[i]
# Define how long the Object Name is
valueElementCount[0] = len(b_objectName)
return True
# Check for PresentValue Property
elif propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["characterstringValue"] and objectInstance == db["characterstringValue"]["instance"]:
presentValue = db["characterstringValue"]["presentValue"]
b_presentValue = presentValue.encode("utf-8")
for i in range(len(b_presentValue)):
value[i] = b_presentValue[i]
# Define how long the Object name is
valueElementCount[0] = len(b_presentValue)
return True
# Check for StateText Property
elif propertyIdentifier == bacnet_propertyIdentifier["statetext"]:
if objectType == bacnet_objectType["multiStateInput"] and objectInstance == db["multiStateInput"]["instance"]:
if useArrayIndex:
stateText = db["multiStateInput"]["stateText"][propertyArrayIndex - 1]
b_stateText = stateText.encode("utf-8")
for i in range(len(b_stateText)):
value[i] = b_stateText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_stateText)
return True
elif objectType == bacnet_objectType["multiStateOutput"] and objectInstance == db["multiStateOutput"]["instance"]:
if useArrayIndex:
stateText = db["multiStateOutput"]["stateText"][propertyArrayIndex - 1]
b_stateText = stateText.encode("utf-8")
for i in range(len(b_stateText)):
value[i] = b_stateText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_stateText)
return True
elif objectType == bacnet_objectType["multiStateValue"] and objectInstance == db["multiStateValue"]["instance"]:
if useArrayIndex:
stateText = db["multiStateValue"]["stateText"][propertyArrayIndex - 1]
b_stateText = stateText.encode("utf-8")
for i in range(len(b_stateText)):
value[i] = b_stateText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_stateText)
return True
#Check for ActiveText Property
elif propertyIdentifier == bacnet_propertyIdentifier["activetext"]:
if objectType == bacnet_objectType["binaryInput"] and objectInstance == db["binaryInput"]["instance"]:
activeText = db["binaryInput"]["activeText"]
b_activeText = activeText.encode("utf-8")
for i in range(len(b_activeText)):
value[i] = b_activeText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_activeText)
return True
elif objectType == bacnet_objectType["binaryValue"] and objectInstance == db["binaryValue"]["instance"]:
activeText = db["binaryValue"]["activeText"]
b_activeText = activeText.encode("utf-8")
for i in range(len(b_activeText)):
value[i] = b_activeText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_activeText)
return True
#Check for InActiveText Property
elif propertyIdentifier == bacnet_propertyIdentifier["inactivetext"]:
if objectType == bacnet_objectType["binaryInput"] and objectInstance == db["binaryInput"]["instance"]:
activeText = db["binaryInput"]["inactiveText"]
b_activeText = activeText.encode("utf-8")
for i in range(len(b_activeText)):
value[i] = b_activeText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_activeText)
return True
elif objectType == bacnet_objectType["binaryValue"] and objectInstance == db["binaryValue"]["instance"]:
activeText = db["binaryValue"]["inactiveText"]
b_activeText = activeText.encode("utf-8")
for i in range(len(b_activeText)):
value[i] = b_activeText[i]
# Define how long the Object name is
valueElementCount[0] = len(b_activeText)
return True
# Return false. The CAS BACnet Stack will use a default value.
return False
def ValueToKey(enumeration, searchValue):
# https://www.geeksforgeeks.org/python-get-key-from-value-in-dictionary/
for key, value in enumeration.items():
if value == searchValue:
return key
return "key doesn't exist"
def CallbackGetPropertyEnumerated(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex):
print(
"CallbackGetPropertyEnumerated", deviceInstance, objectType, objectInstance, propertyIdentifier,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
# Check for presentValue Property
if propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["binaryInput"] and objectInstance == db["binaryInput"]["instance"]:
value[0] = ctypes.c_uint32(db["binaryInput"]["presentValue"])
return True
elif objectType == bacnet_objectType["binaryValue"] and objectInstance == db["binaryValue"]["instance"]:
value[0] = ctypes.c_uint32(db["binaryValue"]["presentValue"])
return True
# Check for units Property
elif propertyIdentifier == bacnet_propertyIdentifier["units"]:
if ValueToKey(bacnet_objectType, objectType) in db:
if "units" in db[ValueToKey(bacnet_objectType, objectType)]:
value[0] = ctypes.c_uint32(db[ValueToKey(bacnet_objectType, objectType)]["units"])
return True
# Check for reliability Property
elif propertyIdentifier == bacnet_propertyIdentifier["reliability"]:
if ValueToKey(bacnet_objectType, objectType) in db:
if "units" in db[ValueToKey(bacnet_objectType, objectType)]:
value[0] = ctypes.c_uint32(db[ValueToKey(bacnet_objectType, objectType)]["reliability"])
return True
# Undefined reliability. Assume no-fault-detected (0)
value[0] = ctypes.c_uint32(0)
return True
# Check for fdbbmdaddress Property, the port portion
elif propertyIdentifier == bacnet_propertyIdentifier["fdbbmdaddress"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
value[0] = db["networkPort"]["FdBbmdAddressHostType"]
return True
# Return false. The CAS BACnet Stack will use a default value.
return False
def CallbackGetPropertyBitString(deviceInstance, objectType, objectInstance, propertyIdentifier, value,
valueElementCount, maxElementCount,
useArrayIndex, propertyArrayIndex):
print(
"CallbackGetPropertyBitString", deviceInstance, objectType, objectInstance, propertyIdentifier, maxElementCount,
useArrayIndex,
propertyArrayIndex)
return False
def CallbackGetPropertyBool(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyBool", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
if propertyIdentifier == bacnet_propertyIdentifier["changespending"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
value[0] = db["networkPort"]["changesPending"]
return True
return False
def CallbackGetPropertyDate(deviceInstance, objectType, objectInstance, propertyIdentifier, year, month, day, weekday,
useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyDate", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
return False
def CallbackGetPropertyDouble(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyDouble", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
if propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["largeAnalogValue"] and objectInstance == db["largeAnalogValue"][
"instance"]:
value[0] = ctypes.c_double(db["largeAnalogValue"]["presentValue"])
return True
return False
def CallbackGetPropertyOctetString(deviceInstance, objectType, objectInstance, propertyIdentifier, value,
valueElementCount, maxElementCount,
useArrayIndex, propertyArrayIndex):
print("CallbackGetPropertyOctetString", deviceInstance, objectInstance, propertyIdentifier, maxElementCount,
useArrayIndex, propertyArrayIndex)
if propertyIdentifier == bacnet_propertyIdentifier["ipaddress"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
valueElementCount[0] = db["networkPort"]["ipLength"]
octetStringCopy(db["networkPort"]["ipAddress"], value, valueElementCount[0])
print("DEBUG: IN GET IP: output =" + str(value[0]) + "." + str(value[1]) + "." + str(value[2]) + "." + str(
value[3]))
return True
elif propertyIdentifier == bacnet_propertyIdentifier["ipdefaultgateway"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
valueElementCount[0] = db["networkPort"]["ipLength"]
octetStringCopy(db["networkPort"]["ipDefaultGateway"], value, valueElementCount[0])
return True
elif propertyIdentifier == bacnet_propertyIdentifier["ipsubnetmask"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
valueElementCount[0] = db["networkPort"]["ipLength"]
octetStringCopy(db["networkPort"]["ipSubnetMask"], value, valueElementCount[0])
return True
elif propertyIdentifier == bacnet_propertyIdentifier["ipdnsserver"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
valueElementCount[0] = db["networkPort"]["ipNumOfDns"] * 4
for i in range(db["networkPort"]["ipNumOfDns"]):
octetStringCopy(db["networkPort"]["ipDnsServer"][i], value, 4, i * 4)
return True
elif propertyIdentifier == bacnet_propertyIdentifier["fdbbmdaddress"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
valueElementCount[0] = db["networkPort"]["ipLength"]
octetStringCopy(db["networkPort"]["FdBbmdAddressHostIp"], value, valueElementCount[0])
return True
return False
def CallbackGetPropertyInt(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyInt", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
if propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["integerValue"] and objectInstance == db["integerValue"]["instance"]:
value[0] = ctypes.c_int32(db["integerValue"]["presentValue"])
return True
return False
def CallbackGetPropertyTime(deviceInstance, objectType, objectInstance, propertyIdentifier, hour, minute, second,
hundrethSeconds, useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyTime", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
return False
def CallbackGetPropertyUInt(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex):
print("CallbackGetPropertyUInt", deviceInstance, objectType, objectInstance, propertyIdentifier, useArrayIndex,
propertyArrayIndex)
if deviceInstance == db["device"]["instance"]:
# Check for vendoridentifier property
if propertyIdentifier == bacnet_propertyIdentifier["vendoridentifier"]:
if objectType == bacnet_objectType["device"]:
value[0] = ctypes.c_uint32(db["device"]["vendoridentifier"])
return True
# Check for bacnetipudpport property
elif propertyIdentifier == bacnet_propertyIdentifier["bacnetipudpport"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
value[0] = db["networkPort"]["BACnetIPUDPPort"]
return True
# Network Port Object IP DNS Server Array Size property
elif propertyIdentifier == bacnet_propertyIdentifier["ipdnsserver"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
if useArrayIndex and propertyArrayIndex == 0:
value[0] = db["networkPort"]["ipNumOfDns"]
return True
# Check for fdbbmdaddress property
elif propertyIdentifier == bacnet_propertyIdentifier["fdbbmdaddress"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
if useArrayIndex and propertyArrayIndex == casbacnetstack_fdBbmdAddressOffset["port"]:
value[0] = db["networkPort"]["FdBbmdAddressPort"]
return True
# Check for fdsubscriptionlifetime property
elif propertyIdentifier == bacnet_propertyIdentifier["fdsubscriptionlifetime"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
value[0] = db["networkPort"]["FdSubscriptionLifetime"]
return True
# Check for PresentValue property
elif propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["multiStateInput"] and objectInstance == \
db["multiStateInput"]["instance"]:
value[0] = ctypes.c_uint32(db["multiStateInput"]["presentValue"])
return True
elif objectType == bacnet_objectType["multiStateValue"] and objectInstance == \
db["multiStateValue"]["instance"]:
value[0] = ctypes.c_uint32(db["multiStateValue"]["presentValue"])
return True
elif objectType == bacnet_objectType["positiveIntegerValue"] and objectInstance == \
db["positiveIntegerValue"]["instance"]:
value[0] = ctypes.c_uint32(db["positiveIntegerValue"]["presentValue"])
return True
# Check for NumberOfStates property
elif propertyIdentifier == bacnet_propertyIdentifier["numberofstates"]:
if objectType == bacnet_objectType["multiStateInput"] and objectInstance == \
db["multiStateInput"]["instance"]:
value[0] = ctypes.c_uint32(db["multiStateInput"]["numberOfStates"])
return True
elif objectType == bacnet_objectType["multiStateOutput"] and objectInstance == \
db["multiStateOutput"]["instance"]:
value[0] = ctypes.c_uint32(db["multiStateOutput"]["numberOfStates"])
return True
elif objectType == bacnet_objectType["multiStateValue"] and objectInstance == \
db["multiStateValue"]["instance"]:
value[0] = ctypes.c_uint32(db["multiStateValue"]["numberOfStates"])
return True
# Check for StateText array size (propertyArrayIndex = 0)
elif propertyIdentifier == bacnet_propertyIdentifier["statetext"]:
if objectType == bacnet_objectType["multiStateInput"] and objectInstance == db["multiStateInput"]["instance"]:
if useArrayIndex and propertyArrayIndex == 0:
value[0] = len(db["multiStateInput"]["stateText"])
return True
elif objectType == bacnet_objectType["multiStateOutput"] and objectInstance == db["multiStateOutput"]["instance"]:
if useArrayIndex and propertyArrayIndex == 0:
value[0] = len(db["multiStateOutput"]["stateText"])
return True
elif objectType == bacnet_objectType["multiStateValue"] and objectInstance == db["multiStateValue"]["instance"]:
if useArrayIndex and propertyArrayIndex == 0:
value[0] = len(db["multiStateValue"]["stateText"])
return True
return False
def CallbackSetPropertyUInt(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex, priority,
errorCode):
print(
"CallbackSetPropertyUInt", deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex,
priority, errorCode)
if deviceInstance == db["device"]["instance"]:
# Check for the fdbbmdaddress property, port portion
if propertyIdentifier == bacnet_propertyIdentifier["fdbbmdaddress"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
db["networkPort"]["FdBbmdAddressPort"] = value
db["networkPort"]["changesPending"] = True
return True
# Check for the fdsubscriptionlifetime property
elif propertyIdentifier == bacnet_propertyIdentifier["fdsubscriptionlifetime"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
db["networkPort"]["FdSubscriptionLifetime"] = value
db["networkPort"]["changesPending"] = True
return True
# Check for the PresentValue property
elif propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["multiStateValue"] and objectInstance == db["multiStateValue"][
"instance"]:
db["multiStateValue"]["presentValue"] = value
return True
return False
def CallbackSetPropertyReal(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex, priority,
errorCode):
print(
"CallbackSetPropertyReal", deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex,
priority, errorCode)
if deviceInstance == db["device"]["instance"]:
# Check for the PresentValue property
if propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["analogInput"] and objectInstance == db["analogInput"]["instance"]:
db["analogInput"]["presentValue"] = value
return True
elif objectType == bacnet_objectType["analogValue"] and objectInstance == db["analogValue"]["instance"]:
db["analogValue"]["presentValue"] = value
return True
# Check for the covincrement property
elif propertyIdentifier == bacnet_propertyIdentifier["covincrement"]:
if objectType == bacnet_objectType["analogInput"] and objectInstance == db["analogInput"]["instance"]:
db["analogInput"]["covIncrement"] = value
return True
elif objectType == bacnet_objectType["analogValue"] and objectInstance == db["analogValue"]["instance"]:
db["analogValue"]["covIncrement"] = value
return True
return False
def CallbackSetPropertyEnumerated(deviceInstance, objectType, objectInstance, propertyIdentifier, value, useArrayIndex,
propertyArrayIndex, priority,
errorCode):
print(
"CallbackSetPropertyEnumerated", deviceInstance, objectType, objectInstance, propertyIdentifier, value,
useArrayIndex,
propertyArrayIndex,
priority, errorCode)
if deviceInstance == db["device"]["instance"]:
# Check for the PresentValue property
if propertyIdentifier == bacnet_propertyIdentifier["presentValue"]:
if objectType == bacnet_objectType["binaryValue"] and objectInstance == db["binaryValue"]["instance"]:
db["binaryValue"]["presentValue"] = value
return True
return False
def CallbackSetPropertyOctetString(deviceInstance, objectType, objectInstance, propertyIdentifier, value, length,
useArrayIndex, propertyArray,
priority, errorCode):
print(
"CallbackSetPropertyOctetString", deviceInstance, objectType, objectInstance, propertyIdentifier, value, length,
useArrayIndex,
propertyArray, priority, errorCode)
if deviceInstance == db["device"]["instance"]:
if propertyIdentifier == bacnet_propertyIdentifier["fdbbmdaddress"]:
if objectType == bacnet_objectType["networkPort"] and objectInstance == db["networkPort"]["instance"]:
db["networkPort"]["FdBbmdAddressHostIp"][0] = value[0]
db["networkPort"]["FdBbmdAddressHostIp"][1] = value[1]
db["networkPort"]["FdBbmdAddressHostIp"][2] = value[2]
db["networkPort"]["FdBbmdAddressHostIp"][3] = value[3]
db["networkPort"]["changesPending"] = False
return True
return False
def CallbackReinitializeDevice(deviceInstance, reinitializedState, password, passwordLength, errorCode):
# Rebuild password from pointer reference
derefedPassword = rebuildString(password, passwordLength)
print(
"CallbackReinitializeDevice", deviceInstance, reinitializedState, derefedPassword, passwordLength, errorCode[0])
# This callback is called when this BACnet Server device receives a ReinitializeDevice message
# In this callback, you will handle the reinitializedState
# If reinitializedState = ACTIVATE_CHANGES (7) then you will apply any network port changes and store the values in
# non-volatile memory
# If reinitializedState = WARM_START(1) then you will apply any network port changes, store the values in
# non-volatile memory, and restart the device
# Before handling the reinitializedState, first check the password.
# If your device does not require a password, then ignore any password passed in.
# Otherwise, validate the password.
# If password invalid, missing, or incorrect: set errorCode to PasswordInvalid (26)
# In this example, a password of 12345 is required
# Check password before handling reinitialization
if passwordLength == 0 or derefedPassword != "12345":
errorCode[0] = bacnet_errorCode["password-failure"]
return False
# In this example, only the NetworkPort Object FdBbmdAddress and FdSubscriptionLifetime properties are writable and
# need to be stored in non-volatile memory. For the purpose of this example, we will not storing these values in
# non-volatile memory.
# 1. Store values that must be stored in non-volatile memory (i.e. must survive a reboot)
# 2. Apply any Network Port values that have been written to
# If any validation on the Network Port values fails, set errorCode to INVALID_CONFIGURATION_DATA (46)
# 3. Set Network Port ChangesPending property to false
# 4. Handle ReinitializedState. If ACTIVATE_CHANGES, no other action, return true
# If WARM_START, prepare device for reboot, return true. and reboot
# NOTE: Must return True first before rebooting so the stack sends the SimpleAck
if reinitializedState == casbacnetstack_reinitializeState["state-activate-changes"]:
db["networkPort"]["changesPending"] = False
return True
elif reinitializedState == casbacnetstack_reinitializeState["state-warm-start"]:
# Flag for reboot and handle reboot after stack responds with SimpleAck
db["networkPort"]["changesPending"] = False
errorCode[0] = 2
return True
else:
# All other states are not supported in this example
errorCode[0] = bacnet_errorCode["optional-functionality-not-supported"]
return False
def CallbackDeviceCommunicationControl(deviceInstance, enableDisable, password, passwordLength, useTimeDuration,
timeDuration, errorCode):
# Rebuild password from pointer reference
derefedPassword = rebuildString(password, passwordLength)
print("CallbackDeviceCommunicationControl", deviceInstance, enableDisable, derefedPassword, passwordLength,
useTimeDuration, timeDuration,
errorCode[0])
# This callback is called when this BACnet Server device receives a DeviceCommunicationControl message
# In this callback, you will handle the password. All other parameters are purely for logging to know
# what parameters the DeviceCommunicationControl request had
# To handle the password:
# If your device does not require a password, then ignore any password passed in
# Otherwise, validate the password
# If password invalid, missing, or incorrect: set errorCode to PasswordInvalid (26)
# In this example, a password of 12345 is required
# Check password
if passwordLength == 0 or derefedPassword != "12345":
errorCode[0] = bacnet_errorCode["password-failure"]
return False
# Return true to allow DeviceCommunicationControl logic to continue
return True
def CallbackLogDebugMessage(message, messageLength, messageType):
# Rebuild message from pointer reference
derefedMessage = rebuildString(message, messageLength)
print("CallbackLogDebugMessage", derefedMessage, messageLength, messageType)
if derefedMessage != "" and messageLength != 0:
print("CAS BACnet Stack DEBUG MESSAGE: ", derefedMessage)
# Main application
# -----------------------------------------------------------------------------
if __name__ == "__main__":
print("FYI: CAS BACnet Stack Python2.7 Server Example v{}".format(bacnet_server_example_python27_version))
print("FYI: https://github.com/chipkin/BACnetServerExamplePython2.7")
# 1. Load the CAS BACnet stack functions
# ---------------------------------------------------------------------------
# Load the shared library into ctypes
libpath = pathlib.Path().absolute() / libname
print("FYI: Libary path: ", libpath)
CASBACnetStack = ctypes.CDLL(str(libpath), mode=ctypes.RTLD_GLOBAL)
# Print the version information
print("FYI: CAS BACnet Stack version: " + str(CASBACnetStack.BACnetStack_GetAPIMajorVersion()) + "." +
str(CASBACnetStack.BACnetStack_GetAPIMinorVersion()) +
"." + str(CASBACnetStack.BACnetStack_GetAPIPatchVersion()) + "." +
str(CASBACnetStack.BACnetStack_GetAPIBuildVersion()))
print("FYI: CAS BACnet Stack python adapter version:" + str(casbacnetstack_adapter_version))
# 2. Connect the UDP resource to the BACnet Port and get network info
# ---------------------------------------------------------------------------
print("FYI: Connecting UDP Resource to port=[" + str(db['networkPort']['BACnetIPUDPPort']) + "]")
HOST = "" # Symbolic name meaning all available interfaces
udpSocket.bind((HOST, db["networkPort"]["BACnetIPUDPPort"]))
udpSocket.setblocking(False)
# Load network information into database
db["networkPort"]["ipAddress"] = [int(octet) for octet in
netifaces.ifaddresses(netifaces.interfaces()[0])[netifaces.AF_INET][0][
"addr"].split(".")]
db["networkPort"]["ipSubnetMask"] = [int(octet) for octet in
netifaces.ifaddresses(netifaces.interfaces()[0])[netifaces.AF_INET][0][
"netmask"].split(".")]
db["networkPort"]["ipDefaultGateway"] = [int(octet) for octet in
netifaces.gateways()["default"][netifaces.AF_INET][0].split(".")]
dnsServerOctetList = []
for dnsServer in dns.resolver.Resolver().nameservers:
dnsServerOctetList.append([int(octet) for octet in dnsServer.split(".")])
db["networkPort"]["ipNumOfDns"] = len(dnsServerOctetList)
db["networkPort"]["ipDnsServer"] = dnsServerOctetList
print("FYI: Local IP address: ", db["networkPort"]["ipAddress"])
# 3. Setup the callbacks
# ---------------------------------------------------------------------------
print("FYI: Registering the Callback Functions with the CAS BACnet Stack")
# Note:
# Make sure you keep references to CFUNCTYPE() objects as long as they are used from C code.
# ctypes doesn't, and if you don"t, they may be garbage collected, crashing your program when
# a callback is made
#
# Because of garbage collection, the pyCallback**** functions need to stay in scope.
# Core Callbacks
pyCallbackReceiveMessage = fpCallbackReceiveMessage(CallbackReceiveMessage)
CASBACnetStack.BACnetStack_RegisterCallbackReceiveMessage(pyCallbackReceiveMessage)
pyCallbackSendMessage = fpCallbackSendMessage(CallbackSendMessage)
CASBACnetStack.BACnetStack_RegisterCallbackSendMessage(pyCallbackSendMessage)
pyCallbackGetSystemTime = fpCallbackGetSystemTime(CallbackGetSystemTime)
CASBACnetStack.BACnetStack_RegisterCallbackGetSystemTime(pyCallbackGetSystemTime)
# GetProperty Callbacks
pyCallbackGetPropertyBitString = fpCallbackGetPropertyBitString(CallbackGetPropertyBitString)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyBitString(pyCallbackGetPropertyBitString)
pyCallbackGetPropertyBool = fpCallbackGetPropertyBool(CallbackGetPropertyBool)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyBool(pyCallbackGetPropertyBool)
pyCallbackGetPropertyCharString = fpCallbackGetPropertyCharString(CallbackGetPropertyCharString)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyCharacterString(pyCallbackGetPropertyCharString)
pyCallbackGetPropertyDate = fpCallbackGetPropertyDate(CallbackGetPropertyDate)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyDate(pyCallbackGetPropertyDate)
pyCallbackGetPropertyDouble = fpCallbackGetPropertyDouble(CallbackGetPropertyDouble)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyDouble(pyCallbackGetPropertyDouble)
pyCallbackGetPropertyEnum = fpCallbackGetPropertyEnum(CallbackGetPropertyEnumerated)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyEnumerated(pyCallbackGetPropertyEnum)
pyCallbackGetPropertyOctetString = fpCallbackGetPropertyOctetString(CallbackGetPropertyOctetString)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyOctetString(pyCallbackGetPropertyOctetString)
pyCallbackGetPropertyInt = fpCallbackGetPropertyInt(CallbackGetPropertyInt)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertySignedInteger(pyCallbackGetPropertyInt)
pyCallbackGetPropertyReal = fpCallbackGetPropertyReal(CallbackGetPropertyReal)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyReal(pyCallbackGetPropertyReal)
pyCallbackGetPropertyTime = fpCallbackGetPropertyTime(CallbackGetPropertyTime)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyTime(pyCallbackGetPropertyTime)
pyCallbackGetPropertyUInt = fpCallbackGetPropertyUInt(CallbackGetPropertyUInt)
CASBACnetStack.BACnetStack_RegisterCallbackGetPropertyUnsignedInteger(pyCallbackGetPropertyUInt)
# SetProperty Callbacks
pyCallbackSetPropertyEnumerated = fpCallbackSetPropertyEnum(CallbackSetPropertyEnumerated)
CASBACnetStack.BACnetStack_RegisterCallbackSetPropertyEnumerated(pyCallbackSetPropertyEnumerated)
pyCallbackSetPropertyOctetString = fpCallbackSetPropertyOctetString(CallbackSetPropertyOctetString)
CASBACnetStack.BACnetStack_RegisterCallbackSetPropertyOctetString(pyCallbackSetPropertyOctetString)
pyCallbackSetPropertyReal = fpCallbackSetPropertyReal(CallbackSetPropertyReal)
CASBACnetStack.BACnetStack_RegisterCallbackSetPropertyReal(pyCallbackSetPropertyReal)
pyCallbackSetPropertyUInt = fpCallbackSetPropertyUInt(CallbackSetPropertyUInt)
CASBACnetStack.BACnetStack_RegisterCallbackSetPropertyUnsignedInteger(pyCallbackSetPropertyUInt)
# BACnet Service Callbacks
pyCallbackReinitializeDevice = fpCallbackReinitializeDevice(CallbackReinitializeDevice)
CASBACnetStack.BACnetStack_RegisterCallbackReinitializeDevice(pyCallbackReinitializeDevice)
pyCallbackDeviceCommunicationControl = fpCallbackDeviceCommunicationControl(CallbackDeviceCommunicationControl)
CASBACnetStack.BACnetStack_RegisterCallbackDeviceCommunicationControl(pyCallbackDeviceCommunicationControl)
# pyCallbackLogDebugMessage = fpCallbackLogDebugMessage(CallbackLogDebugMessage)
# CASBACnetStack.BACnetStack_RegisterCallbackLogDebugMessage(pyCallbackLogDebugMessage)