diff --git a/nodejs/routes/index.js b/nodejs/routes/index.js index 42fc622..93afd2e 100644 --- a/nodejs/routes/index.js +++ b/nodejs/routes/index.js @@ -13,17 +13,21 @@ router.get('/', function(req, res, next) { res.render('index', { title: 'Express' }); }); -router.get('/getRCs', function (req, res) { +router.get('/getRCs', function (req, res, next) { rc_db.findAll(function (error, results, fields) { - if(error) console.log(error); - //rc.send(results[0].on_value); + if(error){ console.log(error); return(next); } res.json(results); }); }); +router.post('/register', function (req, res, next){ + rc.send(req.body.code); + res.send(req.body); +}); + router.get('/irTest', function (req, res) { - //arduino.write(new Buffer('X0' + String.fromCharCode(4) + String.fromCharCode(12) + String.fromCharCode(0)+String.fromCharCode(0)+String.fromCharCode(2689 / 256) + String.fromCharCode(2689 % 256),'ascii')); + arduino.write(new Buffer('X0' + String.fromCharCode(4) + String.fromCharCode(12) + String.fromCharCode(0)+String.fromCharCode(0)+String.fromCharCode(2689 / 256) + String.fromCharCode(2689 % 256),'ascii')); arduino.write(new Buffer('Uo000000'), 'ascii'); arduino.write(new Buffer('Up000000'), 'ascii'); res.send('switch light');