"Hello World" BACNet device
-
Hi, I'm trying to get a minimum BACNet device going but it doesn't seem to respond. The code is as small as I could make it:
LocalDevice dev = new LocalDevice(76, new DefaultTransport(new IpNetwork("192.168.2.255", 47808, "192.168.2.104", "255.255.255.0", 0, false))); BACnetObject obj = createAnalogValue(1); dev.addObject(obj); dev.initialize();
When I try to "ping" it with a tool like:
bacnet-stack-0.8.3/bin/bacwi
nothing happens.
I'm certain I'm doing something stupid but I can't find any example or even something similar to this in the test directory. Any help to get me started is appreciated. -
bacnet-stack-0.8.3 is Steve Karg's C implementation of the BACNet protocol, if I'm not mistaken. It uses BACNET/IP as the transport layer and bacnet4j uses MS/TP as the transport layer. That might be why one doesn't see the other. I have both too and would also like to see them working together.
-
BACnet4J supports both MSTP and IP
-
I like that answer even better.
So, three questions (I'm using the bacnet4j library v3.2.4)
Here is my initialization of a localObject:
IpNetwork network = new IpNetworkBuilder().broadcastIp(broadcastIPString).localBindAddress(ipAddressString).port(port).subnetMask(subnetMaskString).build();
DefaultTransport transport = new DefaultTransport(network);
LocalDevice localDevice = new LocalDevice(deviceID, transport);1.Am I using MS/TP or BACNet/IP?
2.Given an artibrary localDevice, how you do tell which of these two it is using?
3.Whichever I'm using above, how do I initalize my localObject with the other protocol? (e.g. if the above is MS/TP, how do I change it to use BACNet/IP)?Thanks, much obliged.
-
- IP, hence the "IpNetwork" and "IpNetworkBuilder" instead of MstpNetwork
- if( localDevice.getNetwork() instanceof IpNetwork ) return "It's an IP network!";
- Create an MstpNetwork and pass it to new DefaultTransport( mstpNetwork );
-
Ah, so simple. Facepalm moment for me.
Thanks for the tip! -
Thank you, will try this. Have moved forward with my project (simulation of offices/SCADA/ICS systems) but parked the BACnet connection, will work it into the backlog.