add backend functionality

This commit is contained in:
Shannon Sterz 2016-02-18 17:42:34 +01:00
parent 88b56d6056
commit ff135aa3e0

View file

@ -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');