<commit_before># Internet of Tents

This repo contains the documentation, firmware and examples for the
Buzz Conf 2016 Internet of Tents workshop.

## Installation

To get your Node environment along with relevant drivers etc up and running,
please follow the directions in our [standard setup doc](https://github.com/nodebotsau/nbdau/blob/master/setup.md)

Please note at minimum you need the following before going any further

* Git
* A working node install, ideally node 6+
* Drivers for Arduino if you're using Win / Mac

### Installing this repo

Git clone or download and unzip this repo to a folder:

```
git clone <EMAIL>:nodebotsau/internetoftents.git
cd internetoftents
```

Then install dependencies

```
npm install
```

This will install:

* Node Red server that can be run locally (including contrib modules for Johnny
Five, InfluxDB
* Johnny Five (to interact with a local arduino)
* Interchange (so you can flash firmware to an arduino)
* MQTT js (to talk to MQTT servers)

## Running Node Red

To run node-red, `cd` to the root of your project folder then run:

```
./node-modules/.bin/node-red
```

And you will see Node Red spin up. If there are no errors you can access it
on [Localhost:1880](http://127.0.0.1:1880)

By default, contrib packages have been installed for:

* Johnny Five (GPIO nodes)
* InfluxDB (read and write nodes)

You can install more by simply npm-installing from your project folder and use
the packages that are provided at [http://flows.nodered.org/](http://flows.nodered.org/).

## Running a local MQTT Server

If you've installed the repo dependencies then you'll be able to run your own
node-based MQTT server using `mosca`.

To run the server:

```
./node_modules/.bin/mosca -v --http-port 8883
```

This will pass all the config details to the command line but should set up
the standard MQTT server on port 1883 as well as an HTTP Websockets port on
8883 on your local host.

You can demo this working by subscribing to a topic and then publishing a message.

In a new terminal execute a subscription request to the topic `hello`:

```
./node_modules/.bin/mqtt sub -t "hello" -h "localhost" -v
```

Then in yet *another* new terminal, publish a message to the `hello` topic:

```
./node_modules/.bin/mqtt pub -t 'hello' -h 'localhost' -m 'from MQTT.js'
```

If everything has gone properly then in your server terminal you should see the
message and payload details and in the subscription terminal you should see
the message results.

Congrats, you now have your very own MQTT broker and can publish messages and
subscribe to topics. If you wanted to, you could now point your Node-Red
instance at it using the MQTT publish and subscribe nodes.

Alternatively you can also use the BuzzConf site MQTT broker too - the details
of which are given below.

### Alternative servers

If you have a linux VM or linux machine you can install mosquitto
with simply an `apt-get install mosquitto mosquitto-client` which will give you
a highly configurable and robust MQTT broker to play with. This is what is running
the site infrastructure for BuzzConf.

## Using the BuzzConf MQTT server

The site wide MQTT server is available at `mqtt-broker.local` on the LAN. You
must be connected to the BuzzConf network in order to be able to access it. The
server will not be directly accessible from the Internet, however it is capable
of publishing messages to the Internet and other relay servers.

The port for the MQTT server is the standard MQTT port on `1883`.

### A note about security<commit_msg>Change MQTT server name to "mqtt.local".<commit_after># Internet of Tents

This repo contains the documentation, firmware and examples for the
Buzz Conf 2016 Internet of Tents workshop.

## Installation

To get your Node environment along with relevant drivers etc up and running,
please follow the directions in our [standard setup doc](https://github.com/nodebotsau/nbdau/blob/master/setup.md)

Please note at minimum you need the following before going any further

* Git
* A working node install, ideally node 6+
* Drivers for Arduino if you're using Win / Mac

### Installing this repo

Git clone or download and unzip this repo to a folder:

```
git clone <EMAIL>.com:nodebotsau/internetoftents.git
cd internetoftents
```

Then install dependencies

```
npm install
```

This will install:

* Node Red server that can be run locally (including contrib modules for Johnny
Five, InfluxDB
* Johnny Five (to interact with a local arduino)
* Interchange (so you can flash firmware to an arduino)
* MQTT js (to talk to MQTT servers)

## Running Node Red

To run node-red, `cd` to the root of your project folder then run:

```
./node-modules/.bin/node-red
```

And you will see Node Red spin up. If there are no errors you can access it
on [Localhost:1880](http://127.0.0.1:1880)

By default, contrib packages have been installed for:

* Johnny Five (GPIO nodes)
* InfluxDB (read and write nodes)

You can install more by simply npm-installing from your project folder and use
the packages that are provided at [http://flows.nodered.org/](http://flows.nodered.org/).

## Running a local MQTT Server

If you've installed the repo dependencies then you'll be able to run your own
node-based MQTT server using `mosca`.

To run the server:

```
./node_modules/.bin/mosca -v --http-port 8883
```

This will pass all the config details to the command line but should set up
the standard MQTT server on port 1883 as well as an HTTP Websockets port on
8883 on your local host.

You can demo this working by subscribing to a topic and then publishing a message.

In a new terminal execute a subscription request to the topic `hello`:

```
./node_modules/.bin/mqtt sub -t "hello" -h "localhost" -v
```

Then in yet *another* new terminal, publish a message to the `hello` topic:

```
./node_modules/.bin/mqtt pub -t 'hello' -h 'localhost' -m 'from MQTT.js'
```

If everything has gone properly then in your server terminal you should see the
message and payload details and in the subscription terminal you should see
the message results.

Congrats, you now have your very own MQTT broker and can publish messages and
subscribe to topics. If you wanted to, you could now point your Node-Red
instance at it using the MQTT publish and subscribe nodes.

Alternatively you can also use the BuzzConf site MQTT broker too - the details
of which are given below.

### Alternative servers

If you have a linux VM or linux machine you can install mosquitto
with simply an `apt-get install mosquitto mosquitto-client` which will give you
a highly configurable and robust MQTT broker to play with. This is what is running
the site infrastructure for BuzzConf.

## Using the BuzzConf MQTT server

The site wide MQTT server is available at `mqtt.local` on the LAN. You
must be connected to the BuzzConf network in order to be able to access it. The
server will not be directly accessible from the Internet, however it is capable
of publishing messages to the Internet and other relay servers.

The port for the MQTT server is the standard MQTT port on `1883`.

### A note about security
{'fraction_non_alphanumeric': 0.06533370881441847, 'fraction_numerical': 0.009856378484933821, 'mean_word_length': 4.117435158501441, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '434078', 'n_tokens_mistral': 2092, 'n_tokens_neox': 1953, 'n_words': 1080}