README.md 1.15 KB
Newer Older
Luca Arrotta's avatar
Luca Arrotta committed
1 2 3 4
# Setup REST and MQTT



Luca Arrotta's avatar
Luca Arrotta committed
5
* You can import the project directly from a *Version Control System*, by providing the following URL: 
Riccardo Presotto's avatar
Riccardo Presotto committed
6
https://ewserver.di.unimi.it/gitlab/riccardopresotto/setup_rest_mqtt.git
Luca Arrotta's avatar
Luca Arrotta committed
7 8 9 10 11

<img src = './assets/img_1.png'>


* Otherwise, take care to import the project as a Gradle Project
Luca Arrotta's avatar
Luca Arrotta committed
12
* If required, trust the project and accept the Gradle auto-import
Luca Arrotta's avatar
Luca Arrotta committed
13
* Wait until the Gradle indexing process ends (it may take a few seconds)
Luca Arrotta's avatar
Luca Arrotta committed
14 15 16 17

## REST

* Run StartServer.java located in: *REST\_MQTT_example/src/main/java/REST/*
Luca Arrotta's avatar
Luca Arrotta committed
18
    * Don't worry about the red *INFO* console prints
Luca Arrotta's avatar
Luca Arrotta committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
* Use a REST Client application (i.e., Advanced REST Client) to test if the server works correctly
* For example you can run the following request:

<img src = './assets/img_2.jpeg'>


## MQTT
* Dowload and install the Mosquitto broker from here: *https://mosquitto.org/download/*
* Run the Mosquitto broker:
	* **MacOS**
		- brew services start mosquitto
		- mosquitto_sub -h localhost -v -t ‘#’  *(Instead ‘#’ specify the topics of interest)*
	* **Windows**
		- Run the file mosquitto.exe

* Run SubExample.java and PubExample.java located in *REST\_MQTT_example/src/main/java/MQTT/*