Working with multiple calls to the loop method

The following lines declare the process_incoming_commands method that is part of the VehicleCommandProcessor class. You have to add these lines to the existing vehicle_mqtt_client.py Python file. The code file for the sample is included in the mqtt_python_gaston_hillar_04_01 folder, in the vehicle_mqtt_client.py file:

    def process_incoming_commands(self):        self.client.loop()

The process_incoming_commands method calls the loop method for the MQTT client and ensures communication with the MQTT server is carried out. Think about the call to the loop method as synchronizing your mailbox. Any pending messages to be published in the outgoing box will be sent, any incoming messages will arrive to the ...

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.