var express = require('express'); var router = express.Router(); var arcom = new require('../ar-com'); var RCDB = new require('../models/rc_db'); var rc_db = new RCDB(); var arduino = new arcom.Arduino(); var rc = new arcom.RC(arduino); arduino.setup(); /* GET home page. */ router.get('/', function(req, res, next) { res.render('index', { title: 'Express' }); }); router.get('/getRCs', function (req, res) { rc_db.findAll(function (error, results, fields) { if(error) console.log(error); //rc.send(results[0].on_value); res.json(results); }); }); 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('Uo000000'), 'ascii'); arduino.write(new Buffer('Up000000'), 'ascii'); res.send('switch light'); }); module.exports = router;