0.0.2 • Published 6 years ago

aliyun-iot-server-sdk v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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));
});

Bugs