Example #1
0
var currentPort = null;
var serialBuffer = [];

//dbs are compacted every 10 minutes
var AUTOCOMPACT_INTERVAL = 10 * 60 * 1000;
//databases of all data
var dbs = [];
//database of the nodes
var nodesdb = null;
//database of the action examples
var actionsdb = null;
//database of the rules
var rulesdb = null;

var app = new servi(false);
app.port(9090);

app.serveFiles("html");     // serve static HTML from public folder
app.route('/serials', listserials);
app.route('/serials/current', serveserial);
app.route('/test', serveTest);
app.route('/logs', serveLogs);

app.route('/messagetypes', serveMessagetypes);
app.route('/nodes', serveNodes);
app.route('/nodes/:nodeAddress', serveNodes);
app.route('/messages', serveMessages);
app.route('/messages/:dataname', serveMessages);
app.route('/messages/:dataname/:messageid', serveMessages);
app.route('/actions', serveActions);
app.route('/actions/:actionname', serveActions);
Example #2
0
var servi = require('servi'),
	app = new servi(true);

var dropAtHour, dropAtMinute, dropAtSecond;
var dropTimeInSeconds;

var dropped = true;

app.port(8080);
app.serveFiles('public');

// let the user know you started:
console.log('Server is listening on port 8080');

app.route('/', sendIndex);
app.route('/in/:time/:units', dropInTime);
app.route('/at/:hour/:min/:second', dropAtTime);

app.start();
app.listen(8080);

function dropAtTimer() {
	var now = new Date();

	hoursUntilDrop = Math.abs(dropAtHour - now.getHours());
	minutesUntilDrop = Math.abs(dropAtMinute - now.getMinutes());
	secondsUntilDrop = Math.abs(dropAtSecond - now.getSeconds());	

	console.log(hoursUntilDrop);
	console.log(minutesUntilDrop);
Example #3
0
var app = require('http').createServer(handler);
var io = require('socket.io')(app);
var fs = require('fs');

app.listen(80);


/*== Setup HTTP server ==*/
var servi = require('servi');
var html_server = new servi(true); // servi instance
html_server.port(8080);             // port number to run the server on
 
// configure the server's behavior:
html_server.serveFiles("../http");     // serve static HTML from public folder
// html_server.route('/data', sendData); // route requests for /data to sendData()
// now that everything is configured, start the server:
html_server.start();

function handler (req, res) {
  fs.readFile(__dirname + '/index.html',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }

    res.writeHead(200);
    res.end(data);
  });
}
Example #4
0
	
	To launch this, type 'node index.js portname' on the commandline, where
	portname is the name of your serial port.
		
	created 5 Nov 2012
	modified 21 Oct 2014
	by Tom Igoe
*/

var serialport = require("serialport"),		// include the serialport library
	SerialPort  = serialport.SerialPort,	   // make a local instance of serial
	servi = require('servi'),		// include the servi library
	app = new servi(false);		// servi instance

// configure the server's behavior:
app.port(8080);						// port number to run the server on
app.serveFiles("public");			// serve all static HTML files from /public


// respond to web GET requests for the index.html page:
app.route('/', sendIndexPage);
app.route('/index*', sendIndexPage);
// take anything that begins with /output as an LED request:
app.route('/turnon/', sendToSerial);

// now that everything is configured, start the server:
app.start();	
console.log("Listening for new clients on port 8080");

 
// the third word of the command line command is serial port name: