Working with multiple MQTT servers

Add the following lines to the existing in the main virtual environment folder. The following lines declare the main block. The code file for the sample is included in the mqtt_python_gaston_hillar_06_01 folder, in the file:

if __name__ == "__main__": surfboard = Surfboard(device_id=device_id, status=SURFBOARD_STATUS_IDLE, speed_mph=0, altitude_feet=0, water_temperature_f=0) pubnub_client_id = "{}/{}/{}".format( pubnub_publish_key, pubnub_subscribe_key, device_id) pubnub_client = mqtt.Client(client_id=pubnub_client_id, protocol=mqtt.MQTTv311) pubnub_client.on_connect = on_connect_pubnub pubnub_client.on_disconnect = on_disconnect_pubnub pubnub_client.connect(host=pubnub_mqtt_server_host, ...

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.