Find a file
Mike Stegeman f673aed983
Move certs into ssl folder, add files to gitignore. (#455)
Because I can't stand untracked files in my folder.
2018-02-12 12:31:25 -07:00
.vscode Add vscode debugger support 2017-07-17 11:41:52 -07:00
config Add timeout when adding things. 2018-02-05 19:16:58 -05:00
doc Add How To OTA document 2017-09-19 13:28:57 -04:00
image Remove wifi setup zip file after unpacking. (#652) 2018-02-09 21:26:11 +00:00
src Move certs into ssl folder, add files to gitignore. (#455) 2018-02-12 12:31:25 -07:00
ssl Move certs into ssl folder, add files to gitignore. (#455) 2018-02-12 12:31:25 -07:00
static Allow user to update add-ons. (#644) 2018-02-09 17:31:41 +00:00
tools Move certs into ssl folder, add files to gitignore. (#455) 2018-02-12 12:31:25 -07:00
.eslintignore Address review comments for add-on discovery. 2017-11-28 06:52:16 -07:00
.eslintrc.js Add eslint-plugin-html to config file 2017-12-07 12:57:04 -05:00
.gitignore Store tunneltoken and notunnel data in database. 2017-11-07 14:40:23 -07:00
.travis.yml [minor] promote use of LTS (#627) 2018-02-08 09:33:44 -05:00
cross-compile.sh [minor] promote use of LTS (#627) 2018-02-08 09:33:44 -05:00
global.d.ts Convert ec-crypto to typescript. 2017-07-17 11:41:51 -07:00
install.sh [minor] promote use of LTS (#627) 2018-02-08 09:33:44 -05:00
LICENSE Static index page with NodeJS and Express 2017-03-10 15:28:41 +00:00
package.json Update version to 0.3.0. (#547) 2018-01-26 20:03:03 +00:00
pagekite.py Subdomain registration and certificate issuing 2017-06-26 19:41:26 -07:00
README.md Move certs into ssl folder, add files to gitignore. (#455) 2018-02-12 12:31:25 -07:00
run-app.sh Scripts to build a raspberry pi gateway on the host - corrected (#256) 2017-08-22 11:52:07 -07:00
tsconfig.json Make tsc ignore addons. (#662) 2018-02-12 09:02:07 -07:00
webpack.config.js Change adapter to add-on where appropriate. (#424) 2017-11-20 13:00:16 -07:00
yarn.lock Remove winston 2018-01-19 11:00:56 -05:00

Things Gateway by Mozilla

Build Status codecov dependencies devdependencies license

Web of Things gateway.

If you have a Rasberry Pi, the easiest way to use the gateway is to download and flash a pre-built software image from Mozilla to an SD card. Otherwise you can build it from source yourself (see below).

Prerequisites for Building

Install OS

(If you're just installing on your PC, you can skip this step).

If you're installing on a Raspberry Pi then you may need to set up the OS on the Raspberry Pi first. See here for instructions.

Install pkg-config

Under Linux:

$ sudo apt-get install pkg-config

Under OSX:

See here.

nvm allows you to easily install different versions of node. To install nvm:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

Close and reopen your terminal window. Use nvm to install a LTS version of node and set the default version.

$ nvm install --lts
$ nvm use --lts
$ nvm alias default lts/*

Verify that node and npm have been installed:

$ npm --version
5.6.0
$ node --version
v8.9.4

Note: these versions might differ from the LTS version installed locally.

Install node (if you didn't use nvm)

(If you already installed node via nvm you can skip this step)

Follow the directions from NodeJS to install on your platform.

Install libusb and libudev (Linux only)

$ sudo apt-get install libusb-1.0-0-dev libudev-dev

Install git

You'll need git to checkout the repositories.

$ sudo apt-get install git

Build and Install openzwave

$ cd
$ git clone https://github.com/OpenZWave/open-zwave.git
$ cd open-zwave
$ make && sudo make install
$ sudo ldconfig

Note: You may need to manually add /usr/local/lib to your LD_LIBRARY_PATH enviroment variable by adding the following to your ~/.profile file:

export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH

You can run this on the command line as well so it has immediate effect. After running it you should run sudo ldconfig again to make sure the configuration change goes through.

Download and Build Gateway

Clone the GitHub repository (or fork it first):

$ cd
$ git clone https://github.com/mozilla-iot/gateway.git

Change into the gateway directory:

$ cd gateway

Install dependencies:

NOTE: yarn is preferred but npm install will also work. To install yarn run npm install --global yarn or for a more secure installation follow the directions for your OS.

$ yarn

Add SSL certificate:

The HTTPS server looks for privatekey.pem and certificate.pem. You can use a real certificate or generate a self-signed one by following the steps below.

$ mkdir -p ssl
$ openssl genrsa -out ssl/privatekey.pem 2048
$ openssl req -new -sha256 -key ssl/privatekey.pem -out ssl/csr.pem
$ openssl x509 -req -in ssl/csr.pem -signkey ssl/privatekey.pem -out ssl/certificate.pem

Start the web server:

$ npm start

Load https://localhost:4443 in your web browser (or use the server's IP address if loading remotely). Since you're using a self-signed certificate, you'll need to add a security exception in the browser.

Debugging

If you are using vscode simply use the "launch" target it will build the gateway in debugger mode.

If you are not using vscode run npm run debug and it will build the gateway and launch it with --inspect.

Running Tests

To run the linter and all tests:

$ npm test

To run a single test:

$ jest src/test/{test-name}.js

(assumes you have the jest command on your PATH, otherwise use ./node_modules/jest/bin/jest.js)

Source Code Structure

  • config/ - Gateway configuration
  • src/
    • adapters/ - Adapter device drivers (e.g. ZigBee, Z-Wave)
    • controllers/ - App URL routes and their logic
    • models/ - Data model and business logic
    • test/ - Integration tests
    • views/ - HTML views
    • adapter-manager.js - Manages adapters (e.g. ZigBee, Z-Wave)
    • app.js - The main back end script
    • constants.js - System wide constants
    • db.js - Manages the SQLite3 database
    • router.js - Routes app URLs to controllers
  • static/ - Static CSS, JavaScript & image resources for web app front end
  • tools/ - Helpful utilities (not part of the build)
  • package.json - npm module manifest