From e1d0eac6a5d726cce8b040cb27bf27431c5cf0a9 Mon Sep 17 00:00:00 2001 From: Lukas Bachschwell Date: Mon, 7 Mar 2016 21:48:50 +0100 Subject: [PATCH] First poc --- board.html | 114 +++++++++++---------------------------------- requestHandlers.js | 2 +- server.js | 17 ++++--- 3 files changed, 36 insertions(+), 97 deletions(-) diff --git a/board.html b/board.html index 79e1a4b..8dda5cd 100644 --- a/board.html +++ b/board.html @@ -1,4 +1,5 @@ - + + @@ -29,21 +30,10 @@ text-align:center; } - +
-

Data from Arduino

- +

Data from Sim900

+ + + + + +
UhrzeitNachricht
+
-

Data to Arduino

+

Debug functions

diff --git a/requestHandlers.js b/requestHandlers.js index a6cd7fe..03299c7 100644 --- a/requestHandlers.js +++ b/requestHandlers.js @@ -8,7 +8,7 @@ server = require('./server'); function sendInterface(response) { console.log("Request handler 'interface' was called."); response.writeHead(200, {"Content-Type": "text/html"}); - var html = fs.readFileSync(__dirname + "board.html") + var html = fs.readFileSync(__dirname + "/board.html") response.end(html); } diff --git a/server.js b/server.js index 03163dd..b5bd682 100644 --- a/server.js +++ b/server.js @@ -44,15 +44,11 @@ function initSocketIO(httpServer,debug) socketServer.on('update', function(data) { socket.emit('updateData',{pollOneValue:data}); }); - socket.on('buttonval', function(data) { + socket.on('sendAT', function(data) { serialPort.write('AT\r'); - console.log('sending:..'); + console.log('sending AT...'); }); - socket.on('sliderval', function(data) { - serialPort.write(data + 'P'); - }); - - }); + }); } // Listen to serial port @@ -71,12 +67,15 @@ function serialListener(debug) serialPort.on('data', function(data) { //receivedData += data.toString(); //if (receivedData .indexOf('E') >= 0 && receivedData .indexOf('B') >= 0) { - sendData = '50'; //.substring(receivedData .indexOf('B') + 1, receivedData .indexOf('E')); + sendData = data; //.substring(receivedData .indexOf('B') + 1, receivedData .indexOf('E')); receivedData = ''; console.log('server event happening..' + data + '.\r'); //} // send the incoming data to browser with websockets. - socketServer.emit('update', sendData); + //socketServer.emit('update', sendData); + + //if is message and is parsed + socketServer.emit('newMessage', sendData); }); //setTimeout(sendPin,500); serialPort.write('AT+CPIN=3797\r');