@@ -22,20 +22,20 @@ def connected(client):
22
22
# This is a good place to subscribe to feed changes. The client parameter
23
23
# passed to this function is the Adafruit IO MQTT client so you can make
24
24
# calls against it easily.
25
- print 'Connected to Adafruit IO! Listening for DemoFeed changes...'
25
+ print ( 'Connected to Adafruit IO! Listening for DemoFeed changes...' )
26
26
# Subscribe to changes on a feed named DemoFeed.
27
27
client .subscribe ('DemoFeed' )
28
28
29
29
def disconnected (client ):
30
30
# Disconnected function will be called when the client disconnects.
31
- print 'Disconnected from Adafruit IO!'
31
+ print ( 'Disconnected from Adafruit IO!' )
32
32
sys .exit (1 )
33
33
34
34
def message (client , feed_id , payload ):
35
35
# Message function will be called when a subscribed feed has a new value.
36
36
# The feed_id parameter identifies the feed, and the payload parameter has
37
37
# 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 ) )
39
39
40
40
41
41
# Create an MQTT client instance.
@@ -51,16 +51,16 @@ def message(client, feed_id, payload):
51
51
52
52
# Now the program needs to use a client loop function to ensure messages are
53
53
# 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.
55
55
56
56
# The first option is to run a thread in the background so you can continue
57
57
# doing things in your program.
58
58
client .loop_background ()
59
59
# 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)...' )
61
61
while True :
62
62
value = random .randint (0 , 100 )
63
- print 'Publishing {0} to DemoFeed.' .format (value )
63
+ print ( 'Publishing {0} to DemoFeed.' .format (value ) )
64
64
client .publish ('DemoFeed' , value )
65
65
time .sleep (10 )
66
66
@@ -70,14 +70,14 @@ def message(client, feed_id, payload):
70
70
# good option if you don't want to or can't have a thread pumping the message
71
71
# loop in the background.
72
72
#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)...')
74
74
#while True:
75
75
# # Explicitly pump the message loop.
76
76
# client.loop()
77
77
# # Send a new message every 10 seconds.
78
78
# if (time.time() - last) >= 10.0:
79
79
# value = random.randint(0, 100)
80
- # print 'Publishing {0} to DemoFeed.'.format(value)
80
+ # print( 'Publishing {0} to DemoFeed.'.format(value) )
81
81
# client.publish('DemoFeed', value)
82
82
# last = time.time()
83
83
0 commit comments