sudo apt install mosquitto
sudo apt install mosquitto-clients
Before the server starts, run the following command to launch the MQTT broker:
mosquitto -c mosquitto.conf
To publish messages from the command line, run the following command when the server is running:
mosquitto_pub -h localhost -t "topic" -m "1234"
In the above example, topic
is the topic.
You can check the message is successfully received in the server log, e.g.,
received: 1234
You can also send random data continuously to simulate the real use case by running the command:
i=1; while true; do mosquitto_pub -h localhost -t "topic" -m "$RANDOM"; i=$((i+1)); sleep 1; done
topic
: data captured by the sensor is sent with this topic.{ "time": "float", "activity": "bool", "y_acc": "float", "z_acc": "flaot", "y_correct": "bool", "z_correct": "bool" }
Follow Install Docker Engine to install Docker Desktop
.
To run the app, run:
docker-compose up
If you get the network mems-network declared as external, but could not be found
error, run:
docker network create mems-network --subnet=192.168.1.0/24 --gateway=192.168.1.1
- WebSocket endpoint:
http://localhost:8080/endpoint
http://localhost:3000
(e.g., React client) can connect to it.
/topic/time
- type:
float
- type:
/topic/activity
- type:
bool
- type:
/topic/y_acc
- type:
float
- type:
/topic/z_acc
- type:
float
- type:
/topic/y_correct
- type:
bool
- type:
/topic/z_correct
- type:
bool
- type:
Add new data
- Method:
POST
- Body: data captured by sensor
{ "time": "float", "activity": "bool", "y_acc": "float", "z_acc": "flaot", "y_correct": "bool", "z_correct": "bool" }
- Response:
{ "data": { "id": "int", "datetime": "string", "dataJson": { "time": "float", "activity": "bool", "y_acc": "float", "z_acc": "flaot", "y_correct": "bool", "z_correct": "bool" } }, "error": "string" }
Get data of the specified id
- Method:
GET
- Response:
{ "data": { "time": "float", "activity": "bool", "y_acc": "float", "z_acc": "flaot", "y_correct": "bool", "z_correct": "bool" }, "error": "string" }
Delete data of the specified id
- Method:
GET
- Response:
{ "data": "int", "error": "string" }
Get a list of data of with the specified offset
- Method:
GET
- Response:
{ "data": [ { "id": "int", "datetime": "string", "dataJson": { "time": "float", "activity": "bool", "y_acc": "float", "z_acc": "flaot", "y_correct": "bool", "z_correct": "bool" } } ], "error": "string" }