BACnet4J 3.2 and BBMD/Foreign Device Support
-
Can this additional functionality be accessed by manually making entries in either the BDT or FDT tables? If so, can this be accomplished via dashboard or scripting Data Source?
How could I accomplish registration using this function via the UI?
public void registerAsForeignDevice(final InetSocketAddress addr, final int timeToLive) throws BACnetException { if (timeToLive < 1) throw new IllegalArgumentException("timeToLive cannot be less than 1"); if (getTransport() == null || getTransport().getLocalDevice() == null) throw new IllegalArgumentException(...........
The BACnet network I am working with requires Foreign Devices to register with the BBMD in order to route broadcasts.
Thank you
-
Hi Wingnutz, great question!
I wonder if we should be offering this as optional settings on any local device.
Yes you can call it, but I'm not sure the timing will be ideal... you may need to send a broadcast manually afterward.
I think what you'll want to do is something like....
if(RuntimeManager.isDataSourceEnabled("DS_BAC_xid") && !this.initialized) { //ensure the data source has started, so that it has created the local device var localDeviceConfig = com.serotonin.ma.bacnet.device.LocalDeviceDwr.getLocalDevice( "12345678-abcd-1234-94ba-9301406140aa" ); //get this by exporting your BACnet source or local devices, the local device id var localDevice = com.serotonin.ma.bacnet.device.LocalDeviceFactory.getLocalDevice(localDeviceConfig, null); var ipNetwork = localDevice.getNetwork(); try { ipNetwork.registerAsForeignDevice( new java.net.InetSocketAddress("192.168.1.123", 0xBAC0), 60 ); //You may want to do a broadcast? new com.serotonin.ma.bacnet.BACnetDiscovery(com.serotonin.m2m2.Common.getTranslations(), "local_device_id"); this.initialized = true; } catch(e) { this.initialized = false; //print(e.getMessage()); } finally { com.serotonin.ma.bacnet.device.LocalDeviceFactory.releaseLocalDevice(localDevice, null); } } else { this.initialized = false; //should the data source be restarted, this script would have to observe it off for a poll to register again. //If this were a problem, you could use a binary point on the script to reinitialize the bacnet data source, // RuntimeManager.disableDataSource(xid), sleep at least one poll period of the bacnet DS, // or wait on com.serotonin.m2m2.Common.runtimeManager.isDataSourceRunning(dsid) but you'll need the data source's ID. }
-
Phil, thank you very much.
I added your suggested code to a scripting DS, saved, and was successfully registered after only clicking on the script validation icon. No additional interaction required so far.Registration request was sent -
0_1511296630199_7e10a1a2-054c-4101-9ca7-241310bff311-image.png
and success response returned.
0_1511296660583_e418dbda-e2a8-4145-9898-1ed7893298c4-image.png
I will continue to watch and provide updates if anything changes. Thanks again!!
-
Great! Hope that does what you need.
Pretty much any time the script is going through Java code to do something, it'll happen during validation or actual runtime the same. Things like the RuntimeManager, JsonEmport or calling the set() function will only actually change things if running, since they're going through mechanisms particular to the scripts.