Mobile App, MQTT Client, IoT Exercise
MQTT Exercise with Mobile App, without Security
In the previous process, MQTT was tested using only a PC.
Here, we test by adding a mobile app to the mqtt client device while maintaining the previous test settings.
1. Test system configuration
♦ Run MQTT broker on PC.
♦ Set the first client to subscribe to the topic /momo, and the second client to subscribe to the topic /toto.
♦ The third client is executed to publish the message “Hi, MOMO” to the topic /momo.
♦ The last client is the app on the mobile phone, → first try to subscribe to the topic called /momo → then try to publish a message to the topic /momo.
2. MQTT PC Test test procedure
Step1. Open a windows cmd window and check the IP address of the PC to be used as a broker.
any path> ipconfig
Step2. Run MQTT broker/server in windows cmd window.
~ mosquitto>mosquitto -v
Step3. Open a new windows cmd window and run the client subscribing to /momo.
~/mosquitto>mosquitto_sub -h 192.168.0.4 -t /momo
Step4. Open a new windows cmd window and run the client subscribing to /soso.
~/mosquitto>mosquitto_sub -h 192.168.0.4 -t /momo
Step5. Run the mobile app to run the client subscribing to /momo.
Install the MQTT client in Google Player and set it as shown on the right. You can use your favorite app.
Step6. Open a new windows cmd window and try to publish the message “Hi, MOMO” to the topic /momo.
~/mosquitto>mosquitto_pub -h 192.168.0.4 -t /momo -m “Hi, MOMO”
Step7. In the mobile client (App), try to publish the message “Hello, momo” to /soso.
3. MQTT PC Test Result
The final result screen of this test is shown in the figure below.
This time, because of the mobile app, the client subscribing to /soso finally gets the message.