BACnet API v2¶
The BACnet Specification contains many different object types beyond the typical Analog Value-style objects which most simple controllers use. Normal Framework supports fully decoding all standard object and property types when using the v2 API. The protocol parser has been compiled directly from the standards documents and therefore can provide a complete and conformant implementation of the specification. Using this API make it relatively straightforward to access objects with complex object types.
Making Confirmed Service Requests¶
In the BACnet standards, unary requests use the Confirmed Service choice. For instance, ReadProperty, WriteProperty, and ReadRange are different confirmed services.
The examples below show a few different types of requests. For full details on the effect and arguments for these methods, consult the protobuf documentation as well as BACnet specification for the service procedure and possible errors.
import requests
res = requests.post("http://localhost:8080/api/v2/bacnet/confirmed-service", data=json.dumps({
"device_address":{
"device_id": 260001,
},
"request": {
"read_property": {
"object_identifier": {
"object_type": "OBJECT_TYPE_ANALOG_OUTPUT",
"instance": 1,
},
"property_identifier": "PROPERTY_IDENTIFIER_PRIORITY_ARRAY",
"property_array_index": 4294967295,
},
},
}))
res = requests.post("http://localhost:8080/api/v2/bacnet/confirmed-service", data=json.dumps({
"device_address":{
"device_id": 260001,
},
"request": {
"read_range": {
"object_identifier": {
"object_type": "OBJECT_TYPE_TREND_LOG",
"instance": 1,
},
"property_identifier": "PROPERTY_IDENTIFIER_LOG_BUFFER",
"property_array_index": 4294967295,
"by_position": {
"reference_index": 1,
"count": 10,
},
},
},
}))
res = requests.post("http://localhost:8080/api/v2/bacnet/confirmed-service", data=json.dumps({
"device_address":{
"device_id": 260001,
},
"request": {
"atomic_read_file": {
"file_identifier": {
"object_type": "OBJECT_TYPE_TREND_LOG",
"instance": 1,
},
"stream_access": {
"file_start_position": 0,
"requested_octet_count": 10,
},
},
},
}))
import requests
res = requests.post("http://localhost:8080/api/v2/bacnet/confirmed-service", data=json.dumps({
"device_address":{
"device_id": 260001,
},
"request": {
"device_communication_control": {
"time_duration": 10,
"enable_disable": "ENABLE_DISABLE_DISABLE_INITIATION",
"password": "0xdeadbeef",
}
},
}))