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

miketran78727/iot-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Client Library - Introduction

This repository contains 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 Data management sectioncontains information on how applications can use the Java ibmiotf Client Library to interact with the organization in the Watson IoT Platform Data management APIs

How to use the Watson IoT Client Library for Java

The client library can be used by both Application Developers, as well as, Device Developers.

Setup your development environment

This section explains how to set up your development environment to use the Watson IoT Platform Client Library for Java and needs

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.6</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

Development using Eclipse


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 Support for Client side Certificate based authentication is provided by Watson IoT Platform. For information about how to configure certificates, see Configuring certificates.
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.
Data management help you to simplify your applications by decoupling them from the complexities of how specific devices are connected. Refer to Data management 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}}

Key additions to v0.2.5

Version 0.2.5 of the Watson IoT Java Client Library extends the authentication mechanism by adding support for Client side Certificate based authentication. The enhanced security policies enable organizations to determine how they want devices to connect to and be authenticated to the platform. The extended security options that are available to an organization depend on the plan type. Lite, Standard or Advanced Security Plan (ASP) types are available.

Network failure tests that help ascertain network disconnectivity between the Client and the Server while data events are in transit, have been added to the test suite. Leverage the existing setup to build on top of it, various network failure simulations, that suit the needs of your environment. Further documentation on how one can simulate the conditions are mentioned here.


Key additions to v0.2.6

Version 0.2.6 of the Watson IoT Java Client Library adds on Data management capabilities. Imagine you have many different types, makes, or models of device that you want to connect, and these devices publish data in differing formats. As a developer you would probably prefer to work with these devices using a simple, common RESTful interface. Well now you can! You can use the powerful mapping features of Data management to normalize incoming data into a consistent form ready for use in application, dashboards and analytics.


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.
  • Data management sample - The sample in the repository creates all the artifacts needed for getting a working Data Management sample that converts values from Fahrenhiet to Celcius.

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%