沈斌
2017-01-06 92b327d79a3d774e9aa6949b0a5981c89e10c491
环境数硬件接口修改 - 通过版本号来判断终端传感器数据的协议格式
2 files modified
22 ■■■■ changed files
method.js 4 ●●●● patch | view | raw | blame | history
test.js 18 ●●●●● patch | view | raw | blame | history
method.js
@@ -131,6 +131,10 @@
    mac = mac.toLowerCase();
    this.updateDeviceLastUpdated(db, mac, function(data) {});
    //通过版本号来判断传感器数据的协议格式
    //var ver = this.toDec(fields[18]) * 256 + this.toDec(fields[19]); //版本号
    var x1  = this.toDec(fields[20]) * 256 + this.toDec(fields[21]); //PM2.5数据
    var x2  = this.toDec(fields[22]) * 256 + this.toDec(fields[23]); //PM10
    var x3  = this.toDec(fields[24]) * 256 + this.toDec(fields[25]); //0.1升0.3um量
test.js
@@ -243,9 +243,15 @@
// var data = "5a0000010003accf23d4515f00000000000000000030003e198c00110814050300060034001400000004001f000301040200000000000000000003490056048c1f02000000000000000000000000003c5b";
// console.log(data.length);
var moment = require('moment');
var a = {
    data: {a:1, b:2},
    time: moment().format('YYYY-MM-DD HH:mm:ss')
};
console.log(JSON.stringify(a));
// var moment = require('moment');
// var a = {
//     data: {a:1, b:2},
//     time: moment().format('YYYY-MM-DD HH:mm:ss')
// };
// console.log(JSON.stringify(a));
var a = 999;
var b = parseInt(a / 256);
var c = a % 256;
console.log(b + " | " + c);
console.log("0" + b)