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

Commit ab3bdea

Browse files
authored
v1.3.0 to fix bug and optimize code
### Releases v1.3.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 c026535 commit ab3bdea

35 files changed

+424
-223
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-
* `ArduinoCore-mbed` Core Version (e.g. `ArduinoCore-mbed` mbed_portenta core v2.6.1)
18+
* `ArduinoCore-mbed` Core Version (e.g. `ArduinoCore-mbed` mbed_portenta core v3.1.1)
1919
* `Portenta_H7` Board type (e.g. Portenta_H7 Rev2 ABX00042, etc.)
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-
`ArduinoCore-mbed` mbed_portenta core v2.6.1
31+
`ArduinoCore-mbed` mbed_portenta core v3.1.1
3232
Portenta_H7 Rev2 ABX00042
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## Table of Contents
1212

1313
* [Changelog](#changelog)
14+
* [Releases v1.3.0](#releases-v130)
1415
* [Releases v1.2.0](#releases-v120)
1516
* [Releases v1.1.0](#releases-v110)
1617
* [Initial Releases v1.0.0](#Initial-Releases-v100)
@@ -20,6 +21,13 @@
2021

2122
## Changelog
2223

24+
### Releases v1.3.0
25+
26+
1. Fix long timeout if using `IPAddress`
27+
2. Optimize code
28+
3. Display only successful responseText in examples
29+
4. Improve debug messages by adding functions to display error messages instead of `cryptic error number`
30+
2331
### Releases v1.2.0
2432

2533
1. Reduce the breaking effect of v1.5.0 by enabling compatibility with old code to include only `Portenta_H7_AsyncHTTPRequest.h`

examples/Ethernet/AsyncCustomHeader/AsyncCustomHeader.ino

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include "defines.h"
2121

22-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.2.0"
23-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1002000
22+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.3.0"
23+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1003000
2424

2525
// Select a test server address
2626
//char GET_ServerAddress[] = "192.168.2.110/";
@@ -57,24 +57,28 @@ void sendRequest()
5757
}
5858
}
5959

60-
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
60+
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
6161
{
6262
(void) optParm;
63-
63+
6464
if (readyState == readyStateDone)
6565
{
66-
Serial.println("\n**************************************");
67-
Serial.println(request->responseText());
68-
Serial.println("**************************************");
66+
AHTTP_LOGWARN(F("\n**************************************"));
67+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
6968

70-
request->setDebug(false);
69+
if (request->responseHTTPcode() == 200)
70+
{
71+
Serial.println(F("\n**************************************"));
72+
Serial.println(request->responseText());
73+
Serial.println(F("**************************************"));
74+
}
7175
}
7276
}
7377

7478
void setup()
7579
{
7680
Serial.begin(115200);
77-
while (!Serial);
81+
while (!Serial && millis() < 5000);
7882

7983
Serial.print("\nStart AsyncCustomHeader on "); Serial.println(BOARD_NAME);
8084
Serial.println(PORTENTA_H7_ASYNC_TCP_VERSION);

examples/Ethernet/AsyncCustomHeader/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
3333
#define _PORTENTA_H7_ATCP_LOGLEVEL_ 1
34-
#define _ASYNC_HTTP_LOGLEVEL_ 1
34+
#define _ASYNC_HTTP_LOGLEVEL_ 2
3535

3636

3737
#include <Portenta_Ethernet.h>

examples/Ethernet/AsyncDweetGet/AsyncDweetGet.ino

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include "defines.h"
3232

33-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.2.0"
34-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1002000
33+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.3.0"
34+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1003000
3535

3636
// Select a test server address
3737
const char GET_ServerAddress[] = "dweet.io";
@@ -109,23 +109,34 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
109109

110110
if (readyState == readyStateDone)
111111
{
112-
String responseText = request->responseText();
113-
114-
Serial.println("\n**************************************");
115-
//Serial.println(request->responseText());
116-
Serial.println(responseText);
117-
Serial.println("**************************************");
112+
Serial.println();
113+
AHTTP_LOGWARN(F("\n**************************************"));
114+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
118115

119-
parseResponse(responseText);
116+
if (request->responseHTTPcode() == 200)
117+
{
118+
String responseText = request->responseText();
120119

121-
request->setDebug(false);
120+
Serial.println("\n**************************************");
121+
//Serial.println(request->responseText());
122+
Serial.println(responseText);
123+
Serial.println("**************************************");
124+
125+
parseResponse(responseText);
126+
127+
request->setDebug(false);
128+
}
129+
else
130+
{
131+
AHTTP_LOGERROR(F("Response error"));
132+
}
122133
}
123134
}
124135

125136
void setup()
126137
{
127138
Serial.begin(115200);
128-
while (!Serial);
139+
while (!Serial && millis() < 5000);
129140

130141
Serial.print("\nStart AsyncDweetGET on "); Serial.println(BOARD_NAME);
131142
Serial.println(PORTENTA_H7_ASYNC_TCP_VERSION);

examples/Ethernet/AsyncDweetGet/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
3333
#define _PORTENTA_H7_ATCP_LOGLEVEL_ 1
34-
#define _ASYNC_HTTP_LOGLEVEL_ 1
34+
#define _ASYNC_HTTP_LOGLEVEL_ 2
3535

3636

3737
#include <Portenta_Ethernet.h>

examples/Ethernet/AsyncDweetPost/AsyncDweetPost.ino

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
#include "defines.h"
2626

27-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.2.0"
28-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1002000
27+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.3.0"
28+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1003000
2929

3030
// Select a test server address
3131
const char POST_ServerAddress[] = "dweet.io";
@@ -107,23 +107,34 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
107107

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

117-
parseResponse(responseText);
114+
if (request->responseHTTPcode() == 200)
115+
{
116+
String responseText = request->responseText();
118117

119-
request->setDebug(false);
118+
Serial.println("\n**************************************");
119+
//Serial.println(request->responseText());
120+
Serial.println(responseText);
121+
Serial.println("**************************************");
122+
123+
parseResponse(responseText);
124+
125+
request->setDebug(false);
126+
}
127+
else
128+
{
129+
AHTTP_LOGERROR(F("Response error"));
130+
}
120131
}
121132
}
122133

123134
void setup()
124135
{
125136
Serial.begin(115200);
126-
while (!Serial);
137+
while (!Serial && millis() < 5000);
127138

128139
Serial.print("\nStart AsyncDweetPOST on "); Serial.println(BOARD_NAME);
129140
Serial.println(PORTENTA_H7_ASYNC_TCP_VERSION);

examples/Ethernet/AsyncDweetPost/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
3333
#define _PORTENTA_H7_ATCP_LOGLEVEL_ 1
34-
#define _ASYNC_HTTP_LOGLEVEL_ 1
34+
#define _ASYNC_HTTP_LOGLEVEL_ 2
3535

3636

3737
#include <Portenta_Ethernet.h>

examples/Ethernet/AsyncHTTPRequest/AsyncHTTPRequest.ino

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444
#include "defines.h"
4545

46-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.2.0"
47-
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1002000
46+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN_TARGET "Portenta_H7_AsyncHTTPRequest v1.3.0"
47+
#define PORTENTA_H7_ASYNC_HTTP_REQUEST_VERSION_MIN 1003000
4848

4949
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
5050
#include <Portenta_H7_AsyncHTTPRequest.h> // https://github.com/khoih-prog/Portenta_H7_AsyncHTTPRequest
@@ -79,24 +79,28 @@ void sendRequest()
7979
}
8080
}
8181

82-
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
82+
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
8383
{
8484
(void) optParm;
85-
86-
if (readyState == readyStateDone)
85+
86+
if (readyState == readyStateDone)
8787
{
88-
Serial.println("\n**************************************");
89-
Serial.println(request->responseText());
90-
Serial.println("**************************************");
91-
92-
request->setDebug(false);
88+
AHTTP_LOGWARN(F("\n**************************************"));
89+
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
90+
91+
if (request->responseHTTPcode() == 200)
92+
{
93+
Serial.println(F("\n**************************************"));
94+
Serial.println(request->responseText());
95+
Serial.println(F("**************************************"));
96+
}
9397
}
9498
}
9599

96100
void setup()
97101
{
98102
Serial.begin(115200);
99-
while (!Serial);
103+
while (!Serial && millis() < 5000);
100104

101105
Serial.print("\nStart AsyncHTTPRequest on "); Serial.println(BOARD_NAME);
102106
Serial.println(PORTENTA_H7_ASYNC_TCP_VERSION);

examples/Ethernet/AsyncHTTPRequest/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
3333
#define _PORTENTA_H7_ATCP_LOGLEVEL_ 1
34-
#define _ASYNC_HTTP_LOGLEVEL_ 1
34+
#define _ASYNC_HTTP_LOGLEVEL_ 2
3535

3636

3737
#include <Portenta_Ethernet.h>

0 commit comments

Comments
 (0)