@@ -31,7 +31,8 @@ def on_clight_changed(client, clight):
31
31
logging .info (f"ColoredLight changed. Swi: { clight .swi } Bri: { clight .bri } Sat: { clight .sat } Hue: { clight .hue } " )
32
32
33
33
34
- def main (client ):
34
+ def user_task (client ):
35
+ # NOTE: this function should not block.
35
36
# This is a user-defined task that updates the colored light. Note any registered
36
37
# cloud object can be accessed using the client object passed to this function.
37
38
# The composite ColoredLight object fields can be assigned to individually, using dot:
@@ -65,9 +66,8 @@ def wifi_connect():
65
66
wifi_connect ()
66
67
67
68
# Create a client object to connect to the Arduino IoT cloud.
68
- # For MicroPython, the key and cert files must be stored in DER
69
- # format on the filesystem. Alternatively, a username and password
70
- # can be used to authenticate:
69
+ # For MicroPython, the key and cert files must be stored in DER format on the filesystem.
70
+ # Alternatively, a username and password can be used to authenticate:
71
71
# client = AIOTClient(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
72
72
client = AIOTClient (
73
73
device_id = DEVICE_ID ,
@@ -106,7 +106,7 @@ def wifi_connect():
106
106
# The client can also schedule user code in a task and run it along with the other cloud objects.
107
107
# To schedule a user function, use the Task object and pass the task name and function in "on_run"
108
108
# to client.register().
109
- client .register (Task ("main " , on_run = main , interval = 1.0 ))
109
+ client .register (Task ("user_task " , on_run = user_task , interval = 1.0 ))
110
110
111
111
# Start the Arduino IoT cloud client.
112
112
client .start ()
0 commit comments