BACnet4J
BACnet4J copied to clipboard
Mstp test code broken
Hi,
the test here https://github.com/infiniteautomation/BACnet4J/blob/60709d702cb576710f900b5534fc015dc7ed9f94/src_test/com/serotonin/bacnet4j/discovery/MstpObjectList.java#L28
is broken
the util.sero doesn't contain SerialParameters anymore
import com.serotonin.bacnet4j.util.sero.SerialParameters;
Do you have any example about how to discover devices using mstp?
Thanks
Unfortunately when BACnet4J moved to version 4 we wrote new tests and didn't bring the example code forward. The src_test code was left there for reference but it does not compile, eventually when we have time the plan is to bring the examples in src_test up to date with version 4.
As for your question as to how to discover devices the general logic would be:
- Send WhoIs
WhoIsRequest whoIs = new WhoIsRequest(); localDevice.sendGlobalBroadcast(whoIs); - Upon IAm response request Device Properties
public class BACnetDiscovery extends DeviceEventAdapter {
@Override
public void iAmReceived(RemoteDevice d) {
try {
Map<PropertyIdentifier, Encodable> result = RequestUtils.getProperties(localDevice, d, null,
PropertyIdentifier.vendorName,PropertyIdentifier.systemStatus);
bean.setVendor(result.get(PropertyIdentifier.vendorName).toString());
bean.setSystemStatus(result.get(PropertyIdentifier.systemStatus).toString());
} catch (Exception e) {
LOG.warn("Failed to get additional properties for discovered device", e);
}
}
}