Skip to content

Commit 09828ad

Browse files
committed
Version 1.2.0
- Initialization timing fix that causes connection refused right after connecting to Wi-Fi mainly due to Wi-Fi client was not properly initialized. - Fixes and optimizations
1 parent 7367117 commit 09828ad

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void setup()
8686
}
8787
Serial.println();
8888
Serial.println(F("Successfully connected to WiFi!"));
89+
delay(1000); // give some time for the connection to stabilize
8990
9091
http.begin(client, "https://icanhazdadjoke.com/slack", 443);
9192
http.setTimeout(3000);
@@ -147,6 +148,7 @@ void setup()
147148
}
148149
Serial.println();
149150
Serial.println(F("Successfully connected to WiFi!"));
151+
delay(1000); // give some time for the connection to stabilize
150152

151153
StaticJsonDocument<512> doc;
152154
doc["example"] = "content";

examples/GET_request/GET_request.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ void setup()
3131
}
3232
Serial.println();
3333
Serial.println(F("Successfully connected to WiFi!"));
34+
delay(1000); // give some time for the connection to stabilize
3435

3536
http.begin(client, "https://icanhazdadjoke.com/slack", 443);
36-
http.setTimeout(3000);
37+
http.setTimeout(5000);
3738
http.addHeader("User-Agent: Arduino UNO R4 WiFi");
3839
http.addHeader("Connection: close");
3940

examples/POST_request/POST_request.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// #define R4HTTPCLIENT_DEBUG_MODE // uncomment this line to enable debugging mode
2-
31
#include "R4WiFi_secrets.h"
42
#include <R4HttpClient.h>
53
#include <ArduinoJson.h>
@@ -34,6 +32,7 @@ void setup()
3432
}
3533
Serial.println();
3634
Serial.println("Successfully connected to WiFi!");
35+
delay(1000); // give some time for the connection to stabilize
3736

3837
StaticJsonDocument<512> doc;
3938
doc["example"] = "content";
@@ -42,7 +41,7 @@ void setup()
4241
serializeJson(doc, requestBody);
4342

4443
http.begin(client, "https://example.org", 443);
45-
http.setTimeout(3000);
44+
http.setTimeout(5000);
4645
http.addHeader("User-Agent: Arduino UNO R4 WiFi");
4746
http.addHeader("Content-Type: application/json");
4847

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"maintainer": true
1414
}
1515
],
16-
"version": "1.0.4",
16+
"version": "1.2.0",
1717
"frameworks": "arduino",
1818
"platforms": [
1919
"Arduino UNO R4 Boards",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=R4HttpClient
2-
version=1.0.4
2+
version=1.2.0
33
author=Princetoniño Piscos <[email protected]>
44
maintainer=Princetoniño Piscos <[email protected]>
55
sentence=A lightweight HTTP client wrapper library for Arduino Uno R4 WiFi.

src/R4HttpClient.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class R4HttpClient
114114
String endpoint;
115115
String body;
116116
bool isDebug;
117-
WiFiSSLClient client;
117+
WiFiSSLClient *client;
118118
std::vector<String> headers;
119119

120120
void extractUrlComponents(const String &url);
@@ -129,8 +129,11 @@ class R4HttpClient
129129
R4HttpClient();
130130
~R4HttpClient();
131131

132+
void begin(const WiFiSSLClient *sslClient, const String &url);
133+
void begin(const WiFiSSLClient *sslClient, const String &url, const uint16_t &nport);
132134
void begin(const WiFiSSLClient &sslClient, const String &url);
133135
void begin(const WiFiSSLClient &sslClient, const String &url, const uint16_t &nport);
136+
134137
void addHeader(const String &content);
135138
void setTimeout(const int &ms);
136139
void setDebug(const bool &debug);

0 commit comments

Comments
 (0)