@@ -40,22 +40,22 @@ void loop() {
40
40
41
41
HTTPClient http;
42
42
43
- BearSSL::WiFiClientSecure client;
43
+ BearSSL::WiFiClientSecure * client = new BearSSL::WiFiClientSecure ;
44
44
45
- bool mfln = client. probeMaxFragmentLength (" tls.mbed.org" , 443 , 1024 );
45
+ bool mfln = client-> probeMaxFragmentLength (" tls.mbed.org" , 443 , 1024 );
46
46
Serial.printf (" \n Connecting to https://tls.mbed.org\n " );
47
47
Serial.printf (" Maximum fragment Length negotiation supported: %s\n " , mfln ? " yes" : " no" );
48
48
if (mfln) {
49
- client. setBufferSizes (1024 , 1024 );
49
+ client-> setBufferSizes (1024 , 1024 );
50
50
}
51
51
52
52
Serial.print (" [HTTPS] begin...\n " );
53
53
54
54
// configure server and url
55
55
const uint8_t fingerprint[20 ] = {0xEB , 0xD9 , 0xDF , 0x37 , 0xC2 , 0xCC , 0x84 , 0x89 , 0x00 , 0xA0 , 0x58 , 0x52 , 0x24 , 0x04 , 0xE4 , 0x37 , 0x3E , 0x2B , 0xF1 , 0x41 };
56
- client. setFingerprint (fingerprint);
56
+ client-> setFingerprint (fingerprint);
57
57
58
- if (http.begin (client, " https://tls.mbed.org/" )) {
58
+ if (http.begin (* client, " https://tls.mbed.org/" )) {
59
59
60
60
Serial.print (" [HTTPS] GET...\n " );
61
61
// start connection and send HTTP header
@@ -74,7 +74,7 @@ void loop() {
74
74
static uint8_t buff[128 ] = { 0 };
75
75
76
76
// get tcp stream
77
- WiFiClient * stream = & client;
77
+ WiFiClient * stream = client;
78
78
79
79
// read all data from server
80
80
while (http.connected () && (len > 0 || len == -1 )) {
@@ -107,6 +107,8 @@ void loop() {
107
107
} else {
108
108
Serial.printf (" Unable to connect\n " );
109
109
}
110
+
111
+ delete client;
110
112
}
111
113
112
114
delay (10000 );
0 commit comments