BACnet

As part of the Edge Xpert distribution, IOTech provides a Building Automation and Control Network (BACnet) Device Service. This allows Edge Xpert to read data from BACnet devices and to issue commands.

The BACnet Device Services integrate the BACnet protocol with Edge Xpert. There are two BACnet Device Services:

  • BACnet/IP
  • BACnet/MSTP

For more information, refer to the offical ASHRAE SSPC 135 website.

The BACnet Device Service supports the following key features:

  • The addition of the BACnetSupportedServices protocol

  • Discovery of BACnet devices as follows:

    • BACnet/IP: on localhost using the standard BACnet/IP port (47808)
    • BACnet/MTSP: using the DefaultDevicePath value in the TOML configuration file

    Devices are queried for their device name, which is used to match a device profile. To match the device name with a device profile, all characters following the first underscore are removed. If a matching device profile is found, the device is added to EdgeXpert. For example, a device with the name KMC.BAC.9001_00283 would be matched to a device profile called KMC.BAC.9001. Any discovered device is also queried for its supported services, which are set up in the BACnetSupportedServices protocol

  • Reading a single value from a BACnet device

  • Reading multiple values from a BACnet device when the BACnetSupportedServices protocol is present and DS-RPM-B is set

  • Writing a single value to a BACnet device

  • Writing multiple values to a BACnet device when the BACnetSupportedServices protocol is present and DS-WPM-B is set

The BACnet Device Service supports the following data types:

  • Boolean
  • String
  • UInt8, UInt16, UInt32
  • Int8, Int16, Int32
  • Float32
  • Float64

Note

The BACnet Device Service can be embedded with Edge XRT. For further information on implementing Edge XRT with a Device Service, see Edge XRT.

BACnet Attributes

The device profile defines what resources are available on a particular device. Ensure that the following profile attributes are defined in the YAML file:

Required Profile Attributes
Attribute Description
type The object type. Object types are specified in an enum in the bacenum.h file. For more information on BACnet objects, refer to the Sourceforge website
instance The object instance to be read
property The property to read from the object instance
index The array index of the property

BACnet Examples

The following examples assume that the Edge Xpert services have been started with at least the --xpert-manager, --device-bacnet and --bacnet-server parameters. They use the example bacnet-server provided as part of the open source BACnet stack. A suitable startup command would be as follows:

edgexpert up --xpert-manager --device-bacnet --bacnet-server

Note

The bacnet-server simulates a BACnet device. This allows you to run the examples without having a physical device attached.

BACnet/IP Examples

If you want to communicate with devices outside the subnet on which the device-bacnet container runs, you must set up BACnet/IP Broadcast Management Device (BBMD):

The following examples illustrate how the BACnet/IP Device Service can be used:

BACnet/MSTP Examples

If using BACnet/MSTP, you must create a local copy of docker-compose.yml before starting the Device Service, as described in the Using a Custom docker.compose File section of the Edge Xpert Command Line Interface Tool topic. Once you have created the local file, complete the following steps:

  1. Locate the device-bacnet entry in the Device Service section

  2. Locate entrypoint in the device-bacnet entry

  3. Change the entrypoint value from /device-bacnet-ip to /device-bacnet-mstp

  4. Locate command in the device-bacnet entry

  5. Change the command value from --confdir=/res/ip --name=device-bacnet to --confdir=/res/mstp --name=device-bacnet

  6. Locate ports: in the device-bacnet entry

  7. Uncomment the - "49980:49980" line and comment out the - "49981:49981" line

  8. Locate devices in the device-bacnet entry

  9. Uncomment the following lines, and ensure that the second line points to the correct device:

    #    devices:
    #      - /dev/ttyUSB0
    

    There are two ways to find the device path, depending on whether the device is already connected or not.

    If the device is not yet connected, you can find the device path by entering the following command before inserting the USB:

    dmesg -w
    

    The output from this command shows where the USB is connected.

    If the device is connected, you can find the device path by entering the following command:

    lsusb
    

    The output from this command lists the full name and bus of connected USBs.

    The device path is usually something like /dev/tty/USB*x*

    The x is the USB port number.

  10. Optionally, comment out the BBMD environment variables as shown below. If you do not do this, the BACnet/MSTP Device Service is not affected.

    environment:
      <<: *common-variables
#      BACNET_BBMD_ADDRESS: $BBMD_ADDRESS
#      BACNET_BBMD_PORT: $BBMD_PORT

The following examples illustrate how the BACnet/MSTP Device Service can be used: