enos-mqtt-sdk-nodejs
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

  1. Establishing connection with EnOS Cloud
const {DeviceClient, SECURE_MODE} = require('enos-mqtt-sdk-nodejs');
 
// create client instance
const clientOptions = {
  brokerUrl: 'brokerUrl',
  secureMode: SECURE_MODE.VIA_DEVICE_SECRET,
  productKey: 'productKey', deviceKey: 'deviceKey', deviceSecret: 'deviceSecret'
}
const client = new DeviceClient(clientOptions);
 
// listen to 'connect' event
client.on('connect', () => {
  console.log('connected');
})
 
// listen to 'close' event
client.on('close', () => {
  console.log('connection closed');
})
 
// establish connection
client.connect().then(async() => {
  // interact with the cloud
});
  1. Reporting measurement points
const mpResponse = await client.deviceData.postMeasurepoint({
  point: {
    measurepoints: {
      mp_age: 20
    }
  }
});
console.log(mpResponse.data);
  1. Closing the connection
client.close();

Sample Code

Related Information

API Reference

See api reference

Release Notes

  • 2020/01/15 (Initial Release)

Readme

Keywords

none

Package Sidebar

Install

npm i enos-mqtt-sdk-nodejs

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

24 kB

Total Files

10

Last publish

Collaborators

  • envision-tc