Creating a class to represent a drone
Now, we will write Python code that will run on the different IoT boards. Remember to copy the files we have created in the previous chapter to a directory in the computer or device that will represent the board that controls a drone and that we will use to run a Python script. We saved the files in a directory called certificates
. Create a python_certificates
directory in the computer or board you are going to use as the MQTT client for this example. Copy the following three files to this new directory:
ca.crt
: Certificate authority certificate filedevice001.crt
: Client certificate filedevice001.key
: Client key
We will create the following two classes:
Drone
: This class will represent a drone and provides methods that will be called whenever a command has to be processed. In order to keep the example simple, our methods will just print the actions that the drone executes after each method is called to the console output. A real-life class that represents...