You can find the source code for this sample by downloading a zip of all of our samples here and navigating to the
samples-develop\AllJoyn\Samples\BACnetAdapter. The sample code is available in C++. Make a copy of the folder on your disk and open the project from Visual Studio.
This document describes the setup of the BACnet Adapter for Device System Bridge on Windows 10. When using it you will be able to expose BACnet devices to AllJoyn.
BACnet is a communications protocol for building automation and control networks. It is an ASHRAE, ANSI, and ISO 16484-5 standard protocol. BACnet was designed to allow communication of building automation and control systems for applications such as heating, ventilating, and air-conditioning control (HVAC), lighting control, access control, and fire detection systems and their associated equipment. The BACnet protocol provides mechanisms for computerized building automation devices to exchange information, regardless of the particular building service they perform. BACnet is an object based standard. A BACnet device contains a set of objects. A BACnet object is a collection of information within a device. A typical object has a collection of properties, based on the function and purpose of the object. A BACnet Device is represented as a “Device Object” which is simply a collection of objects that represents the functions actually present in a given real device.
See BACnet standard for more information about BACnet…
The BACnet hardware described above has been used to control and expose on AllJoyn two occupancy sensors, two temperature sensors, two temperature controllers and one body controller.
Note that in Windows 10, when a machine has multiple AllJoyn modern applications that need to interact on the same machine, the user must add a loopback exemption for these modern applications. Consequently, if you run both the ZigBee adapter and IoT Explorer for AllJoyn on the same machine you will need to add a loopback exemption for these 2 applications. This isn’t needed for application you run from Visual Studio 2017. Note that when deploying an application from Visual Studio 2017, the loopback exemption is for the lifetime of the installed application. Meaning that you can launch the app directly (not from Visual Studio 2017) afterwards and it will have the loopback exemption.
Set up loopback exception:
CheckNetIsolation LoopbackExempt -a -n=installation-folder-name
samples-develop\AllJoyn\Samples\BACnetAdapter\BACnetAdapter.slnin Visual Studio.
BACnet adapter is written in managed C++. It uses the open BACnet stack which is available on sourceforge.net to interact with BACnet device and exposes them on AllJoyn through BridgeRT interface. A BACnet device is exposed in AllJoyn as follow:
After selecting BACnet001 VLC-2 device, we can see all the objects the device exposes.
The BACnetAdapter class is the main class of BACnet adapter. This class derives from IAdapter (BridgeRT interface) and contains a collection of BACnetAdapterDevice instances and an instance of the BACnetInterface class. BACnetAdapter class uses BACnetAdapterSignal to signal device arrival or removal.
The BACnetInterface class along with BACnetServiceHandlers class handle the interactions with the BACnet devices. They use mechanism provided by the open BACnet stack to handle BACnet devices. See open BACnet stack documentation for more detail about its architecture and the API it provides.
The BACnetAdapterDevice class represents a BACnet device. This class derives from IAdapterDevice (BridgeRT interface) and contains a collection of BACnetAdapterProperty and BACnetAdapterSignal instances.
The BACnetAdapterProperty class represents a BACnet object and derives from IAdapterProperty (BridgeRT interface). This class contains a collection of BACnetAdapterAttribute instances.
The BACnetAdapterAttribute class represents a BACnet property and derives from IAdapterAttribute (BridgeRT interface). BACnet property change notification is handled through an instance of BACnetAdapterSignal from BACnetAdapterDevice class. The value of the property is hosted by an instance of BACnetAdapterValue class.
The BACnetAdapterValue class is used to store value of BACnet property. This class derives from IAdapterValue (BridgeRT interface).
The BACnetAdapterSignal class is used to handle notification such as device arrival or removal as well as change of value. This class derives from IAdapterSignal (BridgeRT interface).