MQTT-SN implementation in contiki for the course LINGI2146 - Mobile and Embedded Computing
- /broker : contains the config file of mosquitto broker
- /gateway : contains all files relative to the gateway
- gateway_v2.c : file containing the code of the sensor root node
- gateway.py : file running the gateway
- /sensor_node : contains all files relative to the sensor nodes
- sensor_v2.c : file containing the code of a sensor node
- /subscriber : contains all files relative to the subscribers of the MQTT network
- subscriber.py : file running one subscriber
- topics_subX.txt : file containing subscriber's topics
- contiki and cooja
- the cooja plugin serial2pty.
- Mosquitto
- Python
- paho-mqtt
- Inside a new simulation in cooja, add a first z1 mote with gateway_v2.c.
- On this node perform a right click and choose serial2pty.
- Add as many z1 motes as you want with sensor_v2.c.
- Go to the /gateway directory and run inside a command prompt
sudo python gateway.py -m <mote_nomber>
where<mote_number>
is the number of the serial device of serial2pty. You can get this number unside cooja in the small window of the related plugin :/dev/pts/<mote_number>.
- Got to /broker and run
mosquitto -c broker.conf
. If mosquitto is already running, you need to kill its process. - Inside a new command prompt, in the /subscriber directory, enter
python subscriber.py -f <topics_file>
where<topics_file>
is a .txt file located in the same directory. You can perform this action as many times as you want. - Finally run the simulation on cooja
The <topics_file>
contains the different subscriptions of a subscriber. These subscriptions have the form : <node_id>/<topic>
where <node_id>
is the rime id of a node inside contiki and <topic>
is temperature or humidity. An example is 2.0/temperature
.