|
11 | 11 | from arduino_iot_cloud import Task
|
12 | 12 | from random import uniform
|
13 | 13 | import argparse
|
14 |
| -import ssl |
| 14 | +import ssl # noqa |
15 | 15 |
|
16 | 16 | from secrets import DEVICE_ID
|
17 | 17 | from secrets import SECRET_KEY # noqa
|
@@ -58,17 +58,22 @@ def user_task(client):
|
58 | 58 | )
|
59 | 59 |
|
60 | 60 | # 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 | + # ) |
72 | 77 |
|
73 | 78 | # Register cloud objects.
|
74 | 79 | # Note: The following objects must be created first in the dashboard and linked to the device.
|
|
0 commit comments