Discover devices using ADDP

You may need to use the Digi-proprietary protocol ADDP (Advanced Device Discovery Protocol) to discover your WVA to determine its IP address. Android applications can also use ADDP to discover WVA devices on your network. This section explains how to use Digi’s ADDP library to perform discoveries.

Using ADDP from your computer

  1. Using ADDP requires a Java JDK to be installed on your computer. This Java JDK should have already been installed if you are using this tutorial, since Android Studio requires Java to be installed. Make sure your JDK was to your computer's PATH by opening a command prompt and entering the following:
    java -version
  2. Download the ADDP library .jar file, using this direct link: download ADDP JAR file.
  3. Optional: Rename the ADDP library .jar file to AddpLibrary.jar for convenience. While this step is optional, the rest of the steps in this procedure refer to the file by this name.
  4. From a command prompt (Windows) or terminal (Linux/OS X), run the following command, which performs an ADDP discovery.
    java -jar AddpLibrary.jar

    Discovered devices are listed in a table, such as the one below:

          MAC Address |        IP Address |                      Hardware
    ======================================================================
    00:40:9D:5C:11:12 |       192.168.1.2 |  Wireless Vehicle Bus Adapter
    
    Search complete. 1 device(s) found.
  5. For more verbose output, which displays all information for each device, add the -v argument:
    java -jar AddpLibrary.jar -v

Using ADDP from an Android application

Digi’s ADDP library is packaged for distribution via JCenter like the WVA Android library. To include the library as a dependency for your application, add the following line to the dependencies section of your build.gradle file:

compile "com.digi.addp:addplib:1.0"

To perform a discovery, first instantiate an AddpClient object, and then call searchForDevicesAsync. See the following code snippet:

AddpClient client = new AddpClient();
client.searchForDevicesAsync(new DeviceFoundListener() {
    @Override
    public void onFound(String mac, AddpDevice device) {
        // Handle discovered device
    }

    @Override
    public void onSearchComplete() {
        // Handle completed search.
    }
});

Using this example, you might populate a ListView with a representation of each discovered device. If you plan to do this, be aware that this listener is invoked from a background thread. To change anything in your application’s UI, you must pass the discovery information to the UI thread in some way.

For more information on this library’s operations, see the Javadoc, available from the WVA Documentation page.

 

© 2017 Digi International Inc. All rights reserved.
Discover devices using ADDP updated on 10 Oct 2017 08:29 AM