Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

local Device is not updated with the properties set and objects added to it


  • 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


  • Since the initialize() command was not executed, localDevice was not initialized. So the above issues are faced. Once the port is closed, local; device was initialized and was updated with objects, services and property values.

    However I-Am response has not received for Who-Is.

    Thanks & regards,
    Kishore


  • Hi Kishore,

    Can you try using the bind address of 0.0.0.0 ?


  • Hi Phildunlap,

    Even after binding to 0.0.0.0, I-Am message is not sent automatically for Who-Is broadcast message.



  • Hi,

    After the debugging I-AM is sent from the code. At line 648 DefaultTransport.java call is passed onto ur.getservice().handle(localdevice, from) wherein it sends I-Am. However at the outset it seems this line is skipped to execute hence there was no I-Am..

    Further the I-A,m is always sent as broadcast messages through the above mentioned code.. To avoid network traffic it is advisable to send unicast I-Am. So if we implement the same in the device Listener of our application, first Unicast I-Am would be sent. Subsequently once again the service.handle() would be executed resulting immediate I-Am as broadcast.

    So how to avoid two I-Am messages?

    Thanks & Regards,
    Kishore


  • Hi Philip,

    I got the issue, If the local device is bind to other than 0.0.0.0 say for example 192.168.1.133 with the correct broadcast address 192.168.1.255, local device is not responding with I-Am. Local Device expects bind address should be 0.0.0.0. But every time we cannot set 0.0.0,.0 as bind address if we have multiple IP port, and would prefer to bind it one one particular address.

    After some search, I noticed that same issue has been discussed in detail in the following post: https://forum.infiniteautomation.com/post/23468

    However I am not finding the fix for the issue in that thread. In that thread it was mentioned that issue#43 is fix for it. But after understanding the description, fix for issue#43 is not the for for the current issue So please share the fix for the issue mentioned in the above thread.

    Thanks & Regards,
    Kishore