@@ -27,7 +27,13 @@ def on_value_changed(client, value):
2727 "-d" , "--debug" , action = "store_true" , help = "Enable debugging messages"
2828 )
2929 parser .add_argument (
30- "-c" , "--crypto-device" , action = "store_true" , help = "Use crypto device"
30+ "-b" , "--basic-auth" , action = "store_true" , help = "Username and password auth" ,
31+ )
32+ parser .add_argument (
33+ "-c" , "--crypto-device" , action = "store_true" , help = "Use soft-hsm/crypto device" ,
34+ )
35+ parser .add_argument (
36+ "-f" , "--file-auth" , action = "store_true" , help = "Use key/cert files"
3137 )
3238 args = parser .parse_args ()
3339
@@ -45,8 +51,25 @@ def on_value_changed(client, value):
4551 # the CA certificate (if any) in "ssl_params". Alternatively, a username and password can
4652 # be used to authenticate, for example:
4753 # client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)
48- if args .crypto_device :
49- import arduino_iot_cloud .ussl as ssl
54+ if args .basic_auth :
55+ client = ArduinoCloudClient (
56+ device_id = os .getenv ("DEVICE_ID" ),
57+ username = os .getenv ("DEVICE_ID" ),
58+ password = os .getenv ("SECRET_KEY" ),
59+ )
60+ elif args .file_auth :
61+ import ssl
62+ client = ArduinoCloudClient (
63+ device_id = os .getenv ("DEVICE_ID" ),
64+ ssl_params = {
65+ "keyfile" : "key.pem" ,
66+ "certfile" : "cert.pem" ,
67+ "ca_certs" : "ca-root.pem" ,
68+ "cert_reqs" : ssl .CERT_REQUIRED ,
69+ },
70+ )
71+ elif args .crypto_device :
72+ import ssl
5073 client = ArduinoCloudClient (
5174 device_id = os .getenv ("DEVICE_ID" ),
5275 ssl_params = {
@@ -60,11 +83,8 @@ def on_value_changed(client, value):
6083 },
6184 )
6285 else :
63- client = ArduinoCloudClient (
64- device_id = os .getenv ("DEVICE_ID" ),
65- username = os .getenv ("DEVICE_ID" ),
66- password = os .getenv ("SECRET_KEY" ),
67- )
86+ parser .print_help ()
87+ sys .exit (1 )
6888
6989 # Register cloud objects.
7090 # Note: The following objects must be created first in the dashboard and linked to the device.
0 commit comments