This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo npm install foreman -g | |
npm install foreman -g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: node app.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Module dependencies. | |
*/ | |
var express = require('express') | |
, routes = require('./routes') | |
, http = require('http') | |
, path = require('path'); | |
var app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Serial Port Setup. | |
*/ | |
var portName = '/dev/ttyAMA0'; //This is the standard Raspberry Pi Serial port | |
var readData = ''; //Array to hold the values read in from the port | |
var sp = new serialport(portName, { | |
baudRate: 9600, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serialport = require("serialport").SerialPort; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Server Code | |
*/ | |
var server = http.createServer(app).listen(app.get('port'), function(){ | |
console.log("Express server listening on port " + app.get('port')); | |
}); | |
var io = require('socket.io').listen(server); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
io.sockets.on('connection', function(socket){ | |
console.log("Socket connected"); | |
socket.emit('connected', 123);</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
io.sockets.on('connection', function(socket){ | |
console.log("Socket connected"); | |
socket.emit('connected', 123); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* GET home page. | |
*/ | |
var fs = require('fs') | |
exports.index = function(req, res){ | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
var contents = fs.readFileSync("./public/index.html", "UTF-8"); | |
res.end(contents); | |
// res.render('index'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var socket = io.connect('http://your ip address here..'); | |
socket.on('connected', function(data) { | |
console.log('Connected, this is what I received : ', data); | |
//you could then emit something here for the server to receive like socket.emit("blah", "helloworld") -hello world is a string of data you are passing the sever here.. | |
}); |
OlderNewer