Menu

BBMD support

Help
2015-12-07
2015-12-17
  • Guillaume Dujardin

    Hello,

    I'm sorry to revive an old request here, but I wonder if there has been any breakthrough concerning BBMD support with BACnet4J ?
    BACnet4J looks nice because I need to write Schedule Objects on remote BACnet devices, but I would like to do so through internet.
    I need my linux server to read and write properties on a BACnet device in a remote network, and as far as I understand, it can only be achieved with a BBMD.

    If BACnet4J still doesn't support BBMD, I would be happy if someone knows an alternative which allows BACnet/IP communication through internet.

    Thanks !

    Best regards,
    Guillaume Dujardin

     
  • Matthew Lohbihler

    BBMD support was added a few months ago. See https://github.com/mlohbihler/BACnet4J

     
    • Guillaume Dujardin

      That's great, thank you !

       
  • Guillaume Dujardin

    Hello again,

    I'm glad you added BBMD support recently, but I still have some issues with the use of the library.

    At first, I was not able to do anything with the recent commits on github (BBMDTest was blocking) until terrypacker's commit (18b2b55) yesterday ! So thanks to terrypacker who probably fixed an issueregarding the use of DatagramSocket.

    Now the library works fine in a local network : I can read and write properties properly on my BACnet device (which is a WAGO BACnet/IP controller with a BBMD).

    However, when I try to communicate from a distant network, I am not able to find my remote device.
    Here is a little drawing trying to explain what I want :
    1

    • my WAGO BACnet Controller is on a network, let's say with Public IP "1.2.3.4" ; a router on this network forwards the port 47808 directly on my WAGO device.
    • I have a Server with public IP "5.6.7.8" where my BACnet4J app is running. Firewall and stuff are configured to let UDP communication free on port 47808.
    • I configured the WAGO BBMD so that there is two entries : the WAGO network "1.2.3.4:47808) and my server network (5.6.7.8:47808). Foreign Devices are allowed.

    When I run the code below on my Server (IP "5.6.7.8")

    public class BACtests {
        static LocalDevice localDevice;
        static RemoteDevice d;
    
        public static void main(String[] args) throws Exception {
    
            IpNetwork network = new IpNetworkBuilder().broadcastIp("10.0.0.0").localBindAddress("10.0.0.4").subnetMask("255.255.255.255").build();
            Transport transport = new DefaultTransport(network);
            localDevice = new LocalDevice(815, transport);
    
            try {
                localDevice.initialize();
                network.registerAsForeignDevice(new InetSocketAddress("1.2.3.4"/* public IP of my remote network where is my WAGO BACnet device */, 47808), 1000);
    
                d = DiscoveryUtils.discoverDevice(localDevice, 377316 /* my remote BACnet device ID */);
    
                if (d == null)
                    throw new RuntimeException("Remote device not found");
    
                readRequest(); //reading properties and stuff...
                writeRequest(); //writing properties and stuff...
    
            }
            finally {
                localDevice.terminate();
            }
        }
    
        //...
    }
    

    I get the following exception :

    Exception in thread "main" java.lang.ClassCastException: com.serotonin.bacnet4j.type.constructed.BACnetError cannot be cast to com.serotonin.bacnet4j.type.constructed.ServicesSupported    at com.serotonin.bacnet4j.util.DiscoveryUtils.discoverDevice(DiscoveryUtils.java:95)
        at com.serotonin.bacnet4j.util.DiscoveryUtils.discoverDevice(DiscoveryUtils.java:95)
        at bactests.BACtests.main(BACtests.java:59)
    

    When I run this code in the WAGO network (IP "1.2.3.4", with adequate modifications in the code), everything is OK.
    I did some check with tcpdump, and I can see UDP packets going in both my networks, but for some reason the WAGO response is not what BACnet4J expected, only when it's through the internet.

    If you have any idea about what is going on, I would be very happy if you tell me. I might be missing something, considering I am just tinkering and I know very little of BACnet's twists and turns !

    Also, thank you for all the work you provide :)

    Best regards,
    Guillaume Dujardin

    [1] : http://i.imgur.com/rIo1ma8.jpg?3

     

Log in to post a comment.