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 = 0 SURFBOARD_STATUS_PADDLING = 1 SURFBOARD_STATUS_RIDING = 2 SURFBOARD_STATUS_RIDE_FINISHED = 3 SURFBOARD_STATUS_WIPED_OUT = 4 ...