O'Reilly logo

Hands-On MQTT Programming with Python by Gaston C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with multiple MQTT servers

Add the following lines to the existing surfboard_monitor.py 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 surfboard_monitor.py 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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required