Book Image

Intel Galileo Blueprints

By : Marco Schwartz
Book Image

Intel Galileo Blueprints

By: Marco Schwartz

Overview of this book

Table of Contents (19 chapters)
Intel Galileo Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Setting Up the Galileo Board and the Development Environment
Index

Building the home automation interface


Now, we are ready to build the app that will facilitate the communication between the Galileo and Arduino boards.

We will use the same technique that we used in the previous chapter. We make use of the Node.js server to build a scalable network application, the Jade interface to manage interactions, and finally, JavaScript to link both.

Here is the first main.js file:

// Module
var express = require('express');
var app = express();

// Define port
var port = 3000;

// View engine
app.set('view engine', 'jade');
app.set('views', __dirname + '/views');

// Set public folder
app.use(express.static(__dirname + '/public'));

// Serve interface
app.get('/', function(req, res){
  res.render('interface');
});

// Rest
var rest = require("arest")(app);

// Add devices
rest.addDevice('http','192.168.1.105');
rest.addDevice('http','192.168.1.106');

// Start server
app.listen(port);
console.log("Listening on port " + port);

We will use the Express framework for this...