As some exercise, do the following three tasks about MQTT:
- Modify the stateful-server.py to replace the ‘magic number’ by a ‘magic list’. Now it shall work this way instead: every time the client sent message ‘2’, the server will append a random integer to the magic list (the list is initially empty). Sending message ‘1’ to the server will make it return the current content of the magic list. Use the default client.py as a testing client. Submit your server Python script.
- Besides our private MQTT broker, there are public MQTT brokers on the Internet, for testing purpose. Take a look at this Mosquitto testing broker page https://test.mosquitto.org/. Write a simple Python subscriber to subscribe to the # topic, to see what other people around the world are doing with that broker :) Read that web page to learn the needed parameters for connection and subscription. You may use the on_connect callback function in chat.py to help you figure out whether or not the connection is established. Submit your subscriber Python script.
- Write into a short text file and briefly describe what you think you may organize the MQTT topics for your project (see page 20 of the lecture slides).
This is an individual homework. One submission per student. Pack your results for all the three tasks (two Python scripts and one text file) into a zip file, and email it to our TA, Yu-Ting Chiang 蔣毓庭 (61247043s@gapps.ntnu.edu.tw). Use your course email address, and clearly identify yourself in the email.
Submission deadline: August 12 (Monday).