From 31ba1ebb94ab0ed3fe369670405172d00095b112 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Fri, 12 Feb 2016 16:28:31 +0000 Subject: [PATCH] modified to use events, hopefully will fix the crashing particle --- routes/temp.js | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/routes/temp.js b/routes/temp.js index 594ba04..e936229 100644 --- a/routes/temp.js +++ b/routes/temp.js @@ -130,37 +130,21 @@ router.post('/', function (req, res, next) { //t = JSON.parse(t); if(t.hasOwnProperty('data')){ logger.debug('We have data'); - var data = t.data; - var s = data.toString(); - logger.debug(typeof s); - logger.debug(s); - /*dataJSON = JSON.parse(s); - logger.debug(typeof dataJSON);*/ - /* if (data.hasOwnProperty(temp)) { + var data = JSON.parse(t.data.toString()); + + if (data.hasOwnProperty(temp)) { logger.log('We have temp! ' + data.temp); - }*/ - - //dataJSON = JSON.parse(data); - //logger.debug(dataJSON); - - /* var data = t.data; - dataJSON = JSON.parse(data); - if(dataJSON.hasOwnProperty('temp')) { - + busEmitter.emit("saveTempData", {time: now.toJSON(), value: parseFloat(data.temp)}); } else { logger.error('No temp data!'); - }*/ + } } else { logger.error('No data block!'); } - /*console.log(JSON.stringify(t)); - if (dataJSON != {} && dataJSON.temp != null) { - busEmitter.emit("saveTempData", {time: now.toJSON(), value: parseFloat(dataJSON.temp)}); - }*/ res.writeHead(200, {"ContentType": "text/html"}); res.end('ok');