-
Notifications
You must be signed in to change notification settings - Fork 7
Creating a local BACnet device
To communicate with remote BACnet/IP devices, a local device instance is necessary. The following code snippet shows how to create a local device:
IpNetwork network = new IpNetwork(IpNetwork.DEFAULT_BROADCAST_IP, IpNetwork.DEFAULT_PORT);
Transport transport = new Transport(network);
int localDeviceID = 10000 + (int) ( Math.random() * 10000);
LocalDevice localDevice = new LocalDevice(localDeviceID, transport);
localDevice.initialize();
The first line creates a new IP network with the default broadcast address (255.255.255.255) and the default BACnet port (0xBAC0). For BACnet communication, the port numbers from 0xBAC0 to 0xBACF are reserved.
After a new transport object instance has been created, the snippet creates a random instance number for the local device. According to the BACnet specification, the instance number must be between 0 and 4194302 and must be unique within the BACnet network. The specification also claims that the instance number of a device must be configurable. Finally, the local device instance can be created and initiated.
Back to bacnet4J page