Skip to content

Discovering devices

Łukasz Dywicki edited this page Jan 2, 2019 · 5 revisions

How discovery works

To get your device discovered you will need an "assembly" archive. This is due to fact that bacnet4j-wrapper as a project was intended to be utility library. From this point of view it does not deliver any functionality but just provides ability to "talk" with BACnet world.

As library currently supports only BACnet/IP discovery supports only this interface. Even if devices from logical point of view are the same with different link layers - there is no support for other connection methods.

Discovery test program

To run discovery program you need Java Runtime to be installed and java executable available in path. The assembly-1.0.2.jar file mentioned in commands is archive name. It might be in your Downloads and be referenced via relative or full path.

java -cp assembly-1.0.2.jar org.code_house.bacnet4j.wrapper.ip.DiscoveryMain

Above command will cause scanning of all network interfaces existing in your system and delivering WHO-IS request to each of these. If there will be any devices they should respond with their identifiers. From this point discovery program will ask about OBJECT-LIST for every device and try to retrieve their current values.

Additional note here - object types (such Schedule, Command) which are unsupported by library will be ignored. They will not be shown in program execution final results.

Additional options to program:

Index Option Since Default Description
1 address 1.0.1 * Broadcast address to be used for delivering WHO-IS request to network. By default all network interfaces are scanned
2 timeout 1.0.1 30 Limit of time to wait for return of WHO-IS replies. For local networks it is sufficient to set it to 10, but for bigger deployments it might be necessary to increase this number.
3 device id 1.0.1 1339 Identifier of virtual device created by program in BACnet.
4 output file 1.0.2 stdout Name of file to which discovery results should be stored.

When you do not specify any arguments commands looks like this:

java -cp assembly-1.0.2.jar org.code_house.bacnet4j.wrapper.ip.DiscoveryMain * 30 1339

Command with all options:

java -cp assembly-1.0.2.jar org.code_house.bacnet4j.wrapper.ip.DiscoveryMain 10.10.10.2555 60 1410 disco.txt

Arguments are ordered and they must occur in given order:

java -cp assembly-1.0.2.jar org.code_house.bacnet4j.wrapper.ip.DiscoveryMain [address] [timeout] [device-id] [output-file]

Generating CSV output

Starting from 1.1.0 release there is one more network program provided - a CSV exporter. Its arguments are the same as for discovery program including redirecting output to file.

Below is sample output of program:

Network,Address,DeviceId,ObjectType,ObjectIdentifier,Name,Units,Description
0,"192.168.1.144:47808",2014,analogOutput,1,"Bypass level","percent",""

Generating OpenHab configuration

Because this library was intended as thin overlay over BACnet4J its primary use case is there. Even if openhab syntax is fairly simple it might be difficult to start on with bigger network or more complex device. Starting from version 1.0.1 it is possible to create configuration file for OpenHab. Generated configuration is just starting point in integrating your device, but it should boost time needed for adoption of your industrail (or home :)) infrastructure.

To get configuration generator running you gonna need again assembly jar. Command with all possible arguments looks like below:

java -cp assembly-1.0.2.jar org.code_house.bacnet4j.wrapper.ip.GeneratorMain [address] [timeout] [device-id] [generate-groups] [generate-tags] [output-file]

First three arguments are known from discovery program described above. Last two arguments are there in order to create groups and tags which are optional in intems syntax.

Index Option Since Default Description
4 groups 1.0.1 true Creates group names from available information about property
5 tags 1.0.1 true Creates tag names from available information about property
6 output file 1.0.2 stdout File for storing results of discovery

Be aware that generated groups and tags are just for supporting purposes. Not all properties deliver useful information (such units) which might lead to malformed items file. Please pay attention to that and in case of any troubles disable groups and tags from final output and assign groups and tags manually.

Example command call:

java -cp assembly-1.0.2.jar org.code_house.bacnet4j.wrapper.ip.GeneratorMain 192.168.1.255 10 1339 false false oh22.items
Clone this wiki locally