From 79d8b4e1d0aee64ee326e619544e913cf5546c78 Mon Sep 17 00:00:00 2001 From: Stefan Sterz Date: Wed, 17 Feb 2016 14:39:03 +0100 Subject: [PATCH] fix typos and minor bugs --- nodejs/ar-com/rc.js | 4 ++-- nodejs/routes/index.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nodejs/ar-com/rc.js b/nodejs/ar-com/rc.js index af2e486..e4a29b3 100644 --- a/nodejs/ar-com/rc.js +++ b/nodejs/ar-com/rc.js @@ -9,8 +9,8 @@ var RC = function (arduino, pin) { RC.prototype.send = function(tristate) { var str = ''; - for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(tristate.substr(i,2), 16)); } - arduino.write(new Buffer('W' + String.fromCharCode(97 + this.pin) + str,'ascii')); + for(i = 0; i < tristate.length; i+=2) { str += String.fromCharCode(parseInt(tristate.substr(i,2), 16)); } + this.arduino.write(new Buffer('W' + String.fromCharCode(97 + this.pin) + str,'ascii')); } RC.prototype.sendDecimal = function (len, val) { diff --git a/nodejs/routes/index.js b/nodejs/routes/index.js index 8f9dd14..464bd03 100644 --- a/nodejs/routes/index.js +++ b/nodejs/routes/index.js @@ -19,9 +19,9 @@ router.get('/toggleLight', function (req, res) { for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); } arduino.write(new Buffer('Wl' + str,'ascii')); res.send('switch light');*/ - - rc_db.fidn(1, function (error, results, fields) { - rc.send(results[0].on_value); + rc_db.find(1, function (error, results, fields) { + if(error) console.log(error); + rc.send(results[0].on_value); }); res.send('switch light'); });