@@ -22,20 +22,20 @@ def connected(client):
2222 # This is a good place to subscribe to feed changes. The client parameter
2323 # passed to this function is the Adafruit IO MQTT client so you can make
2424 # calls against it easily.
25- print 'Connected to Adafruit IO! Listening for DemoFeed changes...'
25+ print ( 'Connected to Adafruit IO! Listening for DemoFeed changes...' )
2626 # Subscribe to changes on a feed named DemoFeed.
2727 client .subscribe ('DemoFeed' )
2828
2929def disconnected (client ):
3030 # Disconnected function will be called when the client disconnects.
31- print 'Disconnected from Adafruit IO!'
31+ print ( 'Disconnected from Adafruit IO!' )
3232 sys .exit (1 )
3333
3434def message (client , feed_id , payload ):
3535 # Message function will be called when a subscribed feed has a new value.
3636 # The feed_id parameter identifies the feed, and the payload parameter has
3737 # the new value.
38- print 'Feed {0} received new value: {1}' .format (feed_id , payload )
38+ print ( 'Feed {0} received new value: {1}' .format (feed_id , payload ) )
3939
4040
4141# Create an MQTT client instance.
@@ -51,16 +51,16 @@ def message(client, feed_id, payload):
5151
5252# Now the program needs to use a client loop function to ensure messages are
5353# sent and received. There are a few options for driving the message loop,
54- # depending on what your program needs to do.
54+ # depending on what your program needs to do.
5555
5656# The first option is to run a thread in the background so you can continue
5757# doing things in your program.
5858client .loop_background ()
5959# Now send new values every 10 seconds.
60- print 'Publishing a new message every 10 seconds (press Ctrl-C to quit)...'
60+ print ( 'Publishing a new message every 10 seconds (press Ctrl-C to quit)...' )
6161while True :
6262 value = random .randint (0 , 100 )
63- print 'Publishing {0} to DemoFeed.' .format (value )
63+ print ( 'Publishing {0} to DemoFeed.' .format (value ) )
6464 client .publish ('DemoFeed' , value )
6565 time .sleep (10 )
6666
@@ -70,14 +70,14 @@ def message(client, feed_id, payload):
7070# good option if you don't want to or can't have a thread pumping the message
7171# loop in the background.
7272#last = 0
73- #print 'Publishing a new message every 10 seconds (press Ctrl-C to quit)...'
73+ #print( 'Publishing a new message every 10 seconds (press Ctrl-C to quit)...')
7474#while True:
7575# # Explicitly pump the message loop.
7676# client.loop()
7777# # Send a new message every 10 seconds.
7878# if (time.time() - last) >= 10.0:
7979# value = random.randint(0, 100)
80- # print 'Publishing {0} to DemoFeed.'.format(value)
80+ # print( 'Publishing {0} to DemoFeed.'.format(value) )
8181# client.publish('DemoFeed', value)
8282# last = time.time()
8383
0 commit comments