Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import paho.mqtt.client as mqtt
- def on_connect(client, obj, flags, rc):
- print("rc: " + str(rc))
- def on_message(client, obj, msg):
- print(msg.topic + " " + str(msg.qos) + " " + str(msg.payload))
- def on_subscribe(client, obj, mid, granted_qos):
- print("Subscribed: " + str(mid) + " " + str(granted_qos))
- client = mqtt.Client()
- client.on_connect = on_connect
- client.on_message = on_message
- client.on_subscribe = on_subscribe
- client.tls_set(
- ca_certs='/opt/wott/certs/ca.crt',
- certfile='/opt/wott/certs/client.crt',
- keyfile='/opt/wott/certs/client.key'
- )
- # disables peer verification
- # client.tls_insecure_set(True)
- # Note that you need to map x.d.wott.local to the IP to the MQTT server
- # in /etc/hosts as the hostname must match the CN in the certificate.
- client.connect('x.d.wott.local', 8883, 60)
- client.subscribe('wott/temperature', 0)
- client.loop_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement