17
17
18
18
#include " arduino_secrets.h"
19
19
#include " ECCX08TLSConfig.h"
20
- #include < ArduinoBearSSL.h>
21
20
#include < ArduinoECCX08.h>
22
21
#include < Arduino_JSON.h>
23
22
#include < ArduinoIoTCloud.h>
@@ -80,18 +79,15 @@ void setup() {
80
79
81
80
while ( status != WL_CONNECTED) {
82
81
Serial.print (" Attempting to connect to Network named: " );
83
- Serial.println (ssid); // print the network name (SSID);
82
+ Serial.println (ssid);
84
83
85
- // Connect to WPA/WPA2 network:
86
84
status = WiFi.begin (ssid, pass);
87
- delay (5000 );
85
+ delay (10000 );
88
86
}
89
87
90
- // print the SSID of the network you're attached to:
91
88
Serial.print (" SSID: " );
92
89
Serial.println (WiFi.SSID ());
93
90
94
- // print your WiFi shield's IP address:
95
91
IPAddress ip = WiFi.localIP ();
96
92
Serial.print (" IP Address: " );
97
93
Serial.println (ip);
@@ -325,7 +321,6 @@ void ArduinoToken(String client_id, String client_secret) {
325
321
PostData += " &audience=https://api2.arduino.cc/iot" ;
326
322
327
323
if (client.connect (server, 443 )) {
328
- // Serial.println("connected to server");
329
324
client.println (" POST /iot/v1/clients/token HTTP/1.1" );
330
325
client.println (" Host: api2.arduino.cc" );
331
326
client.println (" Connection: close" );
@@ -354,7 +349,6 @@ void ArduinoToken(String client_id, String client_secret) {
354
349
int intIndex = 0 ;
355
350
while (client.available ()) {
356
351
tokenResponse[intIndex] = client.read ();
357
- // Serial.write(tokenResponse[intIndex]);
358
352
if (tokenResponse[intIndex] == -1 ) {
359
353
break ;
360
354
}
@@ -379,7 +373,6 @@ void BoardUuid(String board_name, String board_type, String board_fqbn, String b
379
373
PostData += " \" }" ;
380
374
381
375
if (client.connect (server, 443 )) {
382
- // Serial.println("connected to server");
383
376
client.println (" PUT /iot/v2/devices HTTP/1.1" );
384
377
client.println (" Host: api2.arduino.cc" );
385
378
client.println (" Connection: close" );
@@ -432,7 +425,6 @@ void ArduinoCertificate(String user_token, String DeviceUuid, String csr) {
432
425
PostData += " \" ,\" enabled\" :true}" ;
433
426
434
427
if (client.connect (server, 443 )) {
435
- // Serial.println("connected to server");
436
428
client.print (" PUT " );
437
429
client.print (url);
438
430
client.println (" HTTP/1.1" );
@@ -450,10 +442,7 @@ void ArduinoCertificate(String user_token, String DeviceUuid, String csr) {
450
442
while (!client.available ()) {
451
443
;
452
444
}
453
- // while (client.available()) {
454
- // char c = client.read();
455
- // Serial.write(c);
456
- // }
445
+
457
446
char endOfHeaders[] = " \r\n\r\n " ;
458
447
if (!client.find (endOfHeaders)) {
459
448
Serial.println (" Invalid response" );
@@ -490,4 +479,4 @@ void ArduinoCertificate(String user_token, String DeviceUuid, String csr) {
490
479
if (myCert.hasOwnProperty (" signature_asn1_y" )) {
491
480
signature += (const char *) myCert[" signature_asn1_y" ];
492
481
}
493
- }
482
+ }
0 commit comments