Commit 0df933eb by Chavee Issariyapat

update

parent fc675c76
......@@ -26,13 +26,17 @@ const Coordinator = function(param={}) {
jsonpayload = JSON.parse(payload.toString());
}
catch(e) {}
that.localserver.publish(`${jsonpayload.deviceid}/devicestatus`, payload.toString());
});
if (topic == '@shadow/data/updated') {
that.localserver.publish(`${jsonpayload.deviceid}/shadow`, payload.toString());
}
else if (topic.startsWith('@device/status/changed')){
that.localserver.publish(`${jsonpayload.deviceid}/device`, payload.toString());
}
});
}
Coordinator.prototype = new events.EventEmitter;
Coordinator.prototype.start = function() {
this.remoteclient.connect();
this.localserver.start();
......
......@@ -45,9 +45,7 @@ MQTTServer.prototype.start = function() {
});
}
MQTTServer.prototype.publish = function(topic, payload) {
let msgobj = {
topic : topic,
payload : payload,
......@@ -56,8 +54,7 @@ MQTTServer.prototype.publish = function(topic, payload) {
}
this.mqttserver.publish(msgobj, function(){
console.log({topic, payload})
//console.log({topic, payload})
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment