Publishing data retrieved from sensors to the cloud-based MQTT server

If we display the status of the surfer and his surfboard with numbers, it will be difficult to understand the real status. So, we will have to map the integer that represents the status into a string that explains the status.

Now, we will create a new Python file named surfboard_status.py in the main virtual environment folder. The following lines show the code for this file, which defines constants for the different status numbers and a dictionary that maps these constants with integers to strings with the descriptions for the status. The code file for the sample is included in the mqtt_python_gaston_hillar_06_01 folder, in the surfboard_status.py file:

SURFBOARD_STATUS_IDLE ...

Get Hands-On MQTT Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.