• 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

    Getting remote device by using device IP Address and not sending broadcast??

    BACnet4J general discussion
    2
    4
    2.0k
    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.
    • E
      ealebie
      last edited by

      Hi,

      I have the device Id's and ip addresses for all the devices I need to retrieve data from. My machine sits on the same network as all the bacnet devices I need to access.

      getRemoteDeviceBlocking(int, int) sends a broadcast with the device ID to find the remote device, This is currently not working for me. in my wireshark capture I can see the broadcast being sent out, but I never get a response back.

      Since I have the IP wouldn't it be better to just query the ip no to unnecessarily flood the network. I don't see a method allowing me to do so.

      Maybe I'm not using this the right way, Could it be that I have to use localDevice since I have the IP for all devices I need?

      Here in my sample test code:

      Thank you!

         int instance = Integer.parseInt(args[0]);
         int timeout = Integer.parseInt(args[1]);
      	
          Integer deviceId = 1234;
          int port = 0xBAC0;
      	String localBindAddress = "10.116.189.90";
      
          IpNetworkBuilder builder = new IpNetworkBuilder();
          builder.withPort(port);
          builder.withLocalBindAddress(localBindAddress);
          builder.withBroadcast("10.116.189.127", 26);
      
          IpNetwork network = builder.build();
          LocalDevice localDevice = new LocalDevice(deviceId, new DefaultTransport(network));
          try {
              localDevice.initialize();
          } catch (Exception e) {
          	System.out.println("Unable to initialize localDevice");
              e.printStackTrace();	
          }
          
          //Get Superior conference room
          RemoteDevice rd = null;
      	try {
      		rd = localDevice.getRemoteDeviceBlocking(instance, timeout);
      	} catch (BACnetException e) {
      		// TODO Auto-generated catch block
      		System.out.println("Unable to find device: "+ instance);
      		e.printStackTrace();
      		System.exit(1);
      	}
          
          System.out.println("Vendor: " + rd.getVendorName());
          RemoteObject ro = rd.getObject(new ObjectIdentifier(19,8));
          Encodable value = ro.getProperty(PropertyIdentifier.presentValue);
          System.out.println("Device: " + rd.getInstanceNumber()+  " present value =" + value);
      
      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi ealebie,

        The current BACnet4J library does not permit you to forgo having broadcasts properly configured, it's part of the BACnet spec to have them working. If you have BBMDs involved you may need to register as a foreign device with them, In wireshark you suggest they are not being responded to, so I would wonder if you have some successful broadcast packets with which to compare. I would also wonder if binding a sink address (looks like 10.116.189.64 on your network) instead of your actual IP may help (but, not if devices aren't responding)

        Here's a thread where such a registration is performed from within Mango.
        https://forum.infiniteautomation.com/topic/3099/bacnet4j-3-2-and-bbmd-foreign-device-support

        1 Reply Last reply Reply Quote 0
        • E
          ealebie
          last edited by

          Hi Phildunlap,

          Thanks, that helped. I ran different tests. There are devices from different vendors in the Bacnet network, I realised all the other Vendor devices except the ones I was interest in, Lutron, would respond to the broadcast. But I needed to register as a foreign device for the Lutron devices to respond back, but it only resonds 50% of the time, other 50 it times out.

          This is the output I get now when it works:

          RemoteDevice(instanceNumber=1761053, address=Address [networkNumber=3004, macAddress=[0,0,0,1a,df,1d]], maxAPDULengthAccepted=1476, segmentationSupported=no-segmentation, vendorId=176, vendorName=null, name=Superior Conference Room 1761053, servicesSupported=[false, false, false, false, false, true, false, false, false, false, false, false, true, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false])

          I'm supposed to be printing out the present value for the Occupancy state Object, but the getObject returns null. looks like I'm using the right objectype and instance. Not sure what I'm doing wrong, any hints or help would be appriciated.

          Thanks!

          /Alex

          Here is the Device info from BQT:

          0_1519683602281_ecae175b-0835-42b3-b1be-332d870c4861-image.png

          	    	int instance = Integer.parseInt(args[0]);    	
          	    	int timeout = Integer.parseInt(args[1]);
          	
          	        Integer deviceId = 1234;    	
          	        int port = 0xBAC0;
          	
          		String localBindAddress = "10.116.189.90";  	
          	
          	        IpNetworkBuilder builder = new IpNetworkBuilder();    	
          	        builder.withPort(port);    	
          	        builder.withLocalBindAddress(localBindAddress);    	
          	        builder.withBroadcast("10.116.189.127", 26);
                          IpNetwork network = builder.build();  	
          
          	
          	        LocalDevice localDevice = new LocalDevice(deviceId, new DefaultTransport(network));    	
          	        
          	        try {
          	            localDevice.initialize();    	
          	            network.registerAsForeignDevice(new java.net.InetSocketAddress(localBindAddress, 0xBAC0), 60);
          	        } catch (Exception e) {    	
          	        	System.out.println("Unable to initialize localDevice");    	
          	            e.printStackTrace();	    	
          	        }    	        
          	
          	        RemoteDevice rd = null;    	    	        
          	
          		try {    	
          			rd = localDevice.getRemoteDeviceBlocking(instance, timeout);    	
          		} catch (BACnetException e) {    	
          			// TODO Auto-generated catch block    	
          			System.out.println("Unable to find device: "+ instance);    	
          			e.printStackTrace();    	
          			System.exit(1);    	
          		}    	    	        
          	
          		System.out.println("");    	
          		System.out.println(rd.toExtendedString());   	    	        
          	
          	        RemoteObject ro = rd.getObject(new ObjectIdentifier(19,8));    	
          	        if (ro != null)    	
          	        {    	
          	        	Encodable value = ro.getProperty(PropertyIdentifier.presentValue);    	
          	        	System.out.println(ro.getObjectName() +  " present value = " + value);    	
          	        }    	    	        
          	
          	        System.exit(0);
          
          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            Great!

            Hmm, I'm not sure. You could try doing a ReadPropertyRequest for the present value, instead of trying to get the whole Object.

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