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

Commit

Permalink
v1.4.0 to fix crashing bug
Browse files Browse the repository at this point in the history
### Releases v1.4.0

1. Fix crashing bug when request a non-existing IP. Check [Http GET polling causes crash when host disconnected #22](#22)
2. Modify `platform.ini` to avoid compile error with PIO when using ESP8266/ESP32
  • Loading branch information
khoih-prog authored Nov 23, 2021
1 parent d21dafe commit b5ad450
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 48 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.16) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.0 or STM32 v2.1.0)
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.1 or STM32 v2.1.0)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
Expand All @@ -27,9 +27,9 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.16
ESP32 Core Version 2.0.0
ESP32 Core Version 2.0.1
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered an endless loop while trying to connect to Local WiFi.
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ IPAddress ip(192, 168, 2, 232);

```
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest_Generic v1.3.1
AsyncHTTPRequest_Generic v1.4.0
AsyncHTTPRequest @ IP : 192.168.2.72
**************************************
Expand Down Expand Up @@ -694,7 +694,7 @@ week_number: 37

```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
AsyncHTTPRequest_Generic v1.3.1
AsyncHTTPRequest_Generic v1.4.0
Stored: SSID = HueNet1, Pass = 12345678
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
Expand Down Expand Up @@ -727,7 +727,7 @@ HHHHHH

```
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
AsyncHTTPRequest_Generic v1.3.1
AsyncHTTPRequest_Generic v1.4.0
Stored: SSID = HueNet1, Pass = 12345678
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
Expand Down Expand Up @@ -778,7 +778,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH

```
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
AsyncHTTPRequest_Generic v1.3.1
AsyncHTTPRequest_Generic v1.4.0
Connecting to WiFi SSID: HueNet1
...........
HTTP WebServer is @ IP : 192.168.2.81
Expand Down Expand Up @@ -810,7 +810,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H

```
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest_Generic v1.3.1
AsyncHTTPRequest_Generic v1.4.0
AsyncHTTPRequest @ IP : 192.168.2.72
**************************************
Expand Down Expand Up @@ -865,7 +865,7 @@ AsyncHTTPRequest @ IP : 192.168.2.72

```
Start AsyncWebClientRepeating_STM32_LAN8720 on BLACK_F407VE
AsyncHTTPRequest_Generic v1.3.1
AsyncHTTPRequest_Generic v1.4.0
AsyncHTTPRequest @ IP : 192.168.2.150
Expand Down Expand Up @@ -920,8 +920,8 @@ AsyncHTTPRequest @ IP : 192.168.2.150

```
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.2.1
AsyncHTTPRequest_Generic v1.3.1
WebServer_WT32_ETH01 v1.3.0
AsyncHTTPRequest_Generic v1.4.0
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
AsyncHTTPRequest @ IP : 192.168.2.232
Expand All @@ -946,8 +946,8 @@ H

```
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.2.1
AsyncHTTPRequest_Generic v1.3.1
WebServer_WT32_ETH01 v1.3.0
AsyncHTTPRequest_Generic v1.4.0
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
AsyncHTTPRequest @ IP : 192.168.2.232
Expand Down Expand Up @@ -1037,6 +1037,8 @@ This library is based on, modified, bug-fixed and improved from:

5. Thanks to [spdi](https://github.com/spdi) to report [**'Connection' header expects 'disconnect' instead 'close' ? #13**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/13) leading to new release v1.1.3 to fix bug.

6. Thanks to [andrewk123](https://github.com/andrewk123) to report [**Http GET polling causes crash when host disconnected #22**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/22) leading to new release v1.4.0 to fix bug.


<table>
<tr>
Expand All @@ -1045,6 +1047,7 @@ This library is based on, modified, bug-fixed and improved from:
<td align="center"><a href="https://github.com/gleniat"><img src="https://github.com/gleniat.png" width="100px;" alt="gleniat"/><br /><sub><b>gleniat</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/baddwarf"><img src="https://github.com/baddwarf.png" width="100px;" alt="baddwarf"/><br /><sub><b>BadDwarf</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/spdi"><img src="https://github.com/spdi.png" width="100px;" alt="spdi"/><br /><sub><b>spdi</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/andrewk123"><img src="https://github.com/andrewk123.png" width="100px;" alt="andrewk123"/><br /><sub><b>andrewk123</b></sub></a><br /></td>
</tr>
</table>

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v1.4.0](#releases-v140)
* [Releases v1.3.1](#releases-v131)
* [Releases v1.3.0](#releases-v130)
* [Releases v1.2.0](#releases-v120)
Expand All @@ -30,6 +31,11 @@

## Changelog

### Releases v1.4.0

1. Fix crashing bug when request a non-existing IP. Check [Http GET polling causes crash when host disconnected #22](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/22)
2. Modify `platform.ini` to avoid compile error with PIO when using ESP8266/ESP32

### Releases v1.3.1

1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"AsyncHTTPRequest_Generic",
"version": "1.3.1",
"version": "1.4.0",
"description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32-S2), WT32_ETH01 (ESP32 + LAN8720), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, wt32-eth01, ESPAsyncTCP, AsyncTCP, stm32, ethernet, wifi, lan8742a, lan8720, f407ve, nucleo, nucleo-144, stm32f7, stm32f4",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AsyncHTTPRequest_Generic
version=1.3.1
version=1.4.0
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=MIT
Expand Down
8 changes: 4 additions & 4 deletions platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ lib_deps =
me-no-dev/AsyncTCP@>=1.1.1
me-no-dev/ESPAsyncTCP@>=1.2.2
; philbowles/STM32AsyncTCP
https://github.com/khoih-prog/STM32AsyncTCP.git
stm32duino/STM32duino LwIP@>=2.1.2
stm32duino/STM32duino STM32Ethernet@>=1.2.0
; https://github.com/khoih-prog/STM32AsyncTCP.git
; stm32duino/STM32duino LwIP@>=2.1.2
; stm32duino/STM32duino STM32Ethernet@>=1.2.0
khoih-prog/ESPAsync_WiFiManager@>=1.9.3
lorol/LittleFS_esp32@>=1.0.6
khoih-prog/WebServer_WT32_ETH01@>=1.2.1
; khoih-prog/WebServer_WT32_ETH01@>=1.2.1

build_flags =
; set your debug output (default=Serial)
Expand Down
3 changes: 2 additions & 1 deletion src/AsyncHTTPRequest_Debug_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.3.1
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -33,6 +33,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
*****************************************************************************************************************************/

#pragma once
Expand Down
5 changes: 3 additions & 2 deletions src/AsyncHTTPRequest_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.3.1
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -33,14 +33,15 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
*****************************************************************************************************************************/

#pragma once

#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
#define ASYNC_HTTP_REQUEST_GENERIC_H

#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.3.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.4.0"

#include <Arduino.h>

Expand Down
34 changes: 30 additions & 4 deletions src/AsyncHTTPRequest_Impl_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.3.1
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -33,6 +33,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
*****************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -259,9 +260,13 @@ bool AsyncHTTPRequest::send(String body)
return false;
}
//////

AHTTP_LOGERROR1("01) send String body =", body);

MUTEX_LOCK(false)

AHTTP_LOGERROR1("02) send String body =", body);

_addHeader("Content-Length", String(body.length()).c_str());

if ( ! _buildRequest())
Expand All @@ -271,9 +276,15 @@ bool AsyncHTTPRequest::send(String body)
return false;
}

AHTTP_LOGERROR1("1) send String body =", body);

_request->write(body);

AHTTP_LOGERROR1("2) send String body =", body);
_send();

AHTTP_LOGERROR1("3) send String body =", body);

_AHTTP_unlock;

return true;
Expand Down Expand Up @@ -790,12 +801,27 @@ size_t AsyncHTTPRequest::_send()

AHTTP_LOGDEBUG1("_send(), _request->available =", _request->available());

#if 1
if ( ! _client->connected())
{
AHTTP_LOGDEBUG("!connected");

return 0;
}
else if ( ! _client->canSend())
{
AHTTP_LOGDEBUG("*can't send");

return 0;
}
#else
if ( ! _client->connected() || ! _client->canSend())
{
AHTTP_LOGDEBUG("*can't send");

return 0;
}
#endif

size_t supply = _request->available();
size_t demand = _client->space();
Expand Down Expand Up @@ -1009,17 +1035,17 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)

if (_readyState < readyStateOpened)
{
AHTTP_LOGDEBUG("HTTPCODE_NOT_CONNECTED");
_HTTPcode = HTTPCODE_NOT_CONNECTED;
}
else if (_HTTPcode > 0 &&
(_readyState < readyStateHdrsRecvd || (_contentRead + _response->available()) < _contentLength))
{
AHTTP_LOGDEBUG("HTTPCODE_CONNECTION_LOST");
_HTTPcode = HTTPCODE_CONNECTION_LOST;
}

SAFE_DELETE(_client)

_client = nullptr;
AHTTP_LOGDEBUG1("_HTTPcode = ", _HTTPcode);

SAFE_DELETE_ARRAY(_connectedHost)

Expand Down
3 changes: 2 additions & 1 deletion src/utility/xbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.3.1
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -33,6 +33,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
*****************************************************************************************************************************/

/********************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion src/utility/xbuf_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.3.1
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -33,6 +33,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
*****************************************************************************************************************************/

#pragma once
Expand Down
3 changes: 2 additions & 1 deletion src_cpp/AsyncHTTPRequest_Debug_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Version: 1.3.1
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -33,6 +33,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
*****************************************************************************************************************************/

#pragma once
Expand Down
Loading

0 comments on commit b5ad450

Please sign in to comment.