Receiving messages in Python

We will use the recently installed paho-mqtt version 1.3.1 module to subscribe to a specific topic and run code when we receive messages in the topic. We will create a VehicleCommandProcessor class in the same Python file, named, in the main virtual environment folder. This class will represent a command processor associated to an instance of the previously coded Vehicle class, configure the MQTT client and the subscription to the client, and declare the code for the callbacks that are going to be executed when certain events related to MQTT are fired.

We will split the code for the VehicleCommandProcessor class into many code snippets to make it easier to understand each code section. You ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.