update for db testin

This commit is contained in:
Shannon Sterz 2016-02-17 14:14:04 +01:00
parent 21513c81f2
commit 43ea1e9eb1

View file

@ -1,7 +1,10 @@
var express = require('express'); var express = require('express');
var router = express.Router(); var router = express.Router();
var Arduino = new require('../ar-com/arduino'); var arcom = new require('../ar-com');
var arduino = new Arduino(); 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(); arduino.setup();
@ -11,10 +14,15 @@ router.get('/', function(req, res, next) {
}); });
router.get('/toggleLight', function (req, res) { router.get('/toggleLight', function (req, res) {
var s = "0FFF0FFF000F"; /*var s = "0FFF0FFF000F";
var str = ""; var str = "";
for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); } for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); }
arduino.write(new Buffer('Wl' + str,'ascii')); 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);
});
res.send('switch light'); res.send('switch light');
}); });