• 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 4 Documentation Website Mango 5 Documentation Website Radix IoT LinkedIn

    Subscribe COV problems

    Scheduled Pinned Locked Moved BACnet4J general discussion
    1 Posts 1 Posters 1.7k Views 1 Watching
    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.
    • B Offline
      bf89
      last edited by bf89

      My Program subscribes for a analogue value, after this it waits 5 seconds(I receive the COVs in this 5 Seconds), after that I want to unsubscribe, but here I get the error "b ErrorAPDU(choice=5, errorClass=Object, errorCode=covSubscriptionFailed)" also If I try to subscribe for another value, I get this error.
      What do I do wrong? I use the bacnet4j-3.2.4-API

      public class Test1 {
      static LocalDevice localDevice;
      
      public static void main(String[] args) throws Exception {
      	IpNetwork network = new IpNetworkBuilder().build();
      	Transport transport = new DefaultTransport(network);
      	localDevice = new LocalDevice(44444, transport);
      	try {
      		localDevice.initialize();
      		localDevice.getEventHandler().addListener(new Listener());
      
      		localDevice.sendGlobalBroadcast(new WhoIsRequest());
      		Thread.sleep(2 * 1000);
      		RemoteDevice device = localDevice.getRemoteDevice(2222);
      
      		UnsignedInteger subscriberProcessIdentifier = new UnsignedInteger(0);
      		UnsignedInteger lifetime = new UnsignedInteger(0);
      		ObjectIdentifier oi = new ObjectIdentifier(ObjectType.analogValue,
      				0);
      
      		SubscribeCOVRequest request = new SubscribeCOVRequest(
      				subscriberProcessIdentifier, oi, new Boolean(true),
      				lifetime);
      		localDevice.send(device, request, new ResponseConsumer() {
      			@Override
      			public void success(AcknowledgementService arg0) {
      				System.out.println("a " + arg0);
      			}
      			@Override
      			public void fail(AckAPDU arg0) {
      				System.out.println("b " + arg0);
      
      			}
      			@Override
      			public void ex(BACnetException arg0) {
      				System.out.println("c " + arg0);
      			}
      		});
      
      		Thread.sleep(5000);
      		SubscribeCOVRequest request1 = new SubscribeCOVRequest(
      				subscriberProcessIdentifier, oi, null, null);
      		localDevice.send(device, request1, new ResponseConsumer() {
      
      			@Override
      			public void success(AcknowledgementService arg0) {
      				System.out.println("a " + arg0);
      			}
      			@Override
      			public void fail(AckAPDU arg0) {
      				System.out.println("b " + arg0);
      			}
      			@Override
      			public void ex(BACnetException arg0) {
      				System.out.println("c " + arg0);
      			}
      		});
      
      		try {
      			new BufferedReader(new InputStreamReader(System.in)).readLine();
      		} catch (IOException e) {
      			e.printStackTrace();
      		}
      
      		localDevice.terminate();
      	} catch (Exception ex) {
      		ex.printStackTrace();
      	}
      }
      
      static class Listener extends DeviceEventAdapter {
      	@Override
      	public void covNotificationReceived(
      			UnsignedInteger subscriberProcessIdentifier,
      			RemoteDevice initiatingDevice,
      			ObjectIdentifier monitoredObjectIdentifier,
      			UnsignedInteger timeRemaining,
      			SequenceOf<PropertyValue> listOfValues) {
      
      		for (int i = 0; i < listOfValues.getCount(); i++) {
      			if (!(listOfValues.getValues().get(i).getValue() instanceof StatusFlags)) {
      				System.out.println("COV_Result: Instance-ID:"
      						+ monitoredObjectIdentifier.getInstanceNumber()
      						+ " Value:"
      						+ listOfValues.getValues().get(i).getValue()
      						+ " Type: "
      						+ monitoredObjectIdentifier.getObjectType()
      								.intValue());
      
      			}
      		}
      	}
      
      	@Override
      	public void iAmReceived(RemoteDevice d) {
      		System.out.println("IAm received from " + d);
      		System.out.println("Segmentation: " + d.getSegmentationSupported());
      		d.setSegmentationSupported(Segmentation.noSegmentation);
      	}
      }
       }
      

      the output of my program is;

      IAm received from RemoteDevice(instanceNumber=2222, address=Address [networkNumber=20, macAddress=[ae,8,0,0,0,0]])
      Segmentation: both
      a null
      COV_Result: Instance-ID:0 Value:2784.5 Type: 2
      COV_Result: Instance-ID:0 Value:2785.0 Type: 2
      COV_Result: Instance-ID:0 Value:2785.5 Type: 2
      COV_Result: Instance-ID:0 Value:2786.0 Type: 2
      b ErrorAPDU(choice=5, errorClass=Object, errorCode=covSubscriptionFailed)
      COV_Result: Instance-ID:0 Value:2786.5 Type: 2
      COV_Result: Instance-ID:0 Value:2787.0 Type: 2

      EDIT: The "Problem" is that my removeDevice will be overwritten as soon as I receive the first COV. I did a workarround like that:

      private RemoteDevice getRemoteDevice() {
      	return localDevice.getRemoteDeviceCreate(2222, new Address(
      			19, new OctetString(new byte[] { -82, 8, 0, 0, 0, 0 })));
      }
      

      this is executed any time when I send something to the bacnet server. How can I do that propperly?

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post