Getting Started with EnOS SDKs

EnOS provides SDKs to support device connection, asset management, reading stored data, for easy offline application development. This article aims to help you learn how to obtain EnOS SDKs, prepare the development environment, and use EnOS SDKs through the example of API Core SDK (Poseidon).

Before You Start

Ensure you have resources on EnOS that you are authorized to access. The resources can be devices, data, events, user accounts, and so on. So before you start using EnOS APIs, you typically have finished connecting your devices and data into EnOS, and have a user account that has proper access policies assigned through EnOS IAM function.

To use EnOS SDKs, a service account (accessKey and secretKey) is required. The service account is generated by registering an application in the EnOS Console. Before calling an API that requires Write access, ensure that your SA account has the required authority. For more information, see Managing Service Accounts.

Installing EnOS SDKs

The system environment requirements for EnOS SDKs are as follows:

  • For Java, install Java JDK SE 8 and Maven 3 (recommended).
  • For Python, intall Python 2.7.10 or above version, and pip is required.
  • For C, install CMake (downloading CMake from https://cmake.org/).

You can obtain the EnOS SDKs through the following methods:

  • For Java, include the project as a dependency in your Maven project.
  • For Python, install SDKs through PIP.
  • Download the source code by cloning the GitHub repository and build on your machine.

From Maven (as a dependency)

This is the recommended method of including the EnOS Java SDKs in your project.
  1. Navigate to http://search.maven.org, search for com.envisioniot.enos and take note of the latest version number (or the version number of whichever version of the sdk you want to use).

  2. In your main pom.xml file, add the SDK for Java as a dependency (take the EnOS API Core SDK for Java as example):

    <dependency>
      <groupId>com.envisioniot</groupId>
      <artifactId>apim-poseidon</artifactId>
      <version>0.1.7</version>
    </dependency>
    

Install from PIP

Use the following command to install EnOS SDKs for Python (take the EnOS API Core SDK for Python as example):

pip install aphrodite

Building from Source Code

Get a copy of the SDKs from the master branch of the corresponding GitHub repository (take the EnOS Device SDK for MQTT as example):

git clone https://github.com/EnvisionIot/enos-mqtt-sdk-java.git

After you have obtained a copy of the source, you can install the SDK.

Example

The following sample code is for calling the GetAsset API (getting asset information with assetId) with EnOS API Core SDK (Poseidon):

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;

public class demo {
    public static void main(String[] args) {

        String appKey = "accessKey";
        String appSecret = "secretKey";

        String response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret))
                .url("https://apigw-address/asset-service/v2.0/assets?orgId=orgId&assetId=assetId")
                .method("GET")
                .sync();
        System.out.println(response);
        }
    }