Skip to content

Commit b15916f

Browse files
committed
examples: Update examples.
Signed-off-by: iabdalkader <[email protected]>
1 parent 49d1177 commit b15916f

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

examples/example.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from arduino_iot_cloud import Task
1212
from random import uniform
1313
import argparse
14-
import ssl
14+
import ssl # noqa
1515

1616
from secrets import DEVICE_ID
1717
from secrets import SECRET_KEY # noqa
@@ -58,17 +58,22 @@ def user_task(client):
5858
)
5959

6060
# Create a client object to connect to the Arduino IoT cloud.
61-
# To use a secure element, set the token's "pin" and URI in "keyfile" and "certfile", and
62-
# the CA certificate (if any) in "ssl_params". Alternatively, a username and password can
63-
# be used to authenticate, for example:
64-
# client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
65-
client = ArduinoCloudClient(
66-
device_id=DEVICE_ID,
67-
ssl_params={
68-
"pin": "1234",
69-
"keyfile": KEY_PATH, "certfile": CERT_PATH, "ca_certs": CA_PATH, "cert_reqs": ssl.CERT_REQUIRED
70-
},
71-
)
61+
# The most basic authentication method uses a username and password. The username is the device
62+
# ID, and the password is the secret key obtained from the IoT cloud when provisioning a device.
63+
client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
64+
65+
# Alternatively, the client also supports key and certificate-based authentication. To use this
66+
# mode, set "keyfile" and "certfile", and the CA certificate (if any) in "ssl_params".
67+
# Furthermore, secure elements, which can be used to store the key and cert, are also supported.
68+
# To secure elements, set "use_hsm" to True in "ssl_params" and set the token's "pin" if any.
69+
# client = ArduinoCloudClient(
70+
# device_id=DEVICE_ID,
71+
# ssl_params={
72+
# "use_hsm": True, "pin": "1234",
73+
# "keyfile": KEY_PATH, "certfile": CERT_PATH, "cafile": CA_PATH,
74+
# "verify_mode": ssl.CERT_REQUIRED, "server_hostname" : "iot.arduino.cc"
75+
# },
76+
# )
7277

7378
# Register cloud objects.
7479
# Note: The following objects must be created first in the dashboard and linked to the device.

examples/micropython_async_wifi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def on_switch_changed(client, value):
4242
)
4343

4444
# Create a client object to connect to the Arduino IoT cloud.
45-
# For MicroPython, the key and cert files must be stored in DER format on the filesystem.
46-
# Alternatively, a username and password can be used to authenticate:
45+
# The most basic authentication method uses a username and password. The username is the device
46+
# ID, and the password is the secret key obtained from the IoT cloud when provisioning a device.
4747
client = ArduinoCloudClient(
4848
device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY
4949
)

examples/micropython_basic.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,19 @@ def wifi_connect():
7373
wifi_connect()
7474

7575
# Create a client object to connect to the Arduino IoT cloud.
76-
# For MicroPython, the key and cert files must be stored in DER format on the filesystem.
77-
# Alternatively, a username and password can be used to authenticate:
76+
# The most basic authentication method uses a username and password. The username is the device
77+
# ID, and the password is the secret key obtained from the IoT cloud when provisioning a device.
7878
client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
79+
80+
# Alternatively, the client also supports key and certificate-based authentication. To use this
81+
# mode, set "keyfile" and "certfile", and the CA certificate (if any) in "ssl_params".
82+
# Note that for MicroPython, the key and cert files must be stored in DER format on the filesystem.
7983
# client = ArduinoCloudClient(
8084
# device_id=DEVICE_ID,
8185
# ssl_params={
82-
# "keyfile": KEY_PATH, "certfile": CERT_PATH, "cadata": CADATA, "cert_reqs": ssl.CERT_REQUIRED
83-
# }
86+
# "keyfile": KEY_PATH, "certfile": CERT_PATH, "cadata": CADATA,
87+
# "verify_mode": ssl.CERT_REQUIRED, "server_hostname" : "iot.arduino.cc"
88+
# },
8489
# )
8590

8691
# Register cloud objects.

0 commit comments

Comments
 (0)