Skip to content
David Kirwan edited this page May 19, 2013 · 4 revisions

These instructions must be followed in sequence to ensure we have the required dependencies to perform the task at each stage. If for what ever reason you become stuck in configuring and setting the system up, please first examine the FAQ available at https://github.com/davidkirwan/ardtweeno/wiki otherwise please contact me for assistance on Twitter at: @kirwan_david

Install Package Dependencies

In order to install the dependencies and utilities for compiling Ruby native extensions in C we need to do the following steps:

sudo apt-get install build-essential zlib1g-dev \
libssl-dev libreadline-dev libyaml-dev \
libcurl4-openssl-dev curl git-core \
python-software-properties gcc gobjc \
git

Install NodeJS

To install NodeJS on the system do the following:

sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get -y install nodejs

Install RVM and Ruby

To install Ruby on the system using RVM do the following:

\curl -#L https://get.rvm.io | bash -s stable --autolibs=3 --ruby

# Then do the following to install Ruby 2.0.0p0 with OpenSSL support
rvm pkg install openssl

# Then
rvm install 2.0.0 \
    --with-openssl-dir=$HOME/.rvm/usr \
    --verify-downloads 1

# Then
rvm use 2.0.0

Install Ruby Gem Dependencies

To install Ruby gems required by Ardtweeno, do the following:

gem install rake nokogiri rack foreman json typhoeus mongo \
bson_ext rack-test test-unit rspec serialport sinatra thin \
rufus-scheduler bundler

Install the Ardtweeno Gateway Application

The final step then is to install the Ardtweeno system itself. The best way to get access to the Ardtweeno system is to checkout a copy of the repository on Github. We can do this using the following commands:

# Checkout the latest source code from the Git repository
git clone git@github.com:davidkirwan/ardtweeno.git

# Enter the folder
cd ardtweeno/ardtweeno-gem

# Build and install the Ardtweeno gem, possibly requires sudo
rake install

# Ensure the system dependencies are all correct
bundle install

# Ensure the dependencies for the tech demo are all correct
cd ../tech-demo && bundle install && cd ../ardtweeno-gem

Launch the Ardtweeno Gateway

If you wish to stick with the Foreman method of launching the gateway, we can launch the Ardtweeno Gateway from the ardtweeno/ardtweeno-gem directory with the following command:

# Launch the Ardtweeno gateway on port 4567
foreman start -p 4567

Once complete we should be able to visit the following address in your browser and see the Ardtweeno gateway front end running: http://localhost:4567/

It should look something similar to the image below:

Ardtweeno HTTP Interface

Ardtweeno Configuration

Once the system has been executed at least once, it will do the following:

  • automatically create a configuration directory at the path: ~/.ardtweeno/

  • create a configuration file conf.yaml in this directory

  • create a node configuration file nodelist.yaml in this directory

The ~ in the path above corresponds with your home directory, this will be something like /home/yourusername/ or /home/users/yourusername If you somehow manage to get the system working on Windows firstly, my congratulations you succeeded where I failed (Getting the Ruby development setup was the main issue, which prevented me from compiling the native extensions required by some of the dependencies), secondly the path will be something similar to C:\Users\yourusername.

To query the default configuration view the following API Request URI: http://localhost:4567/api/v1/system/config?key=1230aea77d7bd38898fec74a75a87738dea9f657

It should return back something similar to the following with the default settings, keep in mind this is the output when formatted in a pretty fashion, the actual output will not be indented nicely as it is not meant to be viewed with human eyes:

{
  "dev": "/dev/pts/2",
  "speed": 9600,
  "adminkey": "1230aea77d7bd38898fec74a75a87738dea9f657",
  "db": {
    "dbHost": "localhost",
    "dbPort": 27017,
    "dbUser": "david",
    "dbPass": "86ddd1420701a08d4a4380ca5d240ba7",
    "dbName": "ardtweeno",
    "dbPacketsColl": "packets"
  },
  "zones": [
    {
      "zonename": "testzone0",
      "zonekey": "455a807bb34b1976bac820b07c263ee81bd267cc",
      "zonenodes": [
        "node0",
        "node1"
      ]
    },
    {
      "zonename": "testzone1",
      "zonekey": "79a7c75758879243418fe2c87ec7d5d4e1451129",
      "zonenodes": [
        "node2",
        "node3"
      ]
    }
  ]
}
  • dev is the hardware serial device for which the SerialParser will be connected to.

  • speed is the speed at which the SerialParser will attempt to connect to the device.

  • adminkey is the administrator API Key which is required to access the administration features of the Ardtweeno Gateway through the API

  • db is further broken down into:

    • dbHost the hostname which corresponds with the MongoDB database

    • dbPort the port number which the MongoDB database is listening on

    • dbUser the username used to authenticate with the MongoDB database

    • dbPass the password used to authenticate with the MongoDB database

    • dbName the name of the database being managed by MongoDB

    • dbPacketsColl the collection within the database which contains the packet data

  • zones is further broken down, there is an array containing potentially multiple zones each with the format:

    • zonename the name of the zone

    • zonekey the API key used to authenticate when performing administrator functions on this zone

    • zonenodes this is further broken down into an array potentially containing multiple strings of the node names

These settings mirror the contents of the ~/.ardtweeno/conf.yaml configuration file, you will need to configure these to suit the system on your Raspberry Pi machine. I highly recommend you change the API key values also from the defaults to something you prefer. This will ensure the system remains secure when deployed in production. The conf.yaml file structure is stored in the YAML markup language. The contents of the default file can be seen below:

NOTE: The configuration files are YAML which does not work very well or at all with whitespace indentation other than the regular space character. Do not use the tab key to indent the configuration files!

# Device the serial device to which the Ardtweeno SerialParser will connect
dev: /dev/ttyUSB0
speed: 9600

# Administrator API Key
adminkey: 1230aea77d7bd38898fec74a75a87738dea9f657

# Settings for the Database
db:
  dbHost: localhost
  dbPort: 27017
  dbUser: herp
  dbPass: 86ddd1420701a08d4a4380ca5d240ba7
  dbName: ardtweeno
  dbPacketsColl: packets

# Zone configuration
zones:
  -
    zonename: testzone0
    zonekey: 455a807bb34b1976bac820b07c263ee81bd267cc
    zonenodes:
      - node0
  -
    zonename: testzone1
    zonekey: 79a7c75758879243418fe2c87ec7d5d4e1451129
    zonenodes:
      - node1

The second configuration file ~/.ardtweeno/nodelist.yaml contains the following configuration paramaters relating to the managed nodes to which the Ardtweeno gateway is responsible for managing. It is also stored in the YAML language:

-
  name: node0
  key: 500d81aafe637717a52f8650e54206e64da33d27
  description: This node has a temperature sensor
  version: 0.2.1
  sensors:
    - Temperature

Ardtweeno Nodes are defined in this configuration file. All packets received from nodes which are not also defined in this file are dropped automatically by the gateway.