Hello,
The local device is not updated with the objects that are added, properties that are set except the object identifier which the local device is picking from the constructor. Below is the code :
package com.test.mavenproject1;
import com.serotonin.bacnet4j.LocalDevice;
import com.serotonin.bacnet4j.exception.BACnetServiceException;
import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
import com.serotonin.bacnet4j.npdu.ip.IpNetworkBuilder;
import com.serotonin.bacnet4j.obj.BACnetObject;
import com.serotonin.bacnet4j.transport.DefaultTransport;
import com.serotonin.bacnet4j.transport.Transport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.serotonin.bacnet4j.type.constructed.ObjectTypesSupported;
import com.serotonin.bacnet4j.type.constructed.SequenceOf;
import com.serotonin.bacnet4j.type.constructed.ServicesSupported;
import com.serotonin.bacnet4j.type.enumerated.ObjectType;
import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
import com.serotonin.bacnet4j.type.enumerated.RestartReason;
import com.serotonin.bacnet4j.type.primitive.CharacterString;
import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
public class App
{
public static void main( String[] args ) throws Exception
{
final int port = 47808;
IpNetwork network;
System.out.println( "Hello World!" );
network = new IpNetworkBuilder()
.withSubnet("192.168.1.0", 24)
.withLocalBindAddress("192.168.1.107")
.withPort(port)
.build();
final Logger LOG = LoggerFactory.getLogger(DefaultTransport.class);
LOG.debug("Default Transport class");
Transport transport = new DefaultTransport(network);
System.out.println( "Default Transport class!" );
ServicesSupported servicesSupported=new ServicesSupported();
servicesSupported.setAll(false);
servicesSupported.setWhoIs(true);
servicesSupported.setReadProperty(true);
LocalDevice localDevice = new LocalDevice(1000, transport)
.withPassword("1234")
.withAPDUTimeout(new UnsignedInteger(3000))
.withNumberOfApduRetries(new UnsignedInteger(3))
.writePropertyInternal(PropertyIdentifier.protocolServicesSupported, servicesSupported);
try {
localDevice.initialize();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(localDevice.getInstanceNumber());
System.out.println(localDevice.get(PropertyIdentifier.objectIdentifier));
System.out.println(localDevice.getId());
localDevice = localDevice.writePropertyInternal(PropertyIdentifier.location, new CharacterString("Puvys"));
localDevice = localDevice.writePropertyInternal(PropertyIdentifier.description, new CharacterString("Server Device"));
localDevice = localDevice.writePropertyInternal(PropertyIdentifier.activeCovSubscriptions, new SequenceOf<>());
ObjectTypesSupported ots=new ObjectTypesSupported();
ots.allFalse();
ots.set(ObjectType.analogValue, true);
localDevice = localDevice.writePropertyInternal(PropertyIdentifier.protocolObjectTypesSupported, ots);
ObjectIdentifier objectId = new ObjectIdentifier(ObjectType.analogValue, 1);
BACnetObject object = new BACnetObject(localDevice, objectId);
try {
localDevice.addObject(object);
} catch (BACnetServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(localDevice.getServicesSupported());
}
}
For the above the code, we faced the following issues when communicated from 3rd party client
-
For Who-is, I-Am has not been received from the local Device.
-
Correct response is received for Read-Property : Object Identifier
-
Incorrect value is returned for APDU Timeout. As per the above code 3000 is expected, but returned 6000 which is never set.
-
Incorrect value for Protocol_Services_Supported.
-
Analog Value,1 added is not returned while reading Object-List.
-
Output of the print statements are correct.
-
In spite of client functionalities are not added in the above code, after receiving Who_Is from the 3rd party client local devices started sending ReadProperty requests, but not the I-Am.
Please provide the solution. Your quick response is appreciated.
Thanks & Regards,
Kishore