Skip to content

Client libraries and samples for connecting to IBM Watson IoT using Java

License

Notifications You must be signed in to change notification settings

zhenwan/iot-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Client Library - Introduction

Use the Java Client Library to simplify interactions with [IBM Watson IoT Platform] (https://internetofthings.ibmcloud.com).

The following documentation is provided to help you to get started:

  • The Device section contains information on how devices publish events and handle commands using the Java ibmiotf Client Library.
  • The Managed Device section contains information on how devices can connect to the Watson IoT Platform Device Management service using Java ibmiotf Client Library and perform device management operations like firmware update, location update, and diagnostics update.
  • The Gateway section contains information on how gateways publish events and handle commands for itself and for the attached devices using the Java ibmiotf Client Library.
  • The Gateway Management section contains information on how to connect the gateway as Managed Gateway to IBM Watson IoT Platform and manage the attached devices.
  • The Application section details how applications can use the Java ibmiotf Client Library to interact with devices.
  • The API section contains information on how applications can use the Java ibmiotf Client Library to interact with the organization in the Watson IoT Platform through REST APIs

The Java Client Library requires either of the following versions of Java:


Supported Features

Feature Supported? Description
Device connectivity Connect your device(s) to Watson IoT Platform with ease using this library. Click here for detailed information on how devices can publish events and handle commands.
Gateway connectivity Connect your gateway(s) to Watson IoT Platform with ease using this library. Click here for detailed information on how gateways can publish events and handle commands for itself and for the attached devices.
Application connectivity Connect your application(s) to Watson IoT Platform with ease using this library. Click here for detailed information on how applications can subscribe to device events and publish commands to devices.
Watson IoT API Shows how applications can use this library to interact with the Watson IoT Platform through REST APIs. Click here for more information.
SSL/TLS support By default, this library connects your devices, gateways and applications securely to Watson IoT Platform registered service. Ports 8883(default one) and 443 support secure connections using TLS with the MQTT and HTTP protocol. Developers can use the port setting to change the port number to 443 incase port 8883 is blocked. Also, use the WebSocket setting in order to connect your device/gateway/application over WebSockets.
Also, note that the library uses port 1883(unsecured) to connect to the Quickstart service.
Client side Certificate based authentication Client side Certificate based authentication not supported now and will be added soon.
Device Management Connects your device/gateway as managed device/gateway to Watson IoT Platform.
1. Click here for more information on how to perform device management operations like firmware update, reboot, location update and diagnostics update for a device.
2. Click here for more information about managing the devices behind gateway.
3. Click here for information about how to initiate a DM operation from the application.
Device Management Extension(DME) Provides support for custom device management actions.
1. Click here for more information about DME support for a Device.
2. Click here to know how to create and initiate a DME request from the application.
Scalable Application Provides support for load balancing for applications. Click here for more information about how to enable scalable application support using this library.
Auto reconnect Enables device/gateway/application to automatically reconnect to Watson IoT Platform while they are in a disconnected state. To enable this feature, set Automatic-Reconnect option to true.
Websocket Enables device/gateway/application to connect to Watson IoT Platform using WebSockets. To enable this feature, set WebSocket option to true.
Event/Command publish using MQTT Enables device/gateway/application to publish messages using MQTT. Refer to Device, Gateway and Application section for more information.
Event/Command publish using HTTP Enables device/gateway/application to publish messages using HTTP. Refer to Device, Gateway and Application section for more information.

Migration from release 0.1.5 to 0.2.1

Starting from release 0.2.1, the library doesn't add parent JSON Element "d" in front of the actual event that is published, as outlined in the following example:

{"temp":56,"hum":70}

If you need to revert back to the previous behavior, run the application with the property com.ibm.iotf.enableCustomFormat set to false as follows:

java -Dcom.ibm.iotf.enableCustomFormat=false <...>

This will publish the message in old format as follows:

{"d":{"temp":56,"hum":70}}

Maven support

The library artifact is pushed to the maven. Use the following maven dependency to include this library in your Java application.

<dependency>
    <groupId>com.ibm.messaging</groupId>
    <artifactId>watson-iot</artifactId>
    <version>0.2.4</version>
</dependency>

However, if you want to build the library by yourself, use the following maven command:

mvn clean package -Dmaven.test.skip=true

The above command quickly builds the library by skipping the test and the target directory contains the output jar files. However, if you also want to run the tests, modify the property files that are in the directory src/test/resources, and then run the following maven command:

mvn clean package

Download

Refer to the maven secion for how to use this library in your project. Also, you can download the library manually from the maven repository.

When you use maven, the dependencies are downloaded automatically.


Samples

You can find samples in each of the corresponding repositories as follows:

  • Device samples - Repository contains all device (also device management) related samples in different programming languages. Information and instructions regarding the use of these samples can be found in their respective directories.
  • Gateway Samples - Repository contains all Gateway (also gateway management) related samples in different programming languages.
  • Application samples - Repository contains samples for developing the application(s) in IBM Watson Internet of Things Platform in different languages.
  • Watson IoT Platform API V002 samples - Repository contains samples that interacts with IBM Watson IoT Platform using the platform API Version 2.
  • Scalable Application samples - Repository contains sample(s) for building scalable applications, using shared subscription support in IBM Watson IoT Platform.
  • Backup-restore sample - The sample in the repository shows how to backup the device configuration in Cloudant NoSQL DB and restore the same later.

Dependencies


License

The library is shipped with Eclipse Public License. For more information about the public licensing, see the License file.

About

Client libraries and samples for connecting to IBM Watson IoT using Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%