79 }
80 }
81 }
82 console.log("===Report Scan Data\n topic=" + topic) 83 console.log(payloadJson)
84 return JSON.stringify(payloadJson);
85}
30client.subscribe(subTopic)
31client.on('message', function(topic, message) {
32 console.log("topic " + topic)
33 console.log("message " + message) 34})
35
36//IoT平台mqtt连接参数初始化
29const subTopic = `/${deviceConfig.productKey}/${deviceConfig.deviceName}/user/get`;
30client.subscribe(subTopic)
31client.on('message', function(topic, message) {
32 console.log("topic " + topic) 33 console.log("message " + message)
34})
35
28 let topic = msg.application_properties.topic;
29 let content =JSON.parse(Buffer.from(msg.body.content).toString().replace(/\'/g, '"'));
30 if (topic.indexOf('/user/update') !== -1) {
31 console.log("\nTopic: " + topic)32 if (content.subType === "SCAN") {
33 // 网关持续上传周围的跳绳清单和状态、配置信息
34 console.dir(content, { depth: null });
In ES2015 (ES6), we can use template literals instead of string concatenation.
var str = `Hello, ${name}!`;
var str = "Hello, " + name + "!";
var str = "Time: " + (12 * 60 * 60 * 1000);
var str = "Hello World!";
var str = `Hello, ${name}!`;
var str = `Time: ${12 * 60 * 60 * 1000}`;
var str = "Hello, " + "World!";