From a5fa0c2f86c64b271ddbeae7758bc27d2920dcf9 Mon Sep 17 00:00:00 2001 From: 沈斌 <bluelazysb@hotmail.com> Date: Thu, 15 Dec 2016 12:49:59 +0800 Subject: [PATCH] 推送传感器数据到大屏 --- method.js | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/method.js b/method.js index c53e226..4a95bb5 100644 --- a/method.js +++ b/method.js @@ -4,6 +4,7 @@ var moment = require('moment'); var config = require('./config'); +var queue = require('./queue'); module.exports.toDec = function(hex) { if(typeof hex === 'number') { @@ -93,7 +94,7 @@ this.updateDeviceLastUpdated(db, mac, function(data) {}); db.collection("devices").find({ mac: mac }).limit(1).next(function(err, doc){ - if (err) return; + if (err || doc == null) return; callback(doc); }); }; @@ -166,6 +167,22 @@ var ddv = this.toDec(fields[62]) * 256 + this.toDec(fields[63]); var mcu = this.toDec(fields[64]) + this.toDec(fields[65]) / 100; + queue.pushToScreen({ + mac: mac, + location: { + lat: 31.430616, + lng: 120.988327 + }, + data: { + x1: x1, //PM2.5 + x2: x9, //������ + x3: x11, //������ + x4: x10, //������ + x5: x14, //������������ + x6: x12 //������ + } + }); + var current = moment(); var rank = 0; -- Gitblit v1.8.0