v1.9.0 to fix bug and optimize code

### Releases v1.9.0

1. Fix long timeout if using `IPAddress`. Check [setTimeout() hasn't any effect #38](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/38)
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`
5. Remove support to STM32 using **LAN8720** due to problem with new STM32 core v2.3.0
5. Update `Packages' Patches`
This commit is contained in:
Khoi Hoang
2022-08-30 22:59:23 -04:00
committed by GitHub
parent dabf181406
commit 07e2add996
25 changed files with 524 additions and 438 deletions

View File

@ -29,7 +29,7 @@ Please ensure to specify the following:
Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.4
OS: Ubuntu 20.04 LTS
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
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
Context:
I encountered an endless loop while trying to connect to Local WiFi.

157
README.md
View File

@ -56,13 +56,6 @@
* [4. AsyncDweetPost_STM32](examples/AsyncDweetPost_STM32)
* [5. AsyncSimpleGET_STM32](examples/AsyncSimpleGET_STM32)
* [6. AsyncWebClientRepeating_STM32](examples/AsyncWebClientRepeating_STM32)
* [For STM32 using LAN8720](#for-stm32-using-lan8720)
* [1. AsyncHTTPRequest_STM32_LAN8720](examples/STM32_LAN8720/AsyncHTTPRequest_STM32_LAN8720)
* [2. AsyncCustomHeader_STM32_LAN8720](examples/STM32_LAN8720/AsyncCustomHeader_STM32_LAN8720)
* [3. AsyncDweetGet_STM32_LAN8720](examples/STM32_LAN8720/AsyncDweetGet_STM32_LAN8720)
* [4. AsyncDweetPost_STM32_LAN8720](examples/STM32_LAN8720/AsyncDweetPost_STM32_LAN8720)
* [5. AsyncSimpleGET_STM32_LAN8720](examples/STM32_LAN8720/AsyncSimpleGET_STM32_LAN8720)
* [6. AsyncWebClientRepeating_STM32_LAN8720](examples/STM32_LAN8720/AsyncWebClientRepeating_STM32_LAN8720)
* [For WT32_ETH01](#for-wt32_eth01)
* [1. AsyncHTTPRequest_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01)
* [2. AsyncHTTPMultiRequests_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01)
@ -77,14 +70,12 @@
* [3. AsyncHTTPRequest_ESP_WiFiManager running on ESP32_DEV](#3-asynchttprequest_esp_wifimanager-running-on-esp32_dev)
* [4. AsyncHTTPRequest_ESP running on ESP8266_NODEMCU](#4-asynchttprequest_esp-running-on-esp8266_nodemcu)
* [5. AsyncWebClientRepeating_STM32 running on STM32F7 Nucleo-144 NUCLEO_F767ZI using built-in LAN8742A](#5-asyncwebclientrepeating_stm32-running-on-stm32f7-nucleo-144-nucleo_f767zi-using-built-in-lan8742a)
* [6. AsyncWebClientRepeating_STM32_LAN8720 running on STM32F4 BLACK_F407VE using LAN8720](#6-asyncwebclientrepeating_stm32_lan8720-running-on-stm32f4-black_f407ve-using-lan8720)
* [7. AsyncHTTPMultiRequests_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720](#7-asynchttpmultirequests_wt32_eth01-on-esp32_dev-with-eth_phy_lan8720)
* [8. AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720](#8-asynchttprequest_wt32_eth01-on-esp32_dev-with-eth_phy_lan8720)
* [9. AsyncHTTPRequest_ESP_WiFiManager running on ESP32C3_DEV](#9-asynchttprequest_esp_wifimanager-running-on-ESP32C3_DEV) **New**
* [10. AsyncHTTPRequest_ESP_WiFiManager running on ESP32S3_DEV](#10-asynchttprequest_esp_wifimanager-running-on-ESP32S3_DEV) **New**
* [11. AsyncHTTPRequest_ESP_Multi running on ESP32_DEV](#11-AsyncHTTPRequest_ESP_Multi-running-on-ESP32_DEV) **New**
* [12. AsyncHTTPRequest_ESP8266_Ethernet running on ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet](#12-AsyncHTTPRequest_ESP8266_Ethernet-running-on-ESP8266_NODEMCU_ESP12E-using-ESP8266_W5500-Ethernet) **New**
* [13. AsyncHTTPRequest_ESP8266_Ethernet running on ESP8266_NODEMCU_ESP12E using ESP8266_ENC28J60 Ethernet](#13-AsyncHTTPRequest_ESP8266_Ethernet-running-on-ESP8266_NODEMCU_ESP12E-using-ESP8266_ENC28J60-Ethernet) **New**
* [6. AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720](#6-asynchttprequest_wt32_eth01-on-esp32_dev-with-eth_phy_lan8720)
* [7. AsyncHTTPRequest_ESP_WiFiManager running on ESP32C3_DEV](#7-asynchttprequest_esp_wifimanager-running-on-ESP32C3_DEV) **New**
* [8. AsyncHTTPRequest_ESP_WiFiManager running on ESP32S3_DEV](#8-asynchttprequest_esp_wifimanager-running-on-ESP32S3_DEV) **New**
* [9. AsyncHTTPRequest_ESP_Multi running on ESP32_DEV](#9-AsyncHTTPRequest_ESP_Multi-running-on-ESP32_DEV) **New**
* [10. AsyncHTTPRequest_ESP8266_Ethernet running on ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet](#10-AsyncHTTPRequest_ESP8266_Ethernet-running-on-ESP8266_NODEMCU_ESP12E-using-ESP8266_W5500-Ethernet) **New**
* [11. AsyncHTTPRequest_ESP8266_Ethernet running on ESP8266_NODEMCU_ESP12E using ESP8266_ENC28J60 Ethernet](#11-AsyncHTTPRequest_ESP8266_Ethernet-running-on-ESP8266_NODEMCU_ESP12E-using-ESP8266_ENC28J60-Ethernet) **New**
* [Debug](#debug)
* [Troubleshooting](#troubleshooting)
* [Issues](#issues)
@ -166,6 +157,8 @@ This library is based on, modified from:
#### 4. STM32 boards using Ethernet LAN8720
Support for LAN8720 has been **removed** from STM32 core v2.3.0
1. **Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)**
2. **Discovery (DISCO_F746NG)**
3. **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)**
@ -187,7 +180,7 @@ This library is based on, modified from:
8. [`STM32Ethernet library v1.3.0+`](https://github.com/stm32duino/STM32Ethernet) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/STM32Ethernet.svg)](https://github.com/stm32duino/STM32Ethernet/releases/latest)
9. [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/LwIP.svg)](https://github.com/stm32duino/LwIP/releases/latest)
10. [`STM32AsyncTCP library v1.0.1+`](https://github.com/khoih-prog/STM32AsyncTCP) for built-in Ethernet on (Nucleo-144, Discovery). To install manually for Arduino IDE.
11. [`ESPAsync_WiFiManager library v1.12.2+`](https://github.com/khoih-prog/ESPAsync_WiFiManager) for ESP32/ESP8266 using some examples. [![GitHub release](https://img.shields.io/github/release/khoih-prog/ESPAsync_WiFiManager.svg)](https://github.com/khoih-prog/ESPAsync_WiFiManager/releases)
11. [`ESPAsync_WiFiManager library v1.13.0+`](https://github.com/khoih-prog/ESPAsync_WiFiManager) for ESP32/ESP8266 using some examples. [![GitHub release](https://img.shields.io/github/release/khoih-prog/ESPAsync_WiFiManager.svg)](https://github.com/khoih-prog/ESPAsync_WiFiManager/releases)
12. [`LittleFS_esp32 v1.0.6+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS **only with ESP32 core v1.0.5-**. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_esp32.svg?)](https://www.ardu-badge.com/LittleFS_esp32).
13. [`WebServer_WT32_ETH01 library v1.5.0+`](https://github.com/khoih-prog/WebServer_WT32_ETH01) if necessary to use WT32_ETH01 boards. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/WebServer_WT32_ETH01.svg?)](https://www.ardu-badge.com/WebServer_WT32_ETH01)
@ -467,15 +460,6 @@ https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/e3dd512e7aa9e60c8504
5. [AsyncSimpleGET_STM32](examples/AsyncSimpleGET_STM32)
6. [AsyncWebClientRepeating_STM32](examples/AsyncWebClientRepeating_STM32)
#### For STM32 using LAN8720
1. [AsyncHTTPRequest_STM32_LAN8720](examples/STM32_LAN8720/AsyncHTTPRequest_STM32_LAN8720)
2. [AsyncCustomHeader_STM32_LAN8720](examples/STM32_LAN8720/AsyncCustomHeader_STM32_LAN8720)
3. [AsyncDweetGet_STM32_LAN8720](examples/STM32_LAN8720/AsyncDweetGet_STM32_LAN8720)
4. [AsyncDweetPost_STM32_LAN8720](examples/STM32_LAN8720/AsyncDweetPost_STM32_LAN8720)
5. [AsyncSimpleGET_STM32_LAN8720](examples/STM32_LAN8720/AsyncSimpleGET_STM32_LAN8720)
6. [AsyncWebClientRepeating_STM32_LAN8720](examples/STM32_LAN8720/AsyncWebClientRepeating_STM32_LAN8720)
#### For WT32_ETH01
1. [AsyncHTTPRequest_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01)
@ -513,7 +497,7 @@ https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/98733a6c4a1906ff53f6
```
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
AsyncHTTPRequest @ IP : 192.168.2.178
**************************************
@ -558,7 +542,7 @@ week_number: 15
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
Stored: SSID = HueNet1, Pass = 12345678
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
@ -590,7 +574,7 @@ HHHHHH
```
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
Stored: SSID = HueNet1, Pass = 12345678
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
@ -640,7 +624,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
```
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
Connecting to WiFi SSID: HueNet1
...........
HTTP WebServer is @ IP : 192.168.2.81
@ -672,7 +656,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
```
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
AsyncHTTPRequest @ IP : 192.168.2.72
**************************************
@ -718,96 +702,15 @@ AsyncHTTPRequest @ IP : 192.168.2.72
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
```
---
#### 6. [AsyncWebClientRepeating_STM32_LAN8720](examples/STM32_LAN8720/AsyncWebClientRepeating_STM32_LAN8720) running on STM32F4 BLACK_F407VE using LAN8720
```
Start AsyncWebClientRepeating_STM32_LAN8720 on BLACK_F407VE
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest @ IP : 192.168.2.150
**************************************
`:;;;,` .:;;:.
.;;;;;;;;;;;` :;;;;;;;;;;: TM
`;;;;;;;;;;;;;;;` :;;;;;;;;;;;;;;;
:;;;;;;;;;;;;;;;;;; `;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;; .;;;;;;;;;;;;;;;;;;;;
;;;;;;;;:` `;;;;;;;;; ,;;;;;;;;.` .;;;;;;;;
.;;;;;;, :;;;;;;; .;;;;;;; ;;;;;;;
;;;;;; ;;;;;;; ;;;;;;, ;;;;;;.
,;;;;; ;;;;;;.;;;;;;` ;;;;;;
;;;;;. ;;;;;;;;;;;` ``` ;;;;;`
;;;;; ;;;;;;;;;, ;;; .;;;;;
`;;;;: `;;;;;;;; ;;; ;;;;;
,;;;;` `,,,,,,,, ;;;;;;; .,,;;;,,, ;;;;;
:;;;;` .;;;;;;;; ;;;;;, :;;;;;;;; ;;;;;
:;;;;` .;;;;;;;; `;;;;;; :;;;;;;;; ;;;;;
.;;;;. ;;;;;;;. ;;; ;;;;;
;;;;; ;;;;;;;;; ;;; ;;;;;
;;;;; .;;;;;;;;;; ;;; ;;;;;,
;;;;;; `;;;;;;;;;;;; ;;;;;
`;;;;;, .;;;;;; ;;;;;;; ;;;;;;
;;;;;;: :;;;;;;. ;;;;;;; ;;;;;;
;;;;;;;` .;;;;;;;, ;;;;;;;; ;;;;;;;:
;;;;;;;;;:,:;;;;;;;;;: ;;;;;;;;;;:,;;;;;;;;;;
`;;;;;;;;;;;;;;;;;;;. ;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; :;;;;;;;;;;;;;;;;:
,;;;;;;;;;;;;;, ;;;;;;;;;;;;;;
.;;;;;;;;;` ,;;;;;;;;:
;;; ;;;;;` ;;;;: .;; ;; ,;;;;;, ;;. `;, ;;;;
;;; ;;:;;; ;;;;;; .;; ;; ,;;;;;: ;;; `;, ;;;:;;
,;:; ;; ;; ;; ;; .;; ;; ,;, ;;;,`;, ;; ;;
;; ;: ;; ;; ;; ;; .;; ;; ,;, ;;;;`;, ;; ;;.
;: ;; ;;;;;: ;; ;; .;; ;; ,;, ;;`;;;, ;; ;;`
,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;;
;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;;
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
**************************************
```
---
#### 7. [AsyncHTTPMultiRequests_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01) on ESP32_DEV with ETH_PHY_LAN8720
#### 6. [AsyncHTTPRequest_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01) on ESP32_DEV with ETH_PHY_LAN8720
```
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.5.0
AsyncHTTPRequest_Generic v1.8.2
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
AsyncHTTPRequest @ IP : 192.168.2.232
***************Current***************
{"lat":-24.32,"lon":-46.9983,"timezone":"America/Sao_Paulo","timezone_offset":-10800,"current":{"dt":1625887856,"sunrise":1625910700,"sunset":1625949281,"temp":290.45,"feels_like":290.51,"pressure":1022,"humidity":87,"dew_point":288.27,"uvi":0,"clouds":97,"visibility":10000,"wind_speed":1.3,"wind_deg":3,"wind_gust":1.77,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}]}}
**************************************
HHHHHH
***************Minutely***************
{"lat":-24.32,"lon":-46.9983,"timezone":"America/Sao_Paulo","timezone_offset":-10800,"minutely":[{"dt":1625887920,"precipitation":0},{"dt":1625887980,"precipitation":0},{"dt":1625888040,"precipitation":0},{"dt":1625888100,"precipitation":0},{"dt":1625888160,"precipitation":0},{"dt":1625888220,"precipitation":0},{"dt":1625888280,"precipitation":0},{"dt":1625888340,"precipitation":0},{"dt":1625888400,"precipitation":0},{"dt":1625888460,"precipitation":0},{"dt":1625888520,"precipitation":0},{"dt":1625888580,"precipitation":0},{"dt":1625888640,"precipitation":0},{"dt":1625888700,"precipitation":0},{"dt":1625888760,"precipitation":0},{"dt":1625888820,"precipitation":0},{"dt":1625888880,"precipitation":0},{"dt":1625888940,"precipitation":0},{"dt":1625889000,"precipitation":0},{"dt":1625889060,"precipitation":0},{"dt":1625889120,"precipitation":0},{"dt":1625889180,"precipitation":0},{"dt":1625889240,"precipitation":0},{"dt":1625889300,"precipitation":0},{"dt":1625889360,"precipitation":0},{"dt":1625889420,"precipitation":0},{"dt":1625889480,"precipitation":0},{"dt":1625889540,"precipitation":0},{"dt":1625889600,"precipitation":0},{"dt":1625889660,"precipitation":0},{"dt":1625889720,"precipitation":0},{"dt":1625889780,"precipitation":0},{"dt":1625889840,"precipitation":0},{"dt":1625889900,"precipitation":0},{"dt":1625889960,"precipitation":0},{"dt":1625890020,"precipitation":0},{"dt":1625890080,"precipitation":0},{"dt":1625890140,"precipitation":0},{"dt":1625890200,"precipitation":0},{"dt":1625890260,"precipitation":0},{"dt":1625890320,"precipitation":0},{"dt":1625890380,"precipitation":0},{"dt":1625890440,"precipitation":0},{"dt":1625890500,"precipitation":0},{"dt":1625890560,"precipitation":0},{"dt":1625890620,"precipitation":0},{"dt":1625890680,"precipitation":0},{"dt":1625890740,"precipitation":0},{"dt":1625890800,"precipitation":0},{"dt":1625890860,"precipitation":0},{"dt":1625890920,"precipitation":0},{"dt":1625890980,"precipitation":0},{"dt":1625891040,"precipitation":0},{"dt":1625891100,"precipitation":0},{"dt":1625891160,"precipitation":0},{"dt":1625891220,"precipitation":0},{"dt":1625891280,"precipitation":0},{"dt":1625891340,"precipitation":0},{"dt":1625891400,"precipitation":0},{"dt":1625891460,"precipitation":0},{"dt":1625891520,"precipitation":0}]}
**************************************
HHHH HH
***************Daily***************
{"lat":-24.32,"lon":-46.9983,"timezone":"America/Sao_Paulo","timezone_offset":-10800,"daily":[{"dt":1625929200,"sunrise":1625910700,"sunset":1625949281,"moonrise":1625912640,"moonset":1625951340,"moon_phase":0.02,"temp":{"day":295.51,"min":288.03,"max":295.54,"night":289.23,"eve":290.52,"morn":288.14},"feels_like":{"day":295.42,"night":289.24,"eve":290.69,"morn":288.1},"pressure":1021,"humidity":62,"dew_point":287.26,"wind_speed":2.25,"wind_deg":151,"wind_gust":2.36,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"clouds":0,"pop":0.01,"uvi":4.97},{"dt":1626015600,"sunrise":1625997092,"sunset":1626035705,"moonrise":1626001860,"moonset":1626041220,"moon_phase":0.05,"temp":{"day":295.33,"min":288.28,"max":295.45,"night":290.23,"eve":290.91,"morn":288.28},"feels_like":{"day":295.27,"night":290.5,"eve":291.22,"morn":288.07},"pressure":1021,"humidity":64,"dew_point":287.51,"wind_speed":2.46,"wind_deg":173,"wind_gust":2.85,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"clouds":0,"pop":0,"uvi":5.01},{"dt":1626102000,"sunrise":1626083482,"sunset":1626122130,"moonrise":1626090900,"moonset":1626131100,"moon_phase":0.08,"temp":{"day":295.54,"min":289.16,"max":295.58,"night":290.41,"eve":291.33,"morn":289.32},"feels_like":{"day":295.61,"night":290.7,"eve":291.66,"morn":289.45},"pressure":1022,"humidity":68,"dew_point":288.68,"wind_speed":2.3,"wind_deg":115,"wind_gust":2.47,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"clouds":0,"pop":0.01,"uvi":5.02},{"dt":1626188400,"sunrise":1626169871,"sunset":1626208556,"moonrise":1626179700,"moonset":1626220980,"moon_phase":0.12,"temp":{"day":297.47,"min":288.79,"max":297.47,"night":291.03,"eve":291.51,"morn":288.79},"feels_like":{"day":297.42,"night":291.09,"eve":291.75,"morn":288.73},"pressure":1020,"humidity":56,"dew_point":287.21,"wind_speed":2.26,"wind_deg":6,"wind_gust":2.64,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"clouds":7,"pop":0,"uvi":5.16},{"dt":1626274800,"sunrise":1626256259,"sunset":1626294981,"moonrise":1626268380,"moonset":1626310860,"moon_phase":0.15,"temp":{"day":300.56,"min":291.14,"max":300.56,"night":292.56,"eve":293.32,"morn":291.14},"feels_like":{"day":300.44,"night":292.31,"eve":293.3,"morn":290.64},"pressure":1017,"humidity":42,"dew_point":285.41,"wind_speed":2.21,"wind_deg":9,"wind_gust":2.64,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"clouds":99,"pop":0,"uvi":1.57},{"dt":1626361200,"sunrise":1626342645,"sunset":1626381407,"moonrise":1626356940,"moonset":1626400740,"moon_phase":0.19,"temp":{"day":303.08,"min":291.35,"max":303.08,"night":294.83,"eve":295.82,"morn":291.35},"feels_like":{"day":302.65,"night":294.54,"eve":295.79,"morn":290.77},"pressure":1012,"humidity":39,"dew_point":286.19,"wind_speed":2.6,"wind_deg":343,"wind_gust":5.27,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"clouds":40,"pop":0,"uvi":2},{"dt":1626447600,"sunrise":1626429031,"sunset":1626467833,"moonrise":1626445440,"moonset":1626490680,"moon_phase":0.22,"temp":{"day":292.5,"min":289.95,"max":294.21,"night":289.95,"eve":290.68,"morn":291.26},"feels_like":{"day":292.84,"night":290.14,"eve":290.92,"morn":291.4},"pressure":1021,"humidity":90,"dew_point":290.28,"wind_speed":4.17,"wind_deg":265,"wind_gust":7.18,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"clouds":100,"pop":0.76,"rain":4.13,"uvi":2},{"dt":1626534000,"sunrise":1626515415,"sunset":1626554260,"moonrise":1626534060,"moonset":0,"moon_phase":0.25,"temp":{"day":288.1,"min":287.9,"max":289.38,"night":288.96,"eve":288.71,"morn":288.22},"feels_like":{"day":288.16,"night":289.05,"eve":288.78,"morn":288.24},"pressure":1025,"humidity":96,"dew_point":287.06,"wind_speed":3.79,"wind_deg":144,"wind_gust":6.59,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"clouds":100,"pop":1,"rain":32.28,"uvi":2}]}
**************************************
H
```
---
#### 8. [AsyncHTTPRequest_WT32_ETH01](examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01) on ESP32_DEV with ETH_PHY_LAN8720
```
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.5.0
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
AsyncHTTPRequest @ IP : 192.168.2.232
@ -832,12 +735,12 @@ week_number: 15
---
#### 9. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32C3_DEV
#### 7. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32C3_DEV
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP32C3_DEV
ESPAsync_WiFiManager v1.12.2
AsyncHTTPRequest_Generic v1.8.2
ESPAsync_WiFiManager v1.13.0
AsyncHTTPRequest_Generic v1.9.0
Stored: SSID = HueNet1, Pass = password
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
@ -882,13 +785,13 @@ week_number: 15
---
#### 10. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32S3_DEV
#### 8. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager) running on ESP32S3_DEV
```
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP32S3_DEV
ESPAsync_WiFiManager v1.12.2
AsyncHTTPRequest_Generic v1.8.2
ESPAsync_WiFiManager v1.13.0
AsyncHTTPRequest_Generic v1.9.0
Stored: SSID = HueNet1, Pass = password
Got stored Credentials. Timeout 120s
ConnectMultiWiFi in setup
@ -934,13 +837,13 @@ week_number: 15
---
#### 11. [AsyncHTTPRequest_ESP_Multi](examples/AsyncHTTPRequest_ESP_Multi) running on ESP32_DEV
#### 9. [AsyncHTTPRequest_ESP_Multi](examples/AsyncHTTPRequest_ESP_Multi) running on ESP32_DEV
The terminal output of [AsyncHTTPRequest_ESP_Multi example](examples/AsyncHTTPRequest_ESP_Multi) running on `ESP32_DEV` to demonstrate how to send requests to multiple addresses and receive responses from them.
```
Starting AsyncHTTPRequest_ESP_Multi using ESP32_DEV
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
Connecting to WiFi SSID: HueNet1
.......
AsyncHTTPSRequest @ IP : 192.168.2.88
@ -995,13 +898,13 @@ HHH
---
#### 12. [AsyncHTTPRequest_ESP8266_Ethernet](examples/AsyncHTTPRequest_ESP8266_Ethernet) running on ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet
#### 10. [AsyncHTTPRequest_ESP8266_Ethernet](examples/AsyncHTTPRequest_ESP8266_Ethernet) running on ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet
The terminal output of [AsyncHTTPRequest_ESP8266_Ethernet example](examples/AsyncHTTPRequest_ESP8266_Ethernet) running on `ESP8266_NODEMCU_ESP12E` to demonstrate how to use ESP8266_W5500 Ethernet Async feature.
```
Starting AsyncHTTPRequest_ESP8266_Ethernet on ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
Connecting ethernet..
Ethernet IP address: 192.168.2.187
@ -1045,13 +948,13 @@ HH
---
#### 13. [AsyncHTTPRequest_ESP8266_Ethernet](examples/AsyncHTTPRequest_ESP8266_Ethernet) running on ESP8266_NODEMCU_ESP12E using ESP8266_ENC28J60 Ethernet
#### 11. [AsyncHTTPRequest_ESP8266_Ethernet](examples/AsyncHTTPRequest_ESP8266_Ethernet) running on ESP8266_NODEMCU_ESP12E using ESP8266_ENC28J60 Ethernet
The terminal output of [AsyncHTTPRequest_ESP8266_Ethernet example](examples/AsyncHTTPRequest_ESP8266_Ethernet) running on `ESP8266_NODEMCU_ESP12E` to demonstrate how to use ESP8266_ENC28J60 Ethernet Async feature.
```
Starting AsyncHTTPRequest_ESP8266_Ethernet on ESP8266_NODEMCU_ESP12E using ESP8266_ENC28J60 Ethernet
AsyncHTTPRequest_Generic v1.8.2
AsyncHTTPRequest_Generic v1.9.0
Connecting to network : ..........................................................
Ethernet IP address: 192.168.2.187
@ -1152,6 +1055,8 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
15. Add example [AsyncHTTPRequest_ESP_Multi](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/tree/master/examples/AsyncHTTPRequest_ESP_Multi) to demonstrate how to send requests to multiple addresses and receive responses from them.
16. Add support to ESP8266 using **W5x00** with [**lwIP_w5100**](https://github.com/esp8266/Arduino/tree/master/libraries/lwIP_w5100) or [**lwIP_w5500**](https://github.com/esp8266/Arduino/tree/master/libraries/lwIP_w5500) library
17. Add support to ESP8266 using **ENC28J60** with [**lwIP_enc28j60**](https://github.com/esp8266/Arduino/tree/master/libraries/lwIP_enc28j60) library
18. Fix long timeout if using `IPAddress`.
19. Remove support to STM32 using **LAN8720** due to problem with new STM32 core v2.3.0
---
@ -1169,6 +1074,7 @@ This library is based on, modified, bug-fixed and improved from:
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.
7. Thanks to [DavidAntonin](https://github.com/DavidAntonin) to report [Cannot send requests to different addresses #4](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/4) leading to new release v1.7.1 to demonstrate how to send requests to multiple addresses and receive responses from them.
8. Thanks to [per1234](https://github.com/per1234) to make PR [Remove unavailable items from depends field of library.properties](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/35) leading to v1.8.2
9. Thanks to [miwied](https://github.com/miwied) to report [setTimeout() hasn't any effect #38](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/38) leading to new release v1.9.0
<table>
<tr>
@ -1182,6 +1088,7 @@ This library is based on, modified, bug-fixed and improved from:
<tr>
<td align="center"><a href="https://github.com/DavidAntonin"><img src="https://github.com/DavidAntonin.png" width="100px;" alt="DavidAntonin"/><br /><sub><b>DavidAntonin</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/per1234"><img src="https://github.com/per1234.png" width="100px;" alt="per1234"/><br /><sub><b>per1234</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/miwied"><img src="https://github.com/miwied.png" width="100px;" alt="miwied"/><br /><sub><b>miwied</b></sub></a><br /></td>
</tr>
</table>

View File

@ -12,6 +12,7 @@
## Table of Contents
* [Changelog](#changelog)
* [Releases v1.9.0](#releases-v190)
* [Releases v1.8.2](#releases-v182)
* [Releases v1.8.1](#releases-v181)
* [Releases v1.8.0](#releases-v180)
@ -39,6 +40,15 @@
## Changelog
### Releases v1.9.0
1. Fix long timeout if using `IPAddress`. Check [setTimeout() hasn't any effect #38](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/38)
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`
5. Remove support to STM32 using **LAN8720** due to problem with new STM32 core v2.3.0
5. Update `Packages' Patches`
### Releases v1.8.2
1. Fix library.properties to remove unavailable items from depends. Check [Remove unavailable items from depends field of library.properties #35](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/35)

View File

@ -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.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
@ -68,26 +68,35 @@ void sendRequest(void)
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
Serial.println();
AHTTP_LOGDEBUG(F("**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
request->setDebug(false);
if (request->responseHTTPcode() == 200)
{
Serial.println(F("**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
else
{
AHTTP_LOGERROR(F("Response error"));
}
}
}
void setup(void)
{
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStart AsyncCustomHeader_STM32 on " + String(BOARD_NAME));
Serial.print("\nStart AsyncCustomHeader_STM32 on "); Serial.println(BOARD_NAME);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)

View File

@ -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.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
@ -118,6 +118,12 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println();
AHTTP_LOGDEBUG(F("**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
String responseText = request->responseText();
@ -130,14 +136,19 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
request->setDebug(false);
}
else
{
AHTTP_LOGERROR(F("Response error"));
}
}
}
void setup(void)
{
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStart AsyncDweetGET_STM32 on " + String(BOARD_NAME));
Serial.print("\nStart AsyncDweetGET_STM32 on "); Serial.println(BOARD_NAME);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)

View File

@ -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.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
@ -115,6 +115,12 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println();
AHTTP_LOGDEBUG(F("**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
String responseText = request->responseText();
@ -127,14 +133,19 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
request->setDebug(false);
}
else
{
AHTTP_LOGERROR(F("Response error"));
}
}
}
void setup(void)
{
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStart AsyncDweetPOST_STM32 on " + String(BOARD_NAME));
Serial.print("\nStart AsyncDweetPOST_STM32 on "); Serial.println(BOARD_NAME);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)

View File

@ -44,12 +44,12 @@
#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.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 1
#define _ASYNC_HTTP_LOGLEVEL_ 4
// 300s = 5 minutes to not flooding
#define HTTP_REQUEST_INTERVAL 60 //300
@ -68,10 +68,8 @@ const char* password = "your_pass";
#include <WiFi.h>
#endif
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Impl_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
@ -149,10 +147,16 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.print(F("\n***************")); Serial.print(requestName[ requestIndex ]); Serial.println(F("***************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
#if 1
// Bypass hourly
@ -163,7 +167,7 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
#else
// hourly too long, not display anyway. Not enough heap.
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
#endif
#endif
request->setDebug(false);
}
@ -173,7 +177,7 @@ void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
delay(200);

View File

@ -65,8 +65,8 @@ const char* password = "your_pass";
#include <WiFi.h>
#endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
@ -122,17 +122,21 @@ void sendRequest()
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
request->setDebug(false);
}
}
}
@ -140,9 +144,7 @@ void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
delay(200);
while (!Serial && millis() < 5000);
Serial.print(F("\nStarting AsyncHTTPRequest_ESP using ")); Serial.println(ARDUINO_BOARD);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);

View File

@ -93,14 +93,10 @@
using TCPClient = WiFiClient;
//////////////////////////////////////////////////////////
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
@ -156,17 +152,21 @@ void sendRequest()
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
request->setDebug(false);
}
}
}
@ -211,8 +211,8 @@ void setup()
delay(200);
Serial.print(F("\nStarting AsyncHTTPRequest_ESP8266_Ethernet on ")); Serial.print(ARDUINO_BOARD);
Serial.print(F(" using ")); Serial.println(SHIELD_TYPE);
Serial.print("\nStart AsyncHTTPRequest_ESP8266_Ethernet on "); Serial.print(ARDUINO_BOARD);
Serial.print(" using "); Serial.println(SHIELD_TYPE);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
initEthernet();

View File

@ -126,9 +126,19 @@ void requestCB0(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(thisRequest->responseText());
Serial.println("**************************************");
AHTTP_LOGERROR(F("\n**************************************"));
AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
else
{
AHTTP_LOGERROR(F("Response error"));
}
thisRequest->setDebug(false);
readySend[0] = true;
@ -141,9 +151,19 @@ void requestCB1(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(thisRequest->responseText());
Serial.println("**************************************");
AHTTP_LOGERROR(F("\n**************************************"));
AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
else
{
AHTTP_LOGERROR(F("Response error"));
}
thisRequest->setDebug(false);
readySend[1] = true;
@ -154,9 +174,9 @@ void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStarting AsyncHTTPRequest_ESP_Multi using " + String(ARDUINO_BOARD));
Serial.print("\nStart AsyncHTTPRequest_ESP_Multi on "); Serial.println(ARDUINO_BOARD);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
WiFi.mode(WIFI_STA);

View File

@ -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.12.1"
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1012001
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.13.0"
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1013000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
@ -556,17 +556,21 @@ void sendRequest()
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
request->setDebug(false);
}
}
}
@ -574,7 +578,7 @@ void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
delay(200);
@ -634,7 +638,7 @@ void setup()
#if ( USING_ESP32_S2 || USING_ESP32_C3 )
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, "AutoConnectAP");
#else
DNSServer dnsServer;
AsyncDNSServer dnsServer;
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "AutoConnectAP");
#endif

View File

@ -42,8 +42,8 @@
#include "defines.h"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
@ -55,12 +55,12 @@
AsyncHTTPRequest request;
void sendRequest(void);
void sendRequest();
// Repeat forever, millis() resolution
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
void sendRequest(void)
void sendRequest()
{
static bool requestOpenResult;
@ -85,26 +85,30 @@ void sendRequest(void)
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
request->setDebug(false);
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
}
}
void setup(void)
void setup()
{
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStart AsyncHTTPRequest_STM32 on " + String(BOARD_NAME));
Serial.print("\nStart AsyncHTTPRequest_STM32 on "); Serial.println(BOARD_NAME);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
@ -138,7 +142,7 @@ void setup(void)
sendRequest();
}
void loop(void)
void loop()
{
sendHTTPRequest.update();
}

View File

@ -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.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
@ -37,12 +37,12 @@ char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toro
AsyncHTTPRequest request;
void sendRequest(void);
void sendRequest();
// Repeat forever, millis() resolution
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
void sendRequest(void)
void sendRequest()
{
static bool requestOpenResult;
@ -66,26 +66,30 @@ void sendRequest(void)
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
request->setDebug(false);
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
}
}
void setup(void)
void setup()
{
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStart AsyncSimpleGET_STM32 on " + String(BOARD_NAME));
Serial.print("\nStart AsyncSimpleGET_STM32 on "); Serial.println(BOARD_NAME);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
@ -105,8 +109,7 @@ void setup(void)
// Use DHCP dynamic IP and random mac
Ethernet.begin(mac[index]);
Serial.print(F("AsyncHTTPRequest @ IP : "));
Serial.println(Ethernet.localIP());
Serial.print(F("AsyncHTTPRequest @ IP : ")); Serial.println(Ethernet.localIP());
Serial.println();
request.setDebug(false);
@ -119,7 +122,7 @@ void setup(void)
sendRequest();
}
void loop(void)
void loop()
{
sendHTTPRequest.update();
}

View File

@ -21,13 +21,13 @@
#include "defines.h"
// Select a test server address
const char GET_ServerAddress[] = "arduino.cc";
const char GET_ServerAddress[] = "arduino.tips";
// GET location
String GET_Location = "/asciilogo.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
@ -39,12 +39,12 @@ String GET_Location = "/asciilogo.txt";
AsyncHTTPRequest request;
void sendRequest(void);
void sendRequest();
// Repeat forever, millis() resolution
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
void sendRequest(void)
void sendRequest()
{
static bool requestOpenResult;
@ -68,26 +68,30 @@ void sendRequest(void)
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
request->setDebug(false);
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
}
}
void setup(void)
void setup()
{
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.println("\nStart AsyncWebClientRepeating_STM32 on " + String(BOARD_NAME));
Serial.print("\nStart AsyncWebClientRepeating_STM32 on "); Serial.println(BOARD_NAME);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
@ -119,7 +123,7 @@ void setup(void)
sendRequest();
}
void loop(void)
void loop()
{
sendHTTPRequest.update();
}

View File

@ -57,8 +57,8 @@
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
@ -152,9 +152,15 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
if (readyState == readyStateDone)
{
Serial.print("\n***************"); Serial.print(requestName[ requestIndex ]); Serial.println("***************");
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.print(F("\n***************")); Serial.print(requestName[ requestIndex ]); Serial.println(F("***************"));
Serial.println(request->responseText());
Serial.println("**************************************");
Serial.println(F("**************************************"));
}
#if 1
// Bypass hourly
@ -165,7 +171,7 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
#else
// hourly too long, not display anyway. Not enough heap.
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
#endif
#endif
request->setDebug(false);
}
@ -176,12 +182,12 @@ void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
delay(200);
Serial.print("\nStarting AsyncHTTPRequest_WT32_ETH01 on " + String(ARDUINO_BOARD));
Serial.println(" with " + String(SHIELD_TYPE));
Serial.print("\nStart AsyncHTTPMultiRequests_WT32_ETH01 on "); Serial.print(ARDUINO_BOARD);
Serial.print(" with "); Serial.println(SHIELD_TYPE);
Serial.println(WEBSERVER_WT32_ETH01_VERSION);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);

View File

@ -57,8 +57,8 @@
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.7.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1007000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
@ -126,17 +126,21 @@ void sendRequest()
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
Serial.println("\n**************************************");
Serial.println(request->responseText());
Serial.println("**************************************");
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
request->setDebug(false);
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
}
}
@ -144,10 +148,12 @@ void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
while (!Serial && millis() < 5000);
Serial.print("\nStarting AsyncHTTPRequest_WT32_ETH01 on " + String(ARDUINO_BOARD));
Serial.println(" with " + String(SHIELD_TYPE));
delay(200);
Serial.print("\nStart AsyncHTTPRequest_WT32_ETH01 on "); Serial.print(ARDUINO_BOARD);
Serial.print(" with "); Serial.println(SHIELD_TYPE);
Serial.println(WEBSERVER_WT32_ETH01_VERSION);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);

View File

@ -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.8.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1008002
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009000
#include "multiFileProject.h"

View File

@ -31,6 +31,7 @@ onData KEYWORD2
available KEYWORD2
responseLength KEYWORD2
responseHTTPcode KEYWORD2
responseHTTPString KEYWORD2
responseRead KEYWORD2
elapsedTime KEYWORD2
version KEYWORD2

View File

@ -1,8 +1,8 @@
{
"name":"AsyncHTTPRequest_Generic",
"version": "1.8.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 LAN8720 or built-in LAN8742A Ethernet.",
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, wt32-eth01, stm32, ethernet, wifi, lan8742a, lan8720, f407ve, nucleo-144, stm32f7, W5x00, ENC28J60",
"version": "1.9.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, 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": [
{
"name": "Bob Lemaire",
@ -45,7 +45,7 @@
{
"owner": "khoih-prog",
"name": "ESPAsync_WiFiManager",
"version": ">=1.12.2",
"version": ">=1.13.0",
"platforms": ["espressif8266", "espressif32"]
},
{
@ -63,7 +63,7 @@
{
"owner": "khoih-prog",
"name": "WebServer_WT32_ETH01",
"version": ">=1.4.1",
"version": ">=1.5.0",
"platforms": ["espressif32"]
},
{

View File

@ -1,10 +1,10 @@
name=AsyncHTTPRequest_Generic
version=1.8.2
version=1.9.0
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
maintainer=Khoi Hoang <khoih.prog@gmail.com>
icense=GPLv3
sentence=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 LAN8720 or built-in LAN8742A Ethernet.
paragraph=This AsyncHTTPRequest_Generic Library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, for ESP32 (including ESP32-S2), ESP8266 (WiFi, W5x00 or ENC28J60) and STM32 with LAN8720 or built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, F407VE, etc.
paragraph=This AsyncHTTPRequest_Generic Library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, for ESP32 (including ESP32-S2), ESP8266 (WiFi, W5x00 or ENC28J60) and STM32 built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, etc.
category=Communication,AsyncTCP,AsyncHTTP
url=https://github.com/khoih-prog/AsyncHTTPRequest_Generic
architectures=*

View File

@ -43,7 +43,7 @@ lib_deps =
; https://github.com/khoih-prog/STM32AsyncTCP.git
; STM32duino LwIP@>=2.1.2
; STM32duino STM32Ethernet@>=1.3.0
; ESPAsync_WiFiManager@>=1.12.2
; ESPAsync_WiFiManager@>=1.13.0
; LittleFS_esp32@>=1.0.6
; WebServer_WT32_ETH01@>=1.5.0
@ -54,7 +54,7 @@ lib_deps =
; https://github.com/khoih-prog/STM32AsyncTCP.git
; stm32duino/STM32duino LwIP@>=2.1.2
; stm32duino/STM32duino STM32Ethernet@>=1.3.0
khoih-prog/ESPAsync_WiFiManager@>=1.12.2
khoih-prog/ESPAsync_WiFiManager@>=1.13.0
; lorol/LittleFS_esp32@>=1.0.6
; khoih-prog/WebServer_WT32_ETH01@>=1.5.0

View File

@ -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.8.2
Version: 1.9.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -28,6 +28,7 @@
1.8.0 K Hoang 13/04/2022 Add support to ESP8266 using W5x00 with lwip_W5100 or lwip_W5500 library
1.8.1 K Hoang 13/04/2022 Add support to ESP8266 using ENC28J60 with lwip_enc28j60 library
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.
*****************************************************************************************************************************/
#pragma once

View File

@ -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.8.2
Version: 1.9.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -28,6 +28,7 @@
1.8.0 K Hoang 13/04/2022 Add support to ESP8266 using W5x00 with lwip_W5100 or lwip_W5500 library
1.8.1 K Hoang 13/04/2022 Add support to ESP8266 using ENC28J60 with lwip_enc28j60 library
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.
*****************************************************************************************************************************/
#pragma once

View File

@ -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.8.2
Version: 1.9.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -28,6 +28,7 @@
1.8.0 K Hoang 13/04/2022 Add support to ESP8266 using W5x00 with lwip_W5100 or lwip_W5500 library
1.8.1 K Hoang 13/04/2022 Add support to ESP8266 using ENC28J60 with lwip_enc28j60 library
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.
*****************************************************************************************************************************/
#pragma once
@ -35,13 +36,13 @@
#ifndef ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.8.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.9.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 8
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 2
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 9
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 0
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1008002
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1009000
#include <Arduino.h>
@ -253,28 +254,24 @@ class AsyncHTTPRequest
struct URL
{
char* scheme;
char* user;
char* pwd;
char* host;
char *buffer;
char *scheme;
char *host;
int port;
char* path;
char* query;
char* fragment;
char *path;
char *query;
URL(): scheme(nullptr), user(nullptr), pwd(nullptr), host(nullptr),
port(80), path(nullptr), query(nullptr), fragment(nullptr)
URL(): buffer(nullptr), scheme(nullptr), host(nullptr),
port(80), path(nullptr), query(nullptr)
{};
~URL()
{
SAFE_DELETE_ARRAY(buffer)
SAFE_DELETE_ARRAY(scheme)
SAFE_DELETE_ARRAY(user)
SAFE_DELETE_ARRAY(pwd)
SAFE_DELETE_ARRAY(host)
SAFE_DELETE_ARRAY(path)
SAFE_DELETE_ARRAY(query)
SAFE_DELETE_ARRAY(fragment)
}
};
@ -333,6 +330,7 @@ class AsyncHTTPRequest
size_t available(); // response available
size_t responseLength(); // indicated response length or sum of chunks to date
int responseHTTPcode(); // HTTP response code or (negative) error code
String responseHTTPString();
String responseText(); // response (whole* or partial* as string)
char* responseLongText(); // response long (whole* or partial* as string)

View File

@ -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.8.2
Version: 1.9.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -28,6 +28,7 @@
1.8.0 K Hoang 13/04/2022 Add support to ESP8266 using W5x00 with lwip_W5100 or lwip_W5500 library
1.8.1 K Hoang 13/04/2022 Add support to ESP8266 using ENC28J60 with lwip_enc28j60 library
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.
*****************************************************************************************************************************/
#pragma once
@ -302,14 +303,14 @@ String xbuf::readString(int endPos)
if ( ! result.reserve(endPos + 1))
{
// KH, to remove
AHTTP_LOGDEBUG1("xbuf::readString: can't reserve size = ", endPos + 1);
//AHTTP_LOGERROR1(F("xbuf::readString: can't reserve size ="), endPos + 1);
///////
return result;
}
// KH, to remove
AHTTP_LOGDEBUG1("xbuf::readString: Reserved size = ", endPos + 1);
//AHTTP_LOGDEBUG1(F("xbuf::readString: Reserved size ="), endPos + 1);
///////
if (endPos > _used)
@ -384,18 +385,22 @@ void xbuf::addSeg()
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail->next == NULL)
AHTTP_LOGERROR("xbuf::addSeg: error new 1");
{
AHTTP_LOGERROR(F("xbuf::addSeg: error new 1"));
}
else
{
// KH, Must check NULL here
_tail = _tail->next;
}
}
else
{
// KH, Must check NULL here
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail == NULL)
AHTTP_LOGERROR("xbuf::addSeg: error new 2");
AHTTP_LOGERROR(F("xbuf::addSeg: error new 2"));
}
// KH, Must check NULL here
@ -467,7 +472,7 @@ void AsyncHTTPRequest::setDebug(bool debug)
{
_debug = true;
AHTTP_LOGDEBUG3("setDebug(", debug ? "on" : "off", ") version", ASYNC_HTTP_REQUEST_GENERIC_VERSION);
AHTTP_LOGDEBUG3(F("setDebug("), debug ? F("on") : F("off"), F(") version"), ASYNC_HTTP_REQUEST_GENERIC_VERSION);
}
_debug = debug;
@ -482,11 +487,11 @@ bool AsyncHTTPRequest::debug()
//**************************************************************************************************************
bool AsyncHTTPRequest::open(const char* method, const char* URL)
{
AHTTP_LOGDEBUG3("open(", method, ", url =", URL);
AHTTP_LOGDEBUG3(F("open("), method, F(", url ="), URL);
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
{
AHTTP_LOGDEBUG("open: not ready");
AHTTP_LOGERROR(F("open: not ready"));
return false;
}
@ -540,7 +545,7 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
//////
else
{
AHTTP_LOGDEBUG("open: Bad method");
AHTTP_LOGERROR(F("open: Bad method"));
return false;
}
@ -548,14 +553,14 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
if (!_parseURL(URL))
{
AHTTP_LOGDEBUG("open: error parsing URL");
AHTTP_LOGERROR(F("open: error parsing URL"));
return false;
}
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
{
AHTTP_LOGDEBUG("open: not connected");
AHTTP_LOGERROR(F("open: not connected"));
return false;
}
@ -567,7 +572,7 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
sprintf(hostName, "%s:%d", _URL->host, _URL->port);
_addHeader("host", hostName);
AHTTP_LOGDEBUG1("open: conneting to hostname =", hostName);
AHTTP_LOGDEBUG1(F("open: connecting to hostname ="), hostName);
SAFE_DELETE_ARRAY(hostName)
@ -581,7 +586,7 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
}
else
{
AHTTP_LOGDEBUG("open: error alloc");
AHTTP_LOGERROR(F("open: error alloc"));
return false;
}
@ -596,7 +601,7 @@ void AsyncHTTPRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
//**************************************************************************************************************
void AsyncHTTPRequest::setTimeout(int seconds)
{
AHTTP_LOGDEBUG1("setTimeout = ", seconds);
AHTTP_LOGDEBUG1(F("setTimeout ="), seconds);
_timeout = seconds;
}
@ -607,11 +612,11 @@ bool AsyncHTTPRequest::send()
// New in v1.1.1
if (_requestReadyToSend)
{
AHTTP_LOGDEBUG("send()");
AHTTP_LOGDEBUG(F("send()"));
}
else
{
AHTTP_LOGDEBUG(CANT_SEND_BAD_REQUEST);
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -634,20 +639,20 @@ bool AsyncHTTPRequest::send(const String& body)
// New in v1.1.1
if (_requestReadyToSend)
{
AHTTP_LOGDEBUG3("send(String)", body.substring(0, 16).c_str(), ", length =", body.length());
AHTTP_LOGDEBUG3(F("send(String)"), body.substring(0, 16).c_str(), F(", length ="), body.length());
}
else
{
AHTTP_LOGDEBUG(CANT_SEND_BAD_REQUEST);
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
//////
AHTTP_LOGERROR1("01) send String body =", body);
AHTTP_LOGERROR1(F("01) send String body ="), body);
MUTEX_LOCK(false)
AHTTP_LOGERROR1("02) send String body =", body);
AHTTP_LOGERROR1(F("02) send String body ="), body);
_addHeader("Content-Length", String(body.length()).c_str());
@ -658,14 +663,14 @@ bool AsyncHTTPRequest::send(const String& body)
return false;
}
AHTTP_LOGERROR1("1) send String body =", body);
AHTTP_LOGERROR1(F("1) send String body ="), body);
_request->write(body);
AHTTP_LOGERROR1("2) send String body =", body);
AHTTP_LOGERROR1(F("2) send String body ="), body);
_send();
AHTTP_LOGERROR1("3) send String body =", body);
AHTTP_LOGERROR1(F("3) send String body ="), body);
_AHTTP_unlock;
@ -678,11 +683,11 @@ bool AsyncHTTPRequest::send(const char* body)
// New in v1.1.1
if (_requestReadyToSend)
{
AHTTP_LOGDEBUG3("send(char)", body, ", length =", strlen(body));
AHTTP_LOGDEBUG3(F("send(char)"), body, F(", length ="), strlen(body));
}
else
{
AHTTP_LOGDEBUG(CANT_SEND_BAD_REQUEST);
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -712,11 +717,11 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
// New in v1.1.1
if (_requestReadyToSend)
{
AHTTP_LOGDEBUG3("send(char)", (char*) body, ", length =", len);
AHTTP_LOGDEBUG3(F("send(char)"), (char*) body, F(", length ="), len);
}
else
{
AHTTP_LOGDEBUG(CANT_SEND_BAD_REQUEST);
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -746,11 +751,11 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
// New in v1.1.1
if (_requestReadyToSend)
{
AHTTP_LOGDEBUG3("send(char)", body->peekString(16).c_str(), ", length =", len);
AHTTP_LOGDEBUG3(F("send(char)"), body->peekString(16).c_str(), F(", length ="), len);
}
else
{
AHTTP_LOGDEBUG(CANT_SEND_BAD_REQUEST);
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -777,7 +782,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
//**************************************************************************************************************
void AsyncHTTPRequest::abort()
{
AHTTP_LOGDEBUG("abort()");
AHTTP_LOGERROR(F("abort()"));
if (! _client)
{
@ -802,42 +807,114 @@ int AsyncHTTPRequest::responseHTTPcode()
return _HTTPcode;
}
//**************************************************************************************************************
String AsyncHTTPRequest::responseHTTPString()
{
switch(_HTTPcode)
{
case 0:
return F("OK");
case HTTPCODE_CONNECTION_REFUSED:
return F("CONNECTION_REFUSED");
case HTTPCODE_SEND_HEADER_FAILED:
return F("SEND_HEADER_FAILED");
case HTTPCODE_SEND_PAYLOAD_FAILED:
return F("SEND_PAYLOAD_FAILED");
case HTTPCODE_NOT_CONNECTED:
return F("NOT_CONNECTED");
case HTTPCODE_CONNECTION_LOST:
return F("CONNECTION_LOST");
case HTTPCODE_NO_STREAM:
return F("NO_STREAM");
case HTTPCODE_NO_HTTP_SERVER:
return F("NO_HTTP_SERVER");
case HTTPCODE_TOO_LESS_RAM:
return F("TOO_LESS_RAM");
case HTTPCODE_ENCODING:
return F("ENCODING");
case HTTPCODE_STREAM_WRITE:
return F("STREAM_WRITE");
case HTTPCODE_TIMEOUT:
return F("TIMEOUT");
// HTTP positive code
case 100: return F("Continue");
case 101: return F("Switching Protocols");
case 200: return F("HTTP OK");
case 201: return F("Created");
case 202: return F("Accepted");
case 203: return F("Non-Authoritative Information");
case 204: return F("No Content");
case 205: return F("Reset Content");
case 206: return F("Partial Content");
case 300: return F("Multiple Choices");
case 301: return F("Moved Permanently");
case 302: return F("Found");
case 303: return F("See Other");
case 304: return F("Not Modified");
case 305: return F("Use Proxy");
case 307: return F("Temporary Redirect");
case 400: return F("Bad Request");
case 401: return F("Unauthorized");
case 402: return F("Payment Required");
case 403: return F("Forbidden");
case 404: return F("Not Found");
case 405: return F("Method Not Allowed");
case 406: return F("Not Acceptable");
case 407: return F("Proxy Authentication Required");
case 408: return F("Request Time-out");
case 409: return F("Conflict");
case 410: return F("Gone");
case 411: return F("Length Required");
case 412: return F("Precondition Failed");
case 413: return F("Request Entity Too Large");
case 414: return F("Request-URI Too Large");
case 415: return F("Unsupported Media Type");
case 416: return F("Requested range not satisfiable");
case 417: return F("Expectation Failed");
case 500: return F("Internal Server Error");
case 501: return F("Not Implemented");
case 502: return F("Bad Gateway");
case 503: return F("Service Unavailable");
case 504: return F("Gateway Time-out");
case 505: return F("HTTP Version not supported");
default: return "UNKNOWN";
}
}
//**************************************************************************************************************
String AsyncHTTPRequest::responseText()
{
AHTTP_LOGDEBUG("responseText()");
AHTTP_LOGDEBUG(F("responseText()"));
MUTEX_LOCK(String())
if ( ! _response || _readyState < readyStateLoading || ! available())
{
AHTTP_LOGDEBUG("responseText() no data");
AHTTP_LOGERROR(F("responseText() no data"));
_AHTTP_unlock;
return String();
}
String localString;
size_t avail = available();
if ( ! localString.reserve(avail))
{
AHTTP_LOGDEBUG("responseText() no buffer");
String localString = _response->readString(avail);
if (localString.length() < avail)
{
AHTTP_LOGERROR(F("!responseText() no buffer"))
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
_client->abort();
_AHTTP_unlock;
return String();
}
localString = _response->readString(avail);
_contentRead += localString.length();
//AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
AHTTP_LOGDEBUG3("responseText(char)", localString, ", avail =", avail);
AHTTP_LOGDEBUG3(F("responseText() ="), localString.substring(0,16), F(", size ="), avail);
_AHTTP_unlock;
@ -858,13 +935,13 @@ char globalLongString[GLOBAL_STR_LEN + 1];
char* AsyncHTTPRequest::responseLongText()
{
AHTTP_LOGDEBUG("responseLongText()");
AHTTP_LOGDEBUG(F("responseLongText()"));
MUTEX_LOCK(NULL)
if ( ! _response || _readyState < readyStateLoading || ! available())
{
AHTTP_LOGDEBUG("responseText() no data");
AHTTP_LOGERROR(F("responseText() no data"));
_AHTTP_unlock;
@ -881,7 +958,7 @@ char* AsyncHTTPRequest::responseLongText()
_contentRead += _response->readString(avail).length();
AHTTP_LOGDEBUG3("responseLongText(char)", globalLongString, ", avail =", avail);
AHTTP_LOGDEBUG3(F("responseLongText(char)"), globalLongString, F(", avail ="), avail);
_AHTTP_unlock;
@ -893,7 +970,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
{
if ( ! _response || _readyState < readyStateLoading || ! available())
{
AHTTP_LOGDEBUG("responseRead() no data");
AHTTP_LOGERROR(F("responseRead() no data"));
return 0;
}
@ -903,7 +980,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
size_t avail = available() > len ? len : available();
_response->read(buf, avail);
AHTTP_LOGDEBUG3("responseRead(char)", (char*) buf, ", avail =", avail);
AHTTP_LOGDEBUG3(F("responseRead(char)"), (char*) buf, F(", avail ="), avail);
_contentRead += avail;
@ -938,7 +1015,7 @@ size_t AsyncHTTPRequest::responseLength()
//**************************************************************************************************************
void AsyncHTTPRequest::onData(onDataCB cb, void* arg)
{
AHTTP_LOGDEBUG("onData() CB set");
AHTTP_LOGDEBUG(F("onData() CB set"));
_onDataCB = cb;
_onDataCBarg = arg;
@ -1049,8 +1126,8 @@ bool AsyncHTTPRequest::_parseURL(const String& url)
strcpy(_URL->query, url.substring(queryBeg).c_str());
AHTTP_LOGDEBUG2("_parseURL(): scheme+host", _URL->scheme, _URL->host);
AHTTP_LOGDEBUG3("_parseURL(): port+path+query", _URL->port, _URL->path, _URL->query);
AHTTP_LOGDEBUG2(F("_parseURL(): scheme+host"), _URL->scheme, _URL->host);
AHTTP_LOGDEBUG3(F("_parseURL(): port+path+query"), _URL->port, _URL->path, _URL->query);
return true;
}
@ -1058,7 +1135,7 @@ bool AsyncHTTPRequest::_parseURL(const String& url)
//**************************************************************************************************************
bool AsyncHTTPRequest::_connect()
{
AHTTP_LOGDEBUG("_connect()");
AHTTP_LOGDEBUG(F("_connect()"));
if ( ! _client)
{
@ -1100,15 +1177,21 @@ bool AsyncHTTPRequest::_connect()
if ( ! _client->connected())
{
AHTTP_LOGDEBUG3(F("_client->connecting to"), _URL->host, F(","), _URL->port);
if ( ! _client->connect(_URL->host, _URL->port))
{
AHTTP_LOGDEBUG3("client.connect failed:", _URL->host, ",", _URL->port);
AHTTP_LOGERROR3(F("client.connect failed:"), _URL->host, F(","), _URL->port);
_HTTPcode = HTTPCODE_NOT_CONNECTED;
_setReadyState(readyStateDone);
return false;
}
else
{
AHTTP_LOGDEBUG3(F("client.connect OK to"), _URL->host, F(","), _URL->port);
}
}
else
{
@ -1117,13 +1200,15 @@ bool AsyncHTTPRequest::_connect()
_lastActivity = millis();
AHTTP_LOGDEBUG(F("_connect() true"));
return true;
}
//**************************************************************************************************************
bool AsyncHTTPRequest::_buildRequest()
{
AHTTP_LOGDEBUG("_buildRequest()");
AHTTP_LOGDEBUG(F("_buildRequest()"));
// Build the header.
if ( ! _request)
@ -1135,8 +1220,8 @@ bool AsyncHTTPRequest::_buildRequest()
}
// New in v1.1.1
AHTTP_LOGDEBUG1("_HTTPmethod =", _HTTPmethod);
AHTTP_LOGDEBUG3(_HTTPmethodStringwithSpace[_HTTPmethod], _URL->path, _URL->query, " HTTP/1.1\r\n" );
AHTTP_LOGDEBUG1(F("_HTTPmethod ="), _HTTPmethod);
AHTTP_LOGDEBUG3(_HTTPmethodStringwithSpace[_HTTPmethod], _URL->path, _URL->query, F("HTTP/1.1\r\n") );
//////
// New in v1.1.0
@ -1159,7 +1244,7 @@ bool AsyncHTTPRequest::_buildRequest()
_request->write(hdr->value);
_request->write("\r\n");
AHTTP_LOGDEBUG3(hdr->name, ":", hdr->value, "\r\n" );
AHTTP_LOGDEBUG3(hdr->name, F(":"), hdr->value, F("\r\n"));
hdr = hdr->next;
}
@ -1178,29 +1263,25 @@ size_t AsyncHTTPRequest::_send()
if ( ! _request)
return 0;
AHTTP_LOGDEBUG1("_send(), _request->available =", _request->available());
AHTTP_LOGDEBUG1(F("_send(), _request->available ="), _request->available());
#if 1
if ( ! _client->connected())
{
AHTTP_LOGDEBUG("!connected");
AHTTP_LOGDEBUG(F("!connected yet"));
// KH fix bug https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/38
_HTTPcode = HTTPCODE_NOT_CONNECTED;
_setReadyState(readyStateUnsent);
///////////////////////////
return 0;
}
else if ( ! _client->canSend())
{
AHTTP_LOGDEBUG("*can't send");
AHTTP_LOGDEBUG(F("*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();
@ -1235,7 +1316,7 @@ size_t AsyncHTTPRequest::_send()
_client->send();
AHTTP_LOGDEBUG1("*send", sent);
AHTTP_LOGDEBUG1(F("*send"), sent);
_lastActivity = millis();
@ -1249,7 +1330,7 @@ void AsyncHTTPRequest::_setReadyState(reqStates newState)
{
_readyState = newState;
AHTTP_LOGDEBUG1("_setReadyState :", _readyState);
AHTTP_LOGDEBUG1(F("_setReadyState :"), _readyState);
if (_readyStateChangeCB)
{
@ -1263,7 +1344,7 @@ void AsyncHTTPRequest::_processChunks()
{
while (_chunks->available())
{
AHTTP_LOGDEBUG3("_processChunks()", _chunks->peekString(16).c_str(), ", chunks available =", _chunks->available());
AHTTP_LOGDEBUG3(F("_processChunks()"), _chunks->peekString(16).c_str(), F(", chunks available ="), _chunks->available());
size_t _chunkRemaining = _contentLength - _contentRead - _response->available();
_chunkRemaining -= _response->write(_chunks, _chunkRemaining);
@ -1275,7 +1356,7 @@ void AsyncHTTPRequest::_processChunks()
String chunkHeader = _chunks->readStringUntil("\r\n");
AHTTP_LOGDEBUG3("*getChunkHeader", chunkHeader.c_str(), ", chunkHeader length =", chunkHeader.length());
AHTTP_LOGDEBUG3(F("*getChunkHeader"), chunkHeader.c_str(), F(", chunkHeader length ="), chunkHeader.length());
size_t chunkLength = strtol(chunkHeader.c_str(), nullptr, 16);
_contentLength += chunkLength;
@ -1286,13 +1367,13 @@ void AsyncHTTPRequest::_processChunks()
if (connectionHdr && (strcasecmp_P(connectionHdr, PSTR("close")) == 0))
{
AHTTP_LOGDEBUG("*all chunks received - closing TCP");
AHTTP_LOGDEBUG(F("*all chunks received - closing TCP"));
_client->close();
}
else
{
AHTTP_LOGDEBUG("*all chunks received - no disconnect");
AHTTP_LOGDEBUG(F("*all chunks received - no disconnect"));
}
_requestEndTime = millis();
@ -1317,7 +1398,7 @@ void AsyncHTTPRequest::_processChunks()
//**************************************************************************************************************
void AsyncHTTPRequest::_onConnect(AsyncClient* client)
{
AHTTP_LOGDEBUG("_onConnect handler");
AHTTP_LOGDEBUG(F("_onConnect handler"));
MUTEX_LOCK_NR
@ -1334,7 +1415,7 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
_AHTTP_unlock;
// KH, to remove
AHTTP_LOGDEBUG("_onConnect: Can't new _responser");
//AHTTP_LOGERROR(F("_onConnect: Can't new _response"));
///////
return;
@ -1382,7 +1463,7 @@ void AsyncHTTPRequest::_onPoll(AsyncClient* client)
_client->close();
_HTTPcode = HTTPCODE_TIMEOUT;
AHTTP_LOGDEBUG("_onPoll timeout");
AHTTP_LOGDEBUG(F("_onPoll timeout"));
}
if (_onDataCB && available())
@ -1398,7 +1479,8 @@ void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
{
(void) client;
AHTTP_LOGDEBUG1("_onError handler error =", error);
//AHTTP_LOGERROR1(F("_onError handler error ="), error);
AHTTP_LOGERROR1(F("_onError handler error ="), client->errorToString(error));
_HTTPcode = error;
}
@ -1408,23 +1490,25 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
{
(void) client;
AHTTP_LOGDEBUG("\n_onDisconnect handler");
AHTTP_LOGDEBUG(F("\n_onDisconnect handler"));
MUTEX_LOCK_NR
if (_readyState < readyStateOpened)
{
AHTTP_LOGDEBUG("HTTPCODE_NOT_CONNECTED");
AHTTP_LOGERROR(F("HTTPCODE_NOT_CONNECTED"));
_HTTPcode = HTTPCODE_NOT_CONNECTED;
}
else if (_HTTPcode > 0 &&
(_readyState < readyStateHdrsRecvd || (_contentRead + _response->available()) < _contentLength))
{
AHTTP_LOGDEBUG("HTTPCODE_CONNECTION_LOST");
AHTTP_LOGDEBUG(F("_onDisconnect: HTTPCODE_CONNECTION_LOST"));
_HTTPcode = HTTPCODE_CONNECTION_LOST;
}
AHTTP_LOGDEBUG1("_HTTPcode = ", _HTTPcode);
AHTTP_LOGDEBUG1(F("_onDisconnect: _HTTPcode ="), _HTTPcode);
AHTTP_LOGDEBUG1(F("_onDisconnect: _HTTPcode ="), responseHTTPString());
SAFE_DELETE_ARRAY(_connectedHost)
@ -1441,7 +1525,7 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
//**************************************************************************************************************
void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
{
AHTTP_LOGDEBUG3("_onData handler", (char*) Vbuf, ", len =", len);
AHTTP_LOGDEBUG3(F("_onData handler"), (char*) Vbuf, F(", len ="), len);
MUTEX_LOCK_NR
@ -1453,7 +1537,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
_chunks->write((uint8_t*)Vbuf, len);
// KH, to remove
AHTTP_LOGDEBUG("_onData: _processChunks");
//AHTTP_LOGDEBUG(F("_onData: _processChunks"));
///////
_processChunks();
@ -1471,7 +1555,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
_AHTTP_unlock;
// KH, to remove
AHTTP_LOGDEBUG("_onData: headers not complete");
//AHTTP_LOGERROR(F("_onData: headers not complete"));
///////
return;
@ -1491,13 +1575,13 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
if (connectionHdr && (strcasecmp_P(connectionHdr, PSTR("close")) == 0))
{
AHTTP_LOGDEBUG("*all data received - closing TCP");
AHTTP_LOGDEBUG(F("*all data received - closing TCP"));
_client->close();
}
else
{
AHTTP_LOGDEBUG("*all data received - no disconnect");
AHTTP_LOGDEBUG(F("*all data received - no disconnect"));
}
_requestEndTime = millis();
@ -1519,7 +1603,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
//**************************************************************************************************************
bool AsyncHTTPRequest::_collectHeaders()
{
AHTTP_LOGDEBUG("_collectHeaders()");
AHTTP_LOGDEBUG(F("_collectHeaders()"));
// Loop to parse off each header line. Drop out and return false if no \r\n (incomplete)
do
@ -1571,7 +1655,7 @@ bool AsyncHTTPRequest::_collectHeaders()
if (hdr && strcasecmp_P(hdr->value, PSTR("chunked")) == 0)
{
AHTTP_LOGDEBUG("*transfer-encoding: chunked");
AHTTP_LOGDEBUG(F("*transfer-encoding: chunked"));
_chunked = true;
_contentLength = 0;