# Quickstart

## RaspberryPi Setup

You need a fresh setup of Raspbian Jessie Light (the real thing and not NOOBS, otherwise you may have to deal with conflicts).\
Also ssh access to your Raspberry and a working network connection. If you need more detailed instructions please consult the excellent [documentation on raspberrypi.org](https://www.raspberrypi.org/documentation/).

## Space requirements

If you know what you are doing you can squeeze everything onto a 2GB sdcard, but a 4GB+ sdcard is recommended.\
If you plan on doing development you should use a 8GB+ sdcard.

## Hardware reqirements

A Raspberry PI 3 is reqired for this setup. While other models may work its the only supported setup.

Debian 8 and Ubuntu 16.xx where used during development, and all packages are also available for amd64. But you have to configure the components yourself.

If your devices (opentrigger-board, rpl-border-router) have not yet been flashed with firmware yet, please reade the [opentrigger-board setup guide](https://acolono.gitbook.io/opentrigger/overview/buttons/opentrigger-board).

## Installation

```bash
wget -qO- https://acolono.github.io/opentrigger-quickinstall/setup.sh | STAGE=production bash
```

This is the default setup - binaries only.\
The development setup can be installed by passing `STAGE=development` but the development dependencies can also be added later on by installing the `opentrigger-dev` package.

After the installation is done your raspberry will power down.\
Now disconnect it from your power source and plug in the rpl-border-router - which will act as our 6LoWPAN router.

![](https://media.giphy.com/media/l0HlK2isSk4RAusog/source.gif)

### Node-RED

The Node-RED version shipped with Raspbian is quite old, if you want to update it manually have a look at [this guide](http://nodered.org/docs/hardware/raspberrypi).

## Testing

Restart your Raspberry and after it's done booting, get the routers address.

```
grep -A1 'Server IPv6 addresses' /var/log/syslog
```

You should see something like this:

```
tunslip6[780]: Server IPv6 addresses:
tunslip6[780]: aaaa::221:2eff:ff00:5e2c
```

Btw: this only works after a fairly recent power cycle (rebooting does not restart the router).

Now look at your routing table (use the server address from the log file).

```
curl -s [aaaa::221:2eff:ff00:5e2c] | html2text
```

In my case, there is one button connected, and the output looks like this:

```
Neighbors
fe80::221:2eff:ff00:5ce3
Routes
aaaa::221:2eff:ff00:5ce3/128 (via fe80::221:2eff:ff00:5ce3) 827s
```

It should be possible to ping the device now.

```
ping6 aaaa::221:2eff:ff00:5ce3
```

Now watch the distributor's log and push the button while doing so:

```
sudo supervisorctl tail -f ot_distributor
```

Ouput should look similar to this:

```javascript
// Publishing To: /opentrigger/signals/trigger
{
  "Timestamp": "2016-10-31T20:13:07.256648+00:00",
  "UniqueIdentifier": "[aaaa::221:2eff:ff00:5ce3]",
  "Origin": null,
  "EventType": "Trigger",
  "EventId": 98
}
// Publishing To: /opentrigger/signals/release
{
  "Age": 937,
  "Timestamp": "2016-10-31T20:13:08.193695+00:00",
  "UniqueIdentifier": "[aaaa::221:2eff:ff00:5ce3]",
  "Origin": null,
  "EventType": "Release",
  "EventId": 98
}
```

You can also examine the message queue:

```bash
mosquitto_sub -v -t '/opentrigger/#'
```

If you have a version with an RGB-LED you can make it blink red:

```bash
coap post coap://[aaaa::221:2eff:ff00:5ce3]/led/RGB -p 'r=255&g=0&b=0&delay=20&times=3'
```
