0.0.3 • Published 3 years ago
iot-device-mqtt-sdk v0.0.3
iot-mqtt-sdk
Installation
You can install it as dependency with npm.
$ # save into package.json dependencies with -S
$ npm install iot-mqtt-sdk -SAliyun
Aliyun IoT Hub mqtt client with authrozied by productKey & deviceName & deviceSecret & host.
const Mqtt = require('iot-device-mqtt-sdk');
const client = Mqtt.getIoTClient({
productKey: "",
deviceName: "",
deviceSecret: "",
host: "",
});
client.on('connect', function() {
console.log("connect")
})
client.end(function (){
console.log("end")
})Huawei Cloud
Huawei Cloud IoT Hub mqtt client with authrozied by deviceName & deviceSecret & host.
const Mqtt = require('iot-device-mqtt-sdk');
const client = Mqtt.getIoTClient({
deviceName: "",
deviceSecret: "",
host: "",
});
client.on('connect', function() {
console.log("connect")
})
client.end(function (){
console.log("end")
})Tencent Cloud
Tencent Cloud IoT Hub mqtt client with authrozied by productKey & deviceName & deviceSecret & host.
const Mqtt = require('iot-device-mqtt-sdk');
const client = Mqtt.getIoTClient({
productKey: "",
deviceName: "",
deviceSecret: "",
host: "",
});
client.on('connect', function() {
console.log("connect")
})
client.end(function (){
console.log("end")
})OneNET
OneNET IoT Hub mqtt client with authrozied by productKey & deviceName & deviceSecret & host.
const Mqtt = require('iot-device-mqtt-sdk');
const client = Mqtt.getIoTClient({
productKey: "",
deviceName: "",
deviceSecret: "",
host: "",
});
client.on('connect', function() {
console.log("connect")
})
client.end(function (){
console.log("end")
})CTWing
CTWing IoT Hub mqtt client with authrozied by deviceName & deviceSecret & host.
const Mqtt = require('iot-device-mqtt-sdk');
const client = Mqtt.getIoTClient({
deviceName: "",
deviceSecret: "",
host: "",
});
client.on('connect', function() {
console.log("connect")
})
client.end(function (){
console.log("end")
})Subscribe Topic
client.subscribe(topic)Publish Message
client.publish(topic, 'Hello mqtt')
client.publish(topic, 'Hello mqtt', { qos: 1 })Receive Message
client.on('message', function(topic, message) {
console.log(topic+"," + message.toString())
})