• 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

    BACnet4J for Android

    BACnet4J general discussion
    3
    8
    6.3k
    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.
    • P
      pete
      last edited by

      Hi all

      Is it possible to run a BACnet client using BACnet4J on an Android device?

      BR

      1 Reply Last reply Reply Quote 1
      • M
        mjung85
        last edited by

        Hi,

        i just ported BACnet4J to Android. Just take the source code and include it in your Android project.

        There are nearly no changes required (remove apache logging, some minimal changes due to different method signatures of some classes, ...).

        A nasty thing is the dependency to the seroUtils.jar. I was able to reconstruct the src by using a older src zip found in this forum and a Java decompiler. Throwing away the not required parts of the lib for
        BACnet4J you get a working version on Android.

        I use it for a client application accessing a field device using the open-source BACnet C stack, so far it works well.

        Maybe I provide it as open-source project too, but first I need to check if this allowed by the license (seroUtils dependency ...).

        BR
        Markus

        1 Reply Last reply Reply Quote 0
        • P
          pete
          last edited by

          Hi

          Thank you very much!
          Where can I download your ported code? In HEAD of the repo I did not notice a change.

          I also did some tests with the existing code and was able to run it with the original seroUtils.jar included. My main problem was the bind address of the code and I changed
          IpMessageControl.IpMessageControl():175 from
          socket = new DatagramSocket(port, InetAddress.getByName(localBindAddress));
          to
          socket = new DatagramSocket(port);

          BR
          Pete

          1 Reply Last reply Reply Quote 0
          • M
            mjung85
            last edited by

            Hi,

            sorry, maybe it was a little bit misleading. I'm not a commiter nor a contributer.

            I tried it also with the "native" .jar libraries and I think it should work with them also.

            There is also one problem remaining if you use this approach:

            I/dalvikvm(20033): Could not find method java.lang.String.<init>, referenced from method com.serotonin.util.queue.ByteQueue.popString
            W/dalvikvm(20033): VFY: unable to resolve direct method 5449: Ljava/lang/String;.<init> ([BLjava/nio/charset/Charset;)V
            D/dalvikvm(20033): VFY: replacing opcode 0x70 at 0x0007
            D/dalvikvm(20033): VFY: dead code 0x000a-000a in Lcom/serotonin/util/queue/ByteQueue;.popString (ILjava/nio/charset/Charset;)Ljava/lang/String;

            There is a String created using a Charset as argument and in Android this signature is not available, instead the Charset ISO name has to be passed as String instead as a Charset instead. So the change is really trivial, if you have the source code.

            Although it worked with the native libs, but I'm not sure if there aren't any side effects.

            What was your problem with the bind address?

            I just use something like this:

            private LocalDevice device = new LocalDevice(3456, "0.0.0.0");

            device.getEventHandler().addListener(this);
            Log.i(TAG,"Device created");
            try {
            device.initialize();
            } catch (IOException e) {
            e.printStackTrace();
            return;
            }

            ...

            device.setBroadcastAddress(ipstr);
            try {

            Log.i(TAG, "Sending broadcast.");
            device.sendBroadcast(whoHasRequest);
            // d.sendBroadcast(whois);
            

            } catch (BACnetException e) {
            System.out.println("Exception at " + ipstr);
            e.printStackTrace();
            }

            Seems to work without problems.

            If you like to I can send you my ported code in a zip file by E-mail. It includes the complete Bacnet4J stack and the reverse engineered seroUtils part, but since it is closed I don't want to make it public.

            BR

            1 Reply Last reply Reply Quote 0
            • P
              pete
              last edited by

              Hi

              I send you a private message. Did you not get that?
              Yes, it would be great if you could send me the code. The best would be to send the changed files also separately in order for me to replace only them inside my environment.
              With the bind address 0.0.0.0 I have the problem that the external device does not answer to the WhoIs. After my change, this worked fine.. I don't know the exact reason for that.

              Do you know more regarding the license?

              BR

              1 Reply Last reply Reply Quote 0
              • G
                gkrananth
                last edited by

                anybody can successfully developed bacnet client for android. Please post here if anyone succeeded

                1 Reply Last reply Reply Quote 0
                • P
                  pete
                  last edited by

                  Would it be useful to publish the prototype for Android somewhere together with BACnet4J?

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