1
1
/*
2
2
GSMSSLlient
3
3
4
- This sketch connects to a website (https://ifconfig.me )
4
+ This sketch connects to a website (https://example.com )
5
5
using the Portenta CAT.M1/NB IoT GNSS Shield and TLS.
6
6
7
7
*/
8
8
9
9
#include < GSM.h>
10
-
11
10
#include " arduino_secrets.h"
11
+
12
+ #if defined(ARDUINO_EDGE_CONTROL)
13
+ #include " root_ca.h"
14
+ #endif
15
+
12
16
char pin[] = SECRET_PIN;
13
17
char apn[] = SECRET_APN;
14
18
char username[] = SECRET_USERNAME;
15
19
char pass[] = SECRET_PASSWORD;
16
20
17
- const char server[] = " ifconfig.me " ;
21
+ const char server[] = " example.com " ;
18
22
const char * ip_address;
19
23
int port = 443 ;
20
24
GSMSSLClient client;
21
25
22
26
void setup () {
27
+
28
+ #if defined(ARDUINO_EDGE_CONTROL)
29
+ // Power ON MKR2
30
+ pinMode (ON_MKR2, OUTPUT);
31
+ digitalWrite (ON_MKR2, HIGH);
32
+
33
+ // Configure root certificate
34
+ client.appendCustomCACert (root_ca);
35
+ #endif
36
+
23
37
Serial.begin (115200 );
24
38
while (!Serial) {}
39
+
40
+ // To enable AT Trace debug uncomment the following lines
41
+ // GSM.trace(Serial);
42
+ // GSM.setTraceLevel(4);
43
+
25
44
Serial.println (" Starting Carrier Network registration" );
26
45
if (!GSM.begin (pin, apn, username, pass, CATM1, BAND_3 | BAND_20 | BAND_19)){
27
46
Serial.println (" The board was not able to register to the network..." );
@@ -33,7 +52,7 @@ void setup() {
33
52
if (client.connect (server, port)) {
34
53
Serial.println (" connected to server" );
35
54
// Make a HTTP request:
36
- client.println (" GET /ip HTTP/1.1" );
55
+ client.println (" GET / HTTP/1.1" );
37
56
client.print (" Host: " );
38
57
client.println (server);
39
58
client.println (" Connection: close" );
0 commit comments