@@ -27,7 +27,13 @@ def on_value_changed(client, value):
27
27
"-d" , "--debug" , action = "store_true" , help = "Enable debugging messages"
28
28
)
29
29
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"
31
37
)
32
38
args = parser .parse_args ()
33
39
@@ -45,8 +51,25 @@ def on_value_changed(client, value):
45
51
# the CA certificate (if any) in "ssl_params". Alternatively, a username and password can
46
52
# be used to authenticate, for example:
47
53
# 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
50
73
client = ArduinoCloudClient (
51
74
device_id = os .getenv ("DEVICE_ID" ),
52
75
ssl_params = {
@@ -60,11 +83,8 @@ def on_value_changed(client, value):
60
83
},
61
84
)
62
85
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 )
68
88
69
89
# Register cloud objects.
70
90
# Note: The following objects must be created first in the dashboard and linked to the device.
0 commit comments