# Labs

## MQTT Labs

## Mosquitto Intel® Edison Setup

We should have all Mosquitto MQTT tools available in latest version of Linux Yocto based version

* [Building and running Mosquitto MQTT on Intel Edison Old Version](https://software.intel.com/en-us/blogs/2015/02/20/building-and-running-mosquitto-mqtt-on-intel-edison)
* [Connecting Sensor Networks and Devices to the Cloud in just minutes: Solution Brief](https://software.intel.com/sites/default/files/managed/52/10/IBM_Connecting_Sensor_Networks_and_Devices_Cloud_Minutes_Rev1_2.pdf)

## Mosquitto Intel® Galileo Setup

```bash
root@galileo:~# wget http://mosquitto.org/files/source/mosquitto-1.3.5.tar.gz
root@galileo:~# tar xvf mosquitto-1.3.5.tar.gz
root@galileo:~# cd mosquitto-1.3.5
root@galileo:~# make -j3 WITH_SRV=no
root@galileo:~# adduser mosquitto
root@galileo:~# cd test/broker
root@galileo:~# make -j3 test
root@galileo:~# cd ../../
root@galileo:~# cp client/mosquitto_pub /usr/bin
root@galileo:~# cp client/mosquitto_sub /usr/bin
root@galileo:~# cp lib/libmosquitto.so.1 /usr/lib
root@galileo:~# cp src/mosquitto /usr/bin
```

## Mosquitto Applications

```bash
root@board:~# mosquitto
1462105305: Error: Invalid user 'mosquitto'.
root@board:~# mosquitto_sub
Error: You must specify a topic to subscribe to.
mosquitto_sub is a simple mqtt client that will subscribe to a single topic and print all messages it . 
...
root@board:~# mosquitto_pub
Error: You must specify a topic to subscribe to.
mosquitto_sub is a simple mqtt client that will subscribe to a single topic and print all messages it .
...
```

## Mosquitto Demo Temperature Gauge

Go to <http://test.mosquitto.org/gauge/> and execute

```bash
root@platform:~# mosquitto_pub -h test.mosquitto.org -t temp/random -m 23.0
```

## Mosquitto MQTT Server/Broker

As subscribers

```bash
root@board:~# mosquitto_sub -h test.mosquitto.org -p 1883 -t IoT101/#
```

As publishers

```bash
root@board:~# mosquitto_pub -h test.mosquitto.org -p 1883 -t IoT101/all -m "Hello All Operators!"
```

See output from the following command

```bash
root@board:~# mosquitto_sub -h test.mosquitto.org -t "#" -v
```
