Skip to content

EnvisionIot/enos-integration-sdk-java

Repository files navigation

Using EnOS Integration SDK For Java

Installation

Prerequisites

Installing Java JDK SE

Java SE 8 is required to use the SDK and run the samples.

Optional: Installing Maven

The Java SDK is maven-based. If you use Maven 3, you just need to add the dependency upon the Java SDK to the main pom.xml file of your project, saving the efforts to download and build from source code.

For instructions on downloading and installing Maven 3, see here.

Installing EnOS Integration SDK for Java

Select one of the following ways to install the Java SDK:

  • If your project is maven-based, add the dependency on the Java SDK to the main pom.xml of your project.

  • Download the source code and build on your machine.

Adding the Maven Dependency to Your Project

This is the recommended method to use EnOS Integration SDK in your project. Your project has to be a Maven project and you have installed Maven on your machine.

  1. Go to http://search.maven.org. Search for com.envisioniot enos-http-integration and find the version number for the SDK that you want to use.

  2. In your main pom.xml file, add the dependency on the SDK of your desired version by inserting the following code snippet:

    <dependency>
        <groupId>com.envisioniot</groupId>
        <artifactId>enos-http-integration</artifactId>
        <version>0.1.3</version>
        <!--This is latest current version number when this document is being written. Yours may vary.-->
    </dependency>

Building From the Source Code

  1. Download the source code of EnOS Integration SDK for Java from the master branch of the GitHub repository: https://github.com/EnvisionIot/enos-integration-sdk-java

    If you use the command-line interface, the command for download is as follows:

    git clone https://github.com/EnvisionIot/enos-integration-sdk-java.git
  2. Build the SDK from source code using the following command in your command-line interface:

    mvn install

The compiled JAR file with all dependencies bundled can then be found in the following file:

{Integration SDK for Java root}/target/enos-http-integration-{version}.jar

If you want to use the integration SDK in your own project, include this JAR file and any JAR files that the integration SDK depends on in your project.

Feature List

This integration SDK provides:

  • Upload measurement points

  • Upload attributes

  • Upload events

File-type measurement points, attributes and events are supported. This SDK also provides: - Download file - Delete file

Quick Start

  1. Create an HTTP connection and specify the connection parameters.

    // INTEGRATION_CHANNEL_URL is the URL of EnOS HTTP Integration Channel URL and API_GW_URL is the URL of API Gateway,
    // which can be obtained in the Environment Information page in EnOS Console
    // The APP_KEY, APP_SECRET and ORG_ID can be obtain in Application Registration page in EnOS Console
    HttpConnection connection = new HttpConnection.Builder(
            INTEGRATION_CHANNEL_URL, API_GW_URL, APP_KEY, APP_SECRET, ORG_ID)
            .build();
  2. Upload measurement points via the HTTP connection.

    // Build a request to post a measurement point
    // IntMeasurePoint and FileMeasurePoint is a measurement point defined in EnOS console > Model.
    DeviceInfo deviceInfo = new DeviceInfo().setAssetId(ASSET_ID1);
    IntegrationMeasurepointPostRequest request = IntegrationMeasurepointPostRequest.builder()
            .addMeasurepoint(deviceInfo, System.currentTimeMillis(), ImmutableMap.of("IntMeasurePoint", 100, "FileMeasurePoint", new File("sample.txt")))
            .build();
    // Publish the request synchronously with progress listener if provided
    IntegrationResponse response = connection.publish(request, progressListener);

API Reference

Under development

Release Notes

  • 2020/03/15 (Initial Release): Providing Integration APIs, File APIs

  • 2020/04/15 (0.1.1): Support OTA file download

  • 2020/12/08 (0.1.2): Support file upload/download via EnOS LARK

  • 2020/06/29 (0.1.3): Support file download by range and offline integration

About

A Java SDK for integrating device data into EnOS Cloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages