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.
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.
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.
-
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.
-
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>
-
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
-
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.
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
-
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();
-
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);
-
To learn more about EnOS IoT Hub, see EnOS IoT Hub Documentation.
-
To learn more about how to develop integration for EnOS IoT Hub, see EnOS Integration.