Skip to content
Permalink
7782a0dd9f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
16 lines (12 sloc) 475 Bytes
import paho.mqtt.client as mqtt
def on_connect( client, userdata, rc ):
""" callback function for client connection """
client.subscribe( "mytest/counter")
def on_message( client, userdata, msg ):
""" callback function for messages received """
print( "Topic: {}, Message: {}".format(msg.topic, msg.payload) )
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect( "iot.eclipse.org" ) # test broker
client.loop_forever()