From 79f62c3f4a8d0b686fb7ac6b3e5b8c7ca269f49c Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Tue, 18 Oct 2022 22:36:53 -0400 Subject: [PATCH] v1.9.2 not to reconnect after connected ### Releases v1.9.2 1. Not try to reconnect to the same host:port after connected. Check [setReuse feature #12](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/12) 2. Update `Packages' Patches` --- CONTRIBUTING.md | 8 +- changelog.md | 6 ++ .../AsyncCustomHeader_STM32.ino | 4 +- .../AsyncDweetGet_STM32.ino | 4 +- .../AsyncDweetPost_STM32.ino | 4 +- .../AsyncHTTPMultiRequests_ESP.ino | 4 +- .../AsyncHTTPRequest_ESP.ino | 6 +- .../AsyncHTTPRequest_ESP8266_Ethernet.ino | 4 +- .../AsyncHTTPRequest_ESP_Multi.ino | 18 ++--- .../AsyncHTTPRequest_ESP_WiFiManager.ino | 8 +- .../AsyncHTTPRequest_STM32.ino | 4 +- .../AsyncSimpleGET_STM32.ino | 4 +- .../AsyncWebClientRepeating_STM32.ino | 4 +- .../AsyncHTTPMultiRequests_WT32_ETH01.ino | 4 +- .../AsyncHTTPRequest_WT32_ETH01.ino | 4 +- .../multiFileProject/multiFileProject.ino | 4 +- library.json | 9 ++- library.properties | 2 +- platformio/platformio.ini | 50 +++++++++++-- src/AsyncHTTPRequest_Debug_Generic.h | 3 +- src/AsyncHTTPRequest_Generic.h | 3 +- src/AsyncHTTPRequest_Generic.hpp | 9 ++- src/AsyncHTTPRequest_Impl_Generic.h | 74 +++++++++++-------- 23 files changed, 150 insertions(+), 90 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27711425..35016224 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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.19) or Platform.io version -* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.4 or STM32 v2.3.0) +* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.5 or STM32 v2.3.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: @@ -27,12 +27,12 @@ Please ensure to specify the following: ``` Arduino IDE version: 1.8.19 -ESP32 Core Version 2.0.4 +ESP32 Core Version 2.0.5 OS: Ubuntu 20.04 LTS -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 +Linux xy-Inspiron-3593 5.15.0-50-generic #56~20.04.1-Ubuntu SMP Tue Sep 27 15:51:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: -I encountered an endless loop while trying to connect to Local WiFi. +I encountered a crash when using this library Steps to reproduce: 1. ... diff --git a/changelog.md b/changelog.md index f0b289f6..0b26cfb1 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.9.2](#releases-v192) * [Releases v1.9.1](#releases-v191) * [Releases v1.9.0](#releases-v190) * [Releases v1.8.2](#releases-v182) @@ -41,6 +42,11 @@ ## Changelog +### Releases v1.9.2 + +1. Not try to reconnect to the same host:port after connected. Check [setReuse feature #12](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/12) +2. Update `Packages' Patches` + ### Releases v1.9.1 1. Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` diff --git a/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino b/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino index b10a5ff8..1d72e827 100644 --- a/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino +++ b/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino @@ -24,8 +24,8 @@ //char GET_ServerAddress[] = "192.168.2.110/"; char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino b/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino index 9bb2f7ae..5429b9cc 100644 --- a/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino +++ b/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino @@ -35,8 +35,8 @@ const char GET_ServerAddress[] = "dweet.io"; // use your own thing name here String dweetName = "/dweet/for/currentSecond?second="; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino b/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino index c8ae3ce3..66635189 100644 --- a/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino +++ b/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino @@ -29,8 +29,8 @@ const char POST_ServerAddress[] = "dweet.io"; // use your own thing name here String dweetName = "/dweet/for/pinA0-Read?"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino b/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino index 84d285eb..7e4bd2f5 100644 --- a/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino +++ b/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino @@ -44,8 +44,8 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // Level from 0-4 #define ASYNC_HTTP_DEBUG_PORT Serial diff --git a/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino b/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino index fdfdecdc..f3823665 100644 --- a/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino +++ b/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino @@ -46,7 +46,7 @@ // Level from 0-4 #define ASYNC_HTTP_DEBUG_PORT Serial -#define _ASYNC_HTTP_LOGLEVEL_ 1 +#define _ASYNC_HTTP_LOGLEVEL_ 3 // 300s = 5 minutes to not flooding #define HTTP_REQUEST_INTERVAL 60 //300 @@ -65,8 +65,8 @@ const char* password = "your_pass"; #include #endif -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino b/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino index fcd6702e..3fe3e692 100644 --- a/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino +++ b/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino @@ -95,8 +95,8 @@ using TCPClient = WiFiClient; ////////////////////////////////////////////////////////// -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino b/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino index 19c11448..815d9b32 100644 --- a/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino +++ b/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino @@ -139,15 +139,14 @@ void sendRequests() reqCount[1] = NUM_ENTRIES_SITE_1; } - void requestCB0(void* optParm, AsyncHTTPRequest* thisRequest, int readyState) { (void) optParm; if (readyState == readyStateDone) { - AHTTP_LOGERROR(F("\n**************************************")); - AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString()); + AHTTP_LOGWARN(F("\n**************************************")); + AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString()); if (request->responseHTTPcode() == 200) { @@ -171,8 +170,8 @@ void requestCB1(void* optParm, AsyncHTTPRequest* thisRequest, int readyState) if (readyState == readyStateDone) { - AHTTP_LOGERROR(F("\n**************************************")); - AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString()); + AHTTP_LOGWARN(F("\n**************************************")); + AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString()); if (request->responseHTTPcode() == 200) { @@ -207,7 +206,7 @@ void setup() while (WiFi.status() != WL_CONNECTED) { - delay(500); + delay(1000); Serial.print("."); } @@ -231,12 +230,11 @@ void loop() for (int index = 0; index < NUM_DIFFERENT_SITES; index++) { if ((reqCount[index] > 0) && readySend[index]) - // OK but have to use delay(100) - //if ( reqCount[index] > 0 ) { sendRequestCB[index](); - - //delay(100); + + // Don't send too fast + delay(1000); } } } diff --git a/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino b/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino index ac5340e6..5e7991d2 100644 --- a/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino +++ b/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino @@ -46,11 +46,11 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // Level from 0-4 #define ASYNC_HTTP_DEBUG_PORT Serial diff --git a/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino b/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino index 28c18f4e..6e070d69 100644 --- a/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino +++ b/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino @@ -42,8 +42,8 @@ #include "defines.h" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino b/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino index 1b957f99..1c3bc71f 100644 --- a/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino +++ b/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino @@ -24,8 +24,8 @@ //char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/"; char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino b/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino index 370d0752..da4cf3ec 100644 --- a/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino +++ b/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino @@ -26,8 +26,8 @@ const char GET_ServerAddress[] = "arduino.tips"; // GET location String GET_Location = "/asciilogo.txt"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino b/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino index 973fd587..2fb494eb 100644 --- a/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino +++ b/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino @@ -57,8 +57,8 @@ #include // https://github.com/khoih-prog/WebServer_WT32_ETH01 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino b/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino index e96c71f8..c011a93c 100644 --- a/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino +++ b/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino @@ -57,8 +57,8 @@ #include // https://github.com/khoih-prog/WebServer_WT32_ETH01 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/multiFileProject/multiFileProject.ino b/examples/multiFileProject/multiFileProject.ino index 9eb77b69..85b77a17 100644 --- a/examples/multiFileProject/multiFileProject.ino +++ b/examples/multiFileProject/multiFileProject.ino @@ -19,8 +19,8 @@ #error This code is intended to run on the ESP8266, ESP32 or STM32 platform! Please check your Tools->Board setting. #endif -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #include "multiFileProject.h" diff --git a/library.json b/library.json index af74190d..8f7b8ab1 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name":"AsyncHTTPRequest_Generic", - "version": "1.9.1", + "version": "1.9.2", "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, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP8266 (WiFi, W5x00 or ENC28J60) and currently STM32 with built-in LAN8742A Ethernet.", "keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, wt32-eth01, stm32, ethernet, wifi, lan8742a, nucleo-144, stm32f7, W5x00, ENC28J60", "authors": [ @@ -45,7 +45,7 @@ { "owner": "khoih-prog", "name": "ESPAsync_WiFiManager", - "version": ">=1.14.0", + "version": ">=1.15.0", "platforms": ["espressif8266", "espressif32"] }, { @@ -63,12 +63,13 @@ { "owner": "khoih-prog", "name": "WebServer_WT32_ETH01", - "version": ">=1.5.0", + "version": ">=1.5.1", "platforms": ["espressif32"] }, { "name": "STM32AsyncTCP", - "version": "https://github.com/khoih-prog/STM32AsyncTCP" + "version": "https://github.com/khoih-prog/STM32AsyncTCP", + "platforms": "ststm32" } ], "license": "LGPL-3.0", diff --git a/library.properties b/library.properties index 905372cb..dbbaa2c0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AsyncHTTPRequest_Generic -version=1.9.1 +version=1.9.2 author=Bob Lemaire,Khoi Hoang maintainer=Khoi Hoang license=GPLv3 diff --git a/platformio/platformio.ini b/platformio/platformio.ini index 8238c308..c4d355d7 100644 --- a/platformio/platformio.ini +++ b/platformio/platformio.ini @@ -45,20 +45,20 @@ lib_deps = ; https://github.com/khoih-prog/STM32AsyncTCP.git ; STM32duino LwIP@>=2.1.2 ; STM32duino STM32Ethernet@>=1.3.0 -; ESPAsync_WiFiManager@>=1.14.0 +; ESPAsync_WiFiManager@>=1.15.0 ; LittleFS_esp32@>=1.0.6 -; WebServer_WT32_ETH01@>=1.5.0 - +; WebServer_WT32_ETH01@>=1.5.1 +; ; PlatformIO 5.x - me-no-dev/AsyncTCP@>=1.1.1 - me-no-dev/ESPAsyncTCP@>=1.2.2 +; 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.3.0 - khoih-prog/ESPAsync_WiFiManager@>=1.14.0 +; khoih-prog/ESPAsync_WiFiManager@>=1.15.0 ; lorol/LittleFS_esp32@>=1.0.6 -; khoih-prog/WebServer_WT32_ETH01@>=1.5.0 +; khoih-prog/WebServer_WT32_ETH01@>=1.5.1 build_flags = ; set your debug output (default=Serial) @@ -69,6 +69,16 @@ build_flags = [env:ESP8266] platform = espressif8266 framework = arduino + +lib_deps = +; PlatformIO 4.x +; ESPAsyncTCP@>=1.2.2 +; ESPAsync_WiFiManager@>=1.15.0 +; +; PlatformIO 5.x + me-no-dev/ESPAsyncTCP@>=1.2.2 + khoih-prog/ESPAsync_WiFiManager@>=1.15.0 + ; ============================================================ ; Board configuration ; choose your board by uncommenting one of the following lines @@ -114,6 +124,20 @@ board = nodemcuv2 [env:ESP32] platform = espressif32 framework = arduino + +lib_deps = +; PlatformIO 4.x +; AsyncTCP@>=1.1.1 +; ESPAsync_WiFiManager@>=1.15.0 +; LittleFS_esp32@>=1.0.6 +; WebServer_WT32_ETH01@>=1.5.1 +; +; PlatformIO 5.x + me-no-dev/AsyncTCP@>=1.1.1 + khoih-prog/ESPAsync_WiFiManager@>=1.15.0 +; lorol/LittleFS_esp32@>=1.0.6 + khoih-prog/WebServer_WT32_ETH01@>=1.5.1 + ; ============================================================ ; Board configuration ; choose your board by uncommenting one of the following lines @@ -250,6 +274,18 @@ board = feather52840 platform = ststm32 framework = arduino +lib_deps = +; PlatformIO 4.x +; https://github.com/khoih-prog/STM32AsyncTCP.git +; STM32duino LwIP@>=2.1.2 +; STM32duino STM32Ethernet@>=1.3.0 +; +; PlatformIO 5.x + philbowles/STM32AsyncTCP + https://github.com/khoih-prog/STM32AsyncTCP.git + stm32duino/STM32duino LwIP@>=2.1.2 + stm32duino/STM32duino STM32Ethernet@>=1.3.0 + ; ============================================================ ; Choose your board by uncommenting one of the following lines ; ============================================================ diff --git a/src/AsyncHTTPRequest_Debug_Generic.h b/src/AsyncHTTPRequest_Debug_Generic.h index 08bddd79..af25dd85 100644 --- a/src/AsyncHTTPRequest_Debug_Generic.h +++ b/src/AsyncHTTPRequest_Debug_Generic.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.9.1 + Version: 1.9.2 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -31,6 +31,7 @@ 1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` + 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected *****************************************************************************************************************************/ #pragma once diff --git a/src/AsyncHTTPRequest_Generic.h b/src/AsyncHTTPRequest_Generic.h index 7829d5aa..5cf57f18 100644 --- a/src/AsyncHTTPRequest_Generic.h +++ b/src/AsyncHTTPRequest_Generic.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.9.1 + Version: 1.9.2 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -31,6 +31,7 @@ 1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` + 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected *****************************************************************************************************************************/ #pragma once diff --git a/src/AsyncHTTPRequest_Generic.hpp b/src/AsyncHTTPRequest_Generic.hpp index ee6a5aba..40200bd8 100644 --- a/src/AsyncHTTPRequest_Generic.hpp +++ b/src/AsyncHTTPRequest_Generic.hpp @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.9.1 + Version: 1.9.2 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -31,6 +31,7 @@ 1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` + 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected *****************************************************************************************************************************/ #pragma once @@ -38,13 +39,13 @@ #ifndef ASYNC_HTTP_REQUEST_GENERIC_HPP #define ASYNC_HTTP_REQUEST_GENERIC_HPP -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.9.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 9 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 1 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 2 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1009001 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1009002 #include diff --git a/src/AsyncHTTPRequest_Impl_Generic.h b/src/AsyncHTTPRequest_Impl_Generic.h index 9fb233ea..597b1cc7 100644 --- a/src/AsyncHTTPRequest_Impl_Generic.h +++ b/src/AsyncHTTPRequest_Impl_Generic.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.9.1 + Version: 1.9.2 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -31,6 +31,7 @@ 1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` + 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected *****************************************************************************************************************************/ #pragma once @@ -305,7 +306,7 @@ String xbuf::readString(int endPos) if ( ! result.reserve(endPos + 1)) { // KH, to remove - //AHTTP_LOGERROR1(F("xbuf::readString: can't reserve size ="), endPos + 1); + //AHTTP_LOGDEBUG1(F("xbuf::readString: can't reserve size ="), endPos + 1); /////// return result; @@ -388,7 +389,7 @@ void xbuf::addSeg() if (_tail->next == NULL) { - AHTTP_LOGERROR(F("xbuf::addSeg: error new 1")); + AHTTP_LOGDEBUG(F("xbuf::addSeg: error new 1")); } else { @@ -402,7 +403,7 @@ void xbuf::addSeg() _tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1]; if (_tail == NULL) - AHTTP_LOGERROR(F("xbuf::addSeg: error new 2")); + AHTTP_LOGDEBUG(F("xbuf::addSeg: error new 2")); } // KH, Must check NULL here @@ -493,7 +494,7 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL) if (_readyState != readyStateUnsent && _readyState != readyStateDone) { - AHTTP_LOGERROR(F("open: not ready")); + AHTTP_LOGWARN(F("open: not ready")); return false; } @@ -559,12 +560,25 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL) return false; } - - if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort)) + + if ( _client && _client->connected() ) { - AHTTP_LOGERROR(F("open: not connected")); + if ( (strcmp(_URL->host, _connectedHost) == 0) && (_URL->port == _connectedPort) ) + { + AHTTP_LOGINFO(F("open: already connected")); + + _lastActivity = millis(); - return false; + _requestReadyToSend = true; + + return _connect(); + } + else + { + AHTTP_LOGINFO(F("open: not connected: different host or port")); + + return false; + } } char* hostName = new char[strlen(_URL->host) + 10]; @@ -609,7 +623,7 @@ void AsyncHTTPRequest::setTimeout(int seconds) } //************************************************************************************************************** -bool AsyncHTTPRequest::send() +bool AsyncHTTPRequest::send() { // New in v1.1.1 if (_requestReadyToSend) @@ -618,7 +632,8 @@ bool AsyncHTTPRequest::send() } else { - AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST); + AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST); + return false; } ////// @@ -645,16 +660,17 @@ bool AsyncHTTPRequest::send(const String& body) } else { - AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST); + AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST); + return false; } ////// - AHTTP_LOGERROR1(F("01) send String body ="), body); + AHTTP_LOGDEBUG1(F("01) send String body ="), body); MUTEX_LOCK(false) - AHTTP_LOGERROR1(F("02) send String body ="), body); + AHTTP_LOGDEBUG1(F("02) send String body ="), body); _addHeader("Content-Length", String(body.length()).c_str()); @@ -665,14 +681,14 @@ bool AsyncHTTPRequest::send(const String& body) return false; } - AHTTP_LOGERROR1(F("1) send String body ="), body); + AHTTP_LOGDEBUG1(F("1) send String body ="), body); _request->write(body); - AHTTP_LOGERROR1(F("2) send String body ="), body); + AHTTP_LOGDEBUG1(F("2) send String body ="), body); _send(); - AHTTP_LOGERROR1(F("3) send String body ="), body); + AHTTP_LOGDEBUG1(F("3) send String body ="), body); _AHTTP_unlock; @@ -689,7 +705,7 @@ bool AsyncHTTPRequest::send(const char* body) } else { - AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST); + AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST); return false; } ////// @@ -723,7 +739,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len) } else { - AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST); + AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST); return false; } ////// @@ -757,7 +773,8 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len) } else { - AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST); + AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST); + return false; } ////// @@ -893,7 +910,7 @@ String AsyncHTTPRequest::responseText() if ( ! _response || _readyState < readyStateLoading || ! available()) { - AHTTP_LOGERROR(F("responseText() no data")); + AHTTP_LOGWARN(F("responseText() no data")); _AHTTP_unlock; @@ -906,7 +923,7 @@ String AsyncHTTPRequest::responseText() if (localString.length() < avail) { - AHTTP_LOGERROR(F("!responseText() no buffer")) + AHTTP_LOGWARN(F("!responseText() no buffer")) _HTTPcode = HTTPCODE_TOO_LESS_RAM; _client->abort(); _AHTTP_unlock; @@ -943,7 +960,7 @@ char* AsyncHTTPRequest::responseLongText() if ( ! _response || _readyState < readyStateLoading || ! available()) { - AHTTP_LOGERROR(F("responseText() no data")); + AHTTP_LOGWARN(F("responseText() no data")); _AHTTP_unlock; @@ -972,7 +989,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len) { if ( ! _response || _readyState < readyStateLoading || ! available()) { - AHTTP_LOGERROR(F("responseRead() no data")); + AHTTP_LOGWARN(F("responseRead() no data")); return 0; } @@ -1179,7 +1196,7 @@ bool AsyncHTTPRequest::_connect() if ( ! _client->connected()) { - AHTTP_LOGDEBUG3(F("_client->connecting to"), _URL->host, F(","), _URL->port); + AHTTP_LOGINFO3(F("_client->connecting to"), _URL->host, F(","), _URL->port); if ( ! _client->connect(_URL->host, _URL->port)) { @@ -1192,7 +1209,7 @@ bool AsyncHTTPRequest::_connect() } else { - AHTTP_LOGDEBUG3(F("client.connect OK to"), _URL->host, F(","), _URL->port); + AHTTP_LOGINFO3(F("client.connect OK to"), _URL->host, F(","), _URL->port); } } else @@ -1418,7 +1435,7 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client) _AHTTP_unlock; // KH, to remove - //AHTTP_LOGERROR(F("_onConnect: Can't new _response")); + //AHTTP_LOGWARN(F("_onConnect: Can't new _response")); /////// return; @@ -1482,7 +1499,6 @@ void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error) { (void) client; - //AHTTP_LOGERROR1(F("_onError handler error ="), error); AHTTP_LOGERROR1(F("_onError handler error ="), client->errorToString(error)); _HTTPcode = error; @@ -1558,7 +1574,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len) _AHTTP_unlock; // KH, to remove - //AHTTP_LOGERROR(F("_onData: headers not complete")); + //AHTTP_LOGWARN(F("_onData: headers not complete")); /////// return;