• Recent
    • Tags
    • Popular
    • Register
    • Login

    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 Mango 5 Documentation Website

    Multiple devices on one transport

    BACnet4J general discussion
    2
    5
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kevin Herron
      last edited by

      Is it possible to have multiple LocalDevice instances (each with their own device number) share the same transport?

      Or am I stuck with one LocalDevice per available local IP address to bind to, essentially?

      1 Reply Last reply Reply Quote 0
      • terrypackerT
        terrypacker
        last edited by

        I have some example code for using 2 transports with 2 local devices bound to the same port. Would that solve your problem or do you need 1 transport? At the time I wrote the example I did not consider sharing the transport between devices.

        
        /**
         * Copyright (C) 2018  Infinite Automation Software. All rights reserved.
         */
        package com.infiniteautomation.bacnet4j.npdu.ip;
        
        import java.net.InterfaceAddress;
        import java.util.List;
        
        import org.junit.Assume;
        import org.junit.Test;
        
        import com.serotonin.bacnet4j.LocalDevice;
        import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
        import com.serotonin.bacnet4j.npdu.ip.IpNetworkBuilder;
        import com.serotonin.bacnet4j.transport.DefaultTransport;
        import com.serotonin.bacnet4j.transport.Transport;
        
        /**
         * @author Terry Packer
         *
         */
        public class MulltipleLocalDevices {
            
            
            @Test
            public void testMultipleLocalDevices() throws Exception {
                
                List<InterfaceAddress> usable = BacnetIpUtils.listUsableBACnetInterfaces();
                Assume.assumeTrue(usable.size() > 0);
                
                InterfaceAddress address = usable.get(0);
                String bindAddress = address.getAddress().toString().split("/")[1];
                String broadcastAddress = address.getBroadcast().toString().split("/")[1];
                
                //Configure the first network, ensure we set reuse address
                IpNetwork networkOne = new IpNetworkBuilder()
                        .withLocalBindAddress(bindAddress)
                        .withBroadcast(broadcastAddress, address.getNetworkPrefixLength())
                        .withLocalNetworkNumber(1).withPort(9000).withReuseAddress(true).build();
                Transport transportOne = new DefaultTransport(networkOne);
                LocalDevice localDeviceOne = new LocalDevice(1, transportOne);
                
                
                
                IpNetwork networkTwo = new IpNetworkBuilder()
                        .withLocalBindAddress(bindAddress)
                        .withBroadcast(broadcastAddress, address.getNetworkPrefixLength())
                        .withLocalNetworkNumber(1).withPort(9000).withReuseAddress(true).build();
                Transport transportTwo = new DefaultTransport(networkTwo);
                LocalDevice localDeviceTwo = new LocalDevice(2, transportTwo);
                
                localDeviceOne.initialize();
                localDeviceTwo.initialize();
                
            }
        
        }
        
        
        1 Reply Last reply Reply Quote 0
        • K
          Kevin Herron
          last edited by Kevin Herron

          @terrypacker Yes, I think that's what I need. Thank you.

          Now I need to decide if I should share one LocalDevice among the many different connections* my application might have or if each connection should have its own LocalDevice instance.

          If you've got any insight to share that would be welcome.

          • well, "connections", being UDP and all... but let's say configured remote device instances.
          1 Reply Last reply Reply Quote 0
          • terrypackerT
            terrypacker
            last edited by

            @Kevin-Herron I think that will depend on your network topology. Inside Mango we share a local device across many BACnet data sources. But we also all creating many local devices in case you want to use them in different data sources.

            K 1 Reply Last reply Reply Quote 0
            • K
              Kevin Herron @terrypacker
              last edited by

              @terrypacker said in Multiple devices on one transport:

              But we also all creating many local devices in case you want to use them in different data sources.

              I'm not sure what you meant here.

              If it helps, I really only need a LocalDevice at all because that seems to be what's required by the library for communicating with RemoteDevices. I will be not be populating the shared or multiple LocalDevices with additional objects.

              My original plan was to have one LocalDevice per network adapter that might be used. For most systems this would mean just one LocalDevice.

              Is there any reason to have multiple LocalDevices (which I assume requires its own device number each) if I'm not going to be actually exposing any objects?

              I'm essentially only interested in reading from or writing to other BACnet devices on the network.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post