Skip to content

Commit 7638db4

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

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

examples/example.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,24 @@ def user_task(client):
5757
level=logging.DEBUG if args.debug else logging.INFO,
5858
)
5959

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

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

examples/micropython_basic.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,20 @@ 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-
# client = ArduinoCloudClient(
80-
# device_id=DEVICE_ID,
81-
# ssl_params={
82-
# "keyfile": KEY_PATH, "certfile": CERT_PATH, "cadata": CADATA, "cert_reqs": ssl.CERT_REQUIRED
83-
# }
84-
# )
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.
83+
#client = ArduinoCloudClient(
84+
# device_id=DEVICE_ID,
85+
# ssl_params={
86+
# "keyfile": KEY_PATH, "certfile": CERT_PATH, "cadata": CADATA,
87+
# "verify_mode": ssl.CERT_REQUIRED, "server_hostname" : "iot.arduino.cc"
88+
# },
89+
#)
8590

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

0 commit comments

Comments
 (0)