Using EnOS Device SDK for MQTT
Table of Contents
Prerequisites
Installing Node
To use the EnOS Device SDK for NodeJS, you will need to install Node.js 8 or later.
Obtaining the SDK
npm is a command-line package manager that is installed with Node.js is installed, and will be used to obtain the SDK.
$ npm install --save enos-mqtt-sdk-nodejs
Feature List
For the list of features supported by this SDK and the availability of EnOS device connectivity and management features in all SDKs we provide, see EnOS Device SDK.
Quick Start
- Establishing connection with EnOS Cloud
const DeviceClient SECURE_MODE = ; // create client instanceconst clientOptions = brokerUrl: 'brokerUrl' secureMode: SECURE_MODEVIA_DEVICE_SECRET productKey: 'productKey' deviceKey: 'deviceKey' deviceSecret: 'deviceSecret'const client = clientOptions; // listen to 'connect' eventclient // listen to 'close' eventclient // establish connectionclient;
- Reporting measurement points
const mpResponse = await clientdeviceData;console;
- Closing the connection
client;
Sample Code
- Establishing Connection with EnOS Cloud
- Device Tags
- Device Attributes
- Reporting Measurement Points
- Reporting Events
- Receiving Commands from Cloud
- Passing Through Device Information or Receving Passed-through Information from Cloud
- Managing Sub-devices
Related Information
- To learn more about EnOS IoT Hub, see EnOS IoT Hub Documentation.
API Reference
See api reference
Release Notes
- 2020/01/15 (Initial Release)