Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit f3d2a0a

Browse files
authored
v1.1.0 to fix bug and optimize code
### Release v1.1.0 1. Fix long timeout if using `IPAddress`. 2. Optimize code 3. Display only successful `responseText` in examples 4. Improve debug messages by adding functions to display error messages instead of `cryptic error number`
1 parent dfc9a04 commit f3d2a0a

File tree

16 files changed

+554
-410
lines changed

16 files changed

+554
-410
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* `RP2040` Core Version (e.g. RP2040 core v2.4.0)
18+
* `RP2040` Core Version (e.g. RP2040 core v2.5.0)
1919
* `RP2040` Board type (e.g. RASPBERRY_PI_PICO_W)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -28,10 +28,10 @@ Please ensure to specify the following:
2828

2929
```
3030
Arduino IDE version: 1.8.19
31-
RP2040 core v2.4.0
31+
RP2040 core v2.5.0
3232
RASPBERRY_PI_PICO_W Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
3737
I encountered an endless loop while trying to connect to Local WiFi.
@@ -52,3 +52,4 @@ There are usually some outstanding feature requests in the [existing issues list
5252
### Sending Pull Requests
5353

5454
Pull Requests with changes and fixes are also welcome!
55+

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## Table of Contents
1212

1313
* [Changelog](#changelog)
14+
* [Release v1.1.0](#Release-v110)
1415
* [Release v1.0.1](#Release-v101)
1516
* [Initial Release v1.0.0](#Initial-Release-v100)
1617

@@ -19,6 +20,14 @@
1920

2021
## Changelog
2122

23+
### Release v1.1.0
24+
25+
1. Fix long timeout if using `IPAddress`.
26+
2. Optimize code
27+
3. Display only successful responseText in examples
28+
4. Improve debug messages by adding functions to display error messages instead of `cryptic error number`
29+
30+
2231
### Release v1.0.1
2332

2433
1. Fix bug in examples

examples/AsyncCustomHeader/AsyncCustomHeader.ino

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818

1919
#include "defines.h"
2020

21-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
22-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
21+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
22+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
23+
24+
// Level from 0-4
25+
#define ASYNC_HTTP_DEBUG_PORT Serial
26+
#define _ASYNC_HTTP_LOGLEVEL_ 2
2327

2428
// Select a test server address
2529
//char GET_ServerAddress[] = "192.168.2.110/";
@@ -58,17 +62,21 @@ void sendRequest()
5862
}
5963
}
6064

61-
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
65+
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
6266
{
6367
(void) optParm;
64-
68+
6569
if (readyState == readyStateDone)
6670
{
67-
Serial.println("\n**************************************");
68-
Serial.println(request->responseText());
69-
Serial.println("**************************************");
71+
AHTTP_LOGWARN(F("\n**************************************"));
72+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
7073

71-
request->setDebug(false);
74+
if (request->responseHTTPcode() == 200)
75+
{
76+
Serial.println(F("\n**************************************"));
77+
Serial.println(request->responseText());
78+
Serial.println(F("**************************************"));
79+
}
7280
}
7381
}
7482

@@ -87,7 +95,7 @@ void printWifiStatus()
8795
void setup()
8896
{
8997
Serial.begin(115200);
90-
while (!Serial);
98+
while (!Serial && millis() < 5000);
9199

92100
Serial.print("\nStart AsyncCustomHeader on "); Serial.println(BOARD_NAME);
93101
Serial.println(ASYNCTCP_RP2040W_VERSION);

examples/AsyncDweetGet/AsyncDweetGet.ino

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727

2828
#include "defines.h"
2929

30-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
31-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
30+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
31+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
32+
33+
// Level from 0-4
34+
#define ASYNC_HTTP_DEBUG_PORT Serial
35+
#define _ASYNC_HTTP_LOGLEVEL_ 2
3236

3337
// Select a test server address
3438
const char GET_ServerAddress[] = "dweet.io";
@@ -107,14 +111,19 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
107111

108112
if (readyState == readyStateDone)
109113
{
110-
String responseText = request->responseText();
111-
112-
Serial.println("\n**************************************");
113-
//Serial.println(request->responseText());
114-
Serial.println(responseText);
115-
Serial.println("**************************************");
114+
AHTTP_LOGWARN(F("\n**************************************"));
115+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
116116

117-
parseResponse(responseText);
117+
if (request->responseHTTPcode() == 200)
118+
{
119+
String responseText = request->responseText();
120+
121+
Serial.println("\n**************************************");
122+
Serial.println(responseText);
123+
Serial.println("**************************************");
124+
125+
parseResponse(responseText);
126+
}
118127

119128
request->setDebug(false);
120129
}
@@ -135,7 +144,7 @@ void printWifiStatus()
135144
void setup()
136145
{
137146
Serial.begin(115200);
138-
while (!Serial);
147+
while (!Serial && millis() < 5000);
139148

140149
Serial.print("\nStart AsyncDweetGET on "); Serial.println(BOARD_NAME);
141150
Serial.println(ASYNCTCP_RP2040W_VERSION);

examples/AsyncDweetPost/AsyncDweetPost.ino

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121

2222
#include "defines.h"
2323

24-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
25-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
24+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
25+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
26+
27+
// Level from 0-4
28+
#define ASYNC_HTTP_DEBUG_PORT Serial
29+
#define _ASYNC_HTTP_LOGLEVEL_ 2
2630

2731
// Select a test server address
2832
const char POST_ServerAddress[] = "dweet.io";
@@ -106,14 +110,19 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
106110

107111
if (readyState == readyStateDone)
108112
{
109-
String responseText = request->responseText();
110-
111-
Serial.println("\n**************************************");
112-
//Serial.println(request->responseText());
113-
Serial.println(responseText);
114-
Serial.println("**************************************");
113+
AHTTP_LOGWARN(F("\n**************************************"));
114+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
115115

116-
parseResponse(responseText);
116+
if (request->responseHTTPcode() == 200)
117+
{
118+
String responseText = request->responseText();
119+
120+
Serial.println("\n**************************************");
121+
Serial.println(responseText);
122+
Serial.println("**************************************");
123+
124+
parseResponse(responseText);
125+
}
117126

118127
request->setDebug(false);
119128
}
@@ -134,7 +143,7 @@ void printWifiStatus()
134143
void setup()
135144
{
136145
Serial.begin(115200);
137-
while (!Serial);
146+
while (!Serial && millis() < 5000);
138147

139148
Serial.print("\nStart AsyncDweetPOST on "); Serial.println(BOARD_NAME);
140149
Serial.println(ASYNCTCP_RP2040W_VERSION);

examples/AsyncHTTPRequest/AsyncHTTPRequest.ino

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@
4040

4141
#include "defines.h"
4242

43-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
44-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
43+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
44+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
45+
46+
// Level from 0-4
47+
#define ASYNC_HTTP_DEBUG_PORT Serial
48+
#define _ASYNC_HTTP_LOGLEVEL_ 2
4549

4650
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
4751
#include <AsyncHTTPRequest_RP2040W.h> // https://github.com/khoih-prog/AsyncHTTPRequest_RP2040W
@@ -78,17 +82,21 @@ void sendRequest()
7882
}
7983
}
8084

81-
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
85+
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
8286
{
8387
(void) optParm;
84-
85-
if (readyState == readyStateDone)
88+
89+
if (readyState == readyStateDone)
8690
{
87-
Serial.println("\n**************************************");
88-
Serial.println(request->responseText());
89-
Serial.println("**************************************");
90-
91-
request->setDebug(false);
91+
AHTTP_LOGWARN(F("\n**************************************"));
92+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
93+
94+
if (request->responseHTTPcode() == 200)
95+
{
96+
Serial.println(F("\n**************************************"));
97+
Serial.println(request->responseText());
98+
Serial.println(F("**************************************"));
99+
}
92100
}
93101
}
94102

examples/AsyncSimpleGET/AsyncSimpleGET.ino

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818

1919
#include "defines.h"
2020

21-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
22-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
21+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
22+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
23+
24+
// Level from 0-4
25+
#define ASYNC_HTTP_DEBUG_PORT Serial
26+
#define _ASYNC_HTTP_LOGLEVEL_ 2
2327

2428
// Select a test server address
2529
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
@@ -56,17 +60,21 @@ void sendRequest()
5660
}
5761
}
5862

59-
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
63+
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
6064
{
6165
(void) optParm;
62-
66+
6367
if (readyState == readyStateDone)
6468
{
65-
Serial.println("\n**************************************");
66-
Serial.println(request->responseText());
67-
Serial.println("**************************************");
69+
AHTTP_LOGWARN(F("\n**************************************"));
70+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
6871

69-
request->setDebug(false);
72+
if (request->responseHTTPcode() == 200)
73+
{
74+
Serial.println(F("\n**************************************"));
75+
Serial.println(request->responseText());
76+
Serial.println(F("**************************************"));
77+
}
7078
}
7179
}
7280

@@ -85,7 +93,7 @@ void printWifiStatus()
8593
void setup()
8694
{
8795
Serial.begin(115200);
88-
while (!Serial);
96+
while (!Serial && millis() < 5000);
8997

9098
Serial.print("\nStart AsyncSimpleGET on "); Serial.println(BOARD_NAME);
9199
Serial.println(ASYNCTCP_RP2040W_VERSION);

examples/AsyncWebClientRepeating/AsyncWebClientRepeating.ino

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818

1919
#include "defines.h"
2020

21-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
22-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
21+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
22+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
23+
24+
// Level from 0-4
25+
#define ASYNC_HTTP_DEBUG_PORT Serial
26+
#define _ASYNC_HTTP_LOGLEVEL_ 2
2327

2428
// Select a test server address
2529
const char GET_ServerAddress[] = "arduino.tips";
@@ -58,17 +62,21 @@ void sendRequest()
5862
}
5963
}
6064

61-
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
65+
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
6266
{
6367
(void) optParm;
64-
68+
6569
if (readyState == readyStateDone)
66-
{
67-
Serial.println("\n**************************************");
68-
Serial.println(request->responseText());
69-
Serial.println("**************************************");
70-
71-
request->setDebug(false);
70+
{
71+
AHTTP_LOGWARN(F("\n**************************************"));
72+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
73+
74+
if (request->responseHTTPcode() == 200)
75+
{
76+
Serial.println(F("\n**************************************"));
77+
Serial.println(request->responseText());
78+
Serial.println(F("**************************************"));
79+
}
7280
}
7381
}
7482

@@ -87,7 +95,7 @@ void printWifiStatus()
8795
void setup()
8896
{
8997
Serial.begin(115200);
90-
while (!Serial);
98+
while (!Serial && millis() < 5000);
9199

92100
Serial.print("\nStart AsyncWebClientRepeating on "); Serial.println(BOARD_NAME);
93101
Serial.println(ASYNCTCP_RP2040W_VERSION);

examples/multiFileProject/multiFileProject.ino

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
#error For RASPBERRY_PI_PICO_W only
1616
#endif
1717

18-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.0.0"
19-
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1000000
18+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN_TARGET "AsyncHTTPRequest_RP2040W v1.1.0"
19+
#define ASYNC_HTTP_REQUEST_RP2040W_VERSION_MIN 1001000
20+
21+
// Level from 0-4
22+
#define ASYNC_HTTP_DEBUG_PORT Serial
23+
#define _ASYNC_HTTP_LOGLEVEL_ 2
2024

2125
#include "multiFileProject.h"
2226

@@ -26,7 +30,7 @@
2630
void setup()
2731
{
2832
Serial.begin(115200);
29-
while (!Serial);
33+
while (!Serial && millis() < 5000);
3034

3135
Serial.println("\nStart multiFileProject");
3236
Serial.println(ASYNC_HTTP_REQUEST_RP2040W_VERSION);

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ onData KEYWORD2
3131
available KEYWORD2
3232
responseLength KEYWORD2
3333
responseHTTPcode KEYWORD2
34+
responseHTTPString KEYWORD2
3435
responseRead KEYWORD2
3536
elapsedTime KEYWORD2
3637
version KEYWORD2

0 commit comments

Comments
 (0)