aliyun-iot-server-sdk
v0.0.2
Published
阿里云IoT物联网套件服务端API
Downloads
6
Maintainers
Readme
aliyun-iot-server-sdk
Aliyun IoT Hub Server API sdk for Node.js
Installation
You can install it as dependency with npm.
$ # save into package.json dependencies with -S
$ npm install aliyun-iot-server-sdk -S
Usage
Aliyun IoT Hub server api sdk
iot server Api
'use strict';
var iotClient = require('aliyun-iot-server-sdk');
const co = require('co');
var options = {
accessKey: '',
accessKeySecret: '',
};
var client = iotClient.getIotServerClient(options);
co(function*() {
// pub Message
var params = {
ProductKey: "ProductKey",
TopicFullName: "topic",
MessageContent: new Buffer('{"data":12345}').toString('base64'),
Qos: "1"
};
var data = yield client.pub(params);
console.log(JSON.stringify(data));
// createProduct
params = {
Name: "productName",
Desc: "this is a new product"
}
data = yield client.createProduct(params);
console.log(JSON.stringify(data));
});