Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06c722029d | ||
|
|
c84d355d1b | ||
|
|
3949066843 | ||
|
|
ce452fb60f | ||
|
|
887bdef1cd |
@@ -45,6 +45,8 @@
|
||||
* [3. HOWTO use Serial Port for Debugging](#3-howto-use-serial-port-for-debugging)
|
||||
* [HOWTO use ESP8266 with W5x00 Ethernet](#HOWTO-use-ESP8266-with-W5x00-Ethernet)
|
||||
* [1. ESP8266 Wiring](#1-ESP8266-wiring)
|
||||
* [HOWTO use ESP32 with LwIP W5500 or ENC28J60 Ethernet](#HOWTO-use-ESP32-with-LwIP-W5500-or-ENC28J60-Ethernet)
|
||||
* [1. ESP32 Wiring](#1-ESP32-wiring)
|
||||
* [Examples](#examples)
|
||||
* [For ESP32 and ESP8266](#for-esp32-and-esp8266)
|
||||
* [1. AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
|
||||
@@ -65,6 +67,9 @@
|
||||
* [For ESP32_ENC](#for-ESP32_ENC) **New**
|
||||
* [1. AsyncHTTPRequest_ESP32_ENC](examples/ESP32_ENC/AsyncHTTPRequest_ESP32_ENC)
|
||||
* [2. AsyncHTTPMultiRequests_ESP32_ENC](examples/ESP32_ENC/AsyncHTTPMultiRequests_ESP32_ENC)
|
||||
* [For ESP32_W5500](#For-ESP32_W5500) **New**
|
||||
* [1. AsyncHTTPRequest_ESP32_W5500](examples/ESP32_W5500/AsyncHTTPRequest_ESP32_W5500)
|
||||
* [2. AsyncHTTPMultiRequests_ESP32_W5500](examples/ESP32_W5500/AsyncHTTPMultiRequests_ESP32_W5500)
|
||||
* [For ESP or STM32](#For-ESP-or-STM32)
|
||||
* [1. **multiFileProject**](examples/multiFileProject) **New**
|
||||
* [Example AsyncHTTPRequest_STM32](#example-asynchttprequest_stm32)
|
||||
@@ -83,6 +88,7 @@
|
||||
* [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**
|
||||
* [12. AsyncHTTPRequest_ESP32_ENC on ESP32_DEV with ESP32_ENC28J60](#12-AsyncHTTPRequest_ESP32_ENC-on-ESP32_DEV-with-ESP32_ENC28J60) **New**
|
||||
* [13. AsyncHTTPRequest_ESP32_W5500 on ESP32_DEV with ESP32_W5500](#13-AsyncHTTPRequest_ESP32_W5500-on-ESP32_DEV-with-ESP32_W5500) **New**
|
||||
* [Debug](#debug)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
* [Issues](#issues)
|
||||
@@ -175,6 +181,8 @@ Support for LAN8720 has been **removed** from STM32 core v2.3.0
|
||||
|
||||
#### 6. **ESP32 boards using LwIP ENC28J60 Ethernet**
|
||||
|
||||
#### 7. **ESP32 boards using LwIP W5500 Ethernet**
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
@@ -193,6 +201,7 @@ Support for LAN8720 has been **removed** from STM32 core v2.3.0
|
||||
12. [`LittleFS_esp32 v1.0.6+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS with ESP32 core **v1.0.5-**. To install, check [](https://www.ardu-badge.com/LittleFS_esp32). **Notice**: This [`LittleFS_esp32 library`](https://github.com/lorol/LITTLEFS) has been integrated to Arduino [ESP32 core v1.0.6+](https://github.com/espressif/arduino-esp32/tree/master/libraries/LITTLEFS) and **you don't need to install it if using ESP32 core v1.0.6+**
|
||||
13. [`WebServer_WT32_ETH01 library v1.5.1+`](https://github.com/khoih-prog/WebServer_WT32_ETH01) if necessary to use WT32_ETH01 boards. To install, check [](https://www.ardu-badge.com/WebServer_WT32_ETH01)
|
||||
14. [`WebServer_ESP32_ENC library v1.5.1+`](https://github.com/khoih-prog/WebServer_ESP32_ENC) if necessary to use ESP32 boards using LwIP ENC28J60 Ethernet. To install, check [](https://www.ardu-badge.com/WebServer_ESP32_ENC)
|
||||
15. [`WebServer_ESP32_W5500 library v1.5.1+`](https://github.com/khoih-prog/WebServer_ESP32_W5500) if necessary to use ESP32 boards using LwIP W5500 Ethernet. To install, check [](https://www.ardu-badge.com/WebServer_ESP32_W5500)
|
||||
|
||||
---
|
||||
|
||||
@@ -344,22 +353,22 @@ Please have a look at [**ESP_WiFiManager Issue 39: Not able to read analog port
|
||||
|
||||
#### 2. ESP32 ADCs functions
|
||||
|
||||
- ADC1 controls ADC function for pins **GPIO32-GPIO39**
|
||||
- ADC2 controls ADC function for pins **GPIO0, 2, 4, 12-15, 25-27**
|
||||
- `ADC1` controls `ADC` function for pins **GPIO32-GPIO39**
|
||||
- `ADC2` controls `ADC` function for pins **GPIO0, 2, 4, 12-15, 25-27**
|
||||
|
||||
#### 3.. ESP32 WiFi uses ADC2 for WiFi functions
|
||||
|
||||
Look in file [**adc_common.c**](https://github.com/espressif/esp-idf/blob/master/components/driver/adc_common.c#L61)
|
||||
|
||||
> In ADC2, there're two locks used for different cases:
|
||||
> In `ADC2`, there're two locks used for different cases:
|
||||
> 1. lock shared with app and Wi-Fi:
|
||||
> ESP32:
|
||||
> When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed.
|
||||
> When Wi-Fi using the `ADC2`, we assume it will never stop, so app checks the lock and returns immediately if failed.
|
||||
> ESP32S2:
|
||||
> The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.
|
||||
>
|
||||
> 2. lock shared between tasks:
|
||||
> when several tasks sharing the ADC2, we want to guarantee
|
||||
> when several tasks sharing the `ADC2`, we want to guarantee
|
||||
> all the requests will be handled.
|
||||
> Since conversions are short (about 31us), app returns the lock very soon,
|
||||
> we use a spinlock to stand there waiting to do conversions one by one.
|
||||
@@ -367,10 +376,10 @@ Look in file [**adc_common.c**](https://github.com/espressif/esp-idf/blob/master
|
||||
> adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.
|
||||
|
||||
|
||||
- In order to use ADC2 for other functions, we have to **acquire complicated firmware locks and very difficult to do**
|
||||
- So, it's not advisable to use ADC2 with WiFi/BlueTooth (BT/BLE).
|
||||
- Use ADC1, and pins GPIO32-GPIO39
|
||||
- If somehow it's a must to use those pins serviced by ADC2 (**GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27**), use the **fix mentioned at the end** of [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to work with ESP32 WiFi/BlueTooth (BT/BLE).
|
||||
- In order to use `ADC2` for other functions, we have to **acquire complicated firmware locks and very difficult to do**
|
||||
- So, it's not advisable to use `ADC2` with WiFi/BlueTooth (BT/BLE).
|
||||
- Use `ADC1`, and pins **GPIO32-GPIO39**
|
||||
- If somehow it's a must to use those pins serviced by `ADC2` (**GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27**), use the **fix mentioned at the end** of [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to work with ESP32 WiFi/BlueTooth (BT/BLE).
|
||||
|
||||
---
|
||||
---
|
||||
@@ -437,7 +446,7 @@ Connect FDTI (USB to Serial) as follows:
|
||||
|
||||
#### 1. ESP8266 Wiring
|
||||
|
||||
This is the wiring for EP8266 `W5x00` or `ENC28J60` Ethernet when using `SS = GPIO16`
|
||||
This is the wiring for ESP8266 `W5x00` or `ENC28J60` Ethernet when using `SS = GPIO16`
|
||||
|
||||
https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/e3dd512e7aa9e60c85043893d4527d3b052077c0/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino#L65
|
||||
|
||||
@@ -451,6 +460,27 @@ https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/e3dd512e7aa9e60c8504
|
||||
|GND|<--->|GND|
|
||||
|VCC|<--->|+3.3V|
|
||||
|
||||
---
|
||||
|
||||
### HOWTO use ESP32 with LwIP W5500 or ENC28J60 Ethernet
|
||||
|
||||
#### 1. ESP32 Wiring
|
||||
|
||||
This is the wiring for ESP8266 `W5500` or `ENC28J60` Ethernet when using `SS = GPIO5`
|
||||
|
||||
https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/ce452fb60f63c14b1deb12ca63524f3a74976194/examples/ESP32_ENC/AsyncHTTPRequest_ESP32_ENC/AsyncHTTPRequest_ESP32_ENC.ino#L60-L70
|
||||
|
||||
|
||||
|W5x00/ENC28J60 Ethernet|<--->|ESP32|
|
||||
|:-:|:-:|:-:|
|
||||
|MOSI|<--->|MOSI = GPIO23|
|
||||
|MISO|<--->|MISO = GPIO19|
|
||||
|SCK|<--->|SCK = GPIO18|
|
||||
|SS|<--->|GPIO5|
|
||||
|INT|<--->|GPIO4|
|
||||
|GND|<--->|GND|
|
||||
|VCC|<--->|+3.3V|
|
||||
|
||||
|
||||
---
|
||||
---
|
||||
@@ -481,9 +511,14 @@ https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/e3dd512e7aa9e60c8504
|
||||
|
||||
#### For ESP32_ENC
|
||||
|
||||
1. [AsyncHTTPRequest_ESP32_ENC](examples/WT32_ETH01/AsyncHTTPRequest_ESP32_ENC) **New**
|
||||
2. [AsyncHTTPMultiRequests_ESP32_ENC](examples/WT32_ETH01/AsyncHTTPMultiRequests_ESP32_ENC) **New**
|
||||
1. [AsyncHTTPRequest_ESP32_ENC](examples/ESP32_ENC/AsyncHTTPRequest_ESP32_ENC) **New**
|
||||
2. [AsyncHTTPMultiRequests_ESP32_ENC](examples/ESP32_ENC/AsyncHTTPMultiRequests_ESP32_ENC) **New**
|
||||
|
||||
#### For ESP32_W5500
|
||||
|
||||
1. [AsyncHTTPRequest_ESP32_W5500](examples/ESP32_W5500/AsyncHTTPRequest_ESP32_W5500) **New**
|
||||
2. [AsyncHTTPMultiRequests_ESP32_W5500](examples/ESP32_W5500/AsyncHTTPMultiRequests_ESP32_W5500) **New**
|
||||
|
||||
#### For ESP or STM32
|
||||
|
||||
1. [**multiFileProject**](examples/multiFileProject) **New**
|
||||
@@ -516,7 +551,7 @@ https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/639ce917e54c296f15fd
|
||||
|
||||
```cpp
|
||||
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
AsyncHTTPRequest @ IP : 192.168.2.178
|
||||
|
||||
**************************************
|
||||
@@ -562,7 +597,7 @@ week_number: 48
|
||||
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Stored: SSID = HueNet1, Pass = 12345678
|
||||
Got stored Credentials. Timeout 120s
|
||||
ConnectMultiWiFi in setup
|
||||
@@ -594,7 +629,7 @@ HHHHHH
|
||||
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Stored: SSID = HueNet1, Pass = 12345678
|
||||
Got stored Credentials. Timeout 120s
|
||||
ConnectMultiWiFi in setup
|
||||
@@ -644,7 +679,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
|
||||
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Connecting to WiFi SSID: HueNet1
|
||||
...........
|
||||
HTTP WebServer is @ IP : 192.168.2.81
|
||||
@@ -676,7 +711,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
|
||||
|
||||
```cpp
|
||||
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
AsyncHTTPRequest @ IP : 192.168.2.72
|
||||
|
||||
**************************************
|
||||
@@ -730,7 +765,7 @@ AsyncHTTPRequest @ IP : 192.168.2.72
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
|
||||
WebServer_WT32_ETH01 v1.5.1
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
|
||||
AsyncHTTPRequest @ IP : 192.168.2.232
|
||||
|
||||
@@ -760,7 +795,7 @@ week_number: 48
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP32C3_DEV
|
||||
ESPAsync_WiFiManager v1.15.0
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Stored: SSID = HueNet1, Pass = password
|
||||
Got stored Credentials. Timeout 120s
|
||||
ConnectMultiWiFi in setup
|
||||
@@ -811,7 +846,7 @@ week_number: 48
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP32S3_DEV
|
||||
ESPAsync_WiFiManager v1.15.0
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Stored: SSID = HueNet1, Pass = password
|
||||
Got stored Credentials. Timeout 120s
|
||||
ConnectMultiWiFi in setup
|
||||
@@ -862,7 +897,7 @@ The terminal output of [AsyncHTTPRequest_ESP_Multi example](examples/AsyncHTTPRe
|
||||
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP_Multi using ESP32_DEV
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Connecting to WiFi SSID: HueNet1
|
||||
.......
|
||||
AsyncHTTPSRequest @ IP : 192.168.2.88
|
||||
@@ -923,7 +958,7 @@ The terminal output of [AsyncHTTPRequest_ESP8266_Ethernet example](examples/Asyn
|
||||
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP8266_Ethernet on ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Connecting ethernet..
|
||||
Ethernet IP address: 192.168.2.187
|
||||
|
||||
@@ -973,7 +1008,7 @@ The terminal output of [AsyncHTTPRequest_ESP8266_Ethernet example](examples/Asyn
|
||||
|
||||
```cpp
|
||||
Starting AsyncHTTPRequest_ESP8266_Ethernet on ESP8266_NODEMCU_ESP12E using ESP8266_ENC28J60 Ethernet
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
Connecting to network : ..........................................................
|
||||
Ethernet IP address: 192.168.2.187
|
||||
|
||||
@@ -1017,14 +1052,14 @@ week_number: 48
|
||||
---
|
||||
|
||||
|
||||
#### 12. [AsyncHTTPRequest_ESP32_ENC](examples/AsyncHTTPRequest_ESP32_ENC) on ESP32_DEV with ESP32_ENC28J60
|
||||
#### 12. [AsyncHTTPRequest_ESP32_ENC](examples/ESP32_ENC/AsyncHTTPRequest_ESP32_ENC) on ESP32_DEV with ESP32_ENC28J60
|
||||
|
||||
The terminal output of [AsyncHTTPRequest_ESP32_ENC example](examples/AsyncHTTPRequest_ESP32_ENC) running on `ESP32_DEV with ESP32_ENC28J60` to demonstrate how to use ESP32 LwIP ENC28J60 Ethernet Async feature.
|
||||
The terminal output of [AsyncHTTPRequest_ESP32_ENC example](examples/AsyncHTTPRequest_ESP32_ENC) running on `ESP32_DEV with ESP32_ENC28J60` to demonstrate how to use ESP32 `LwIP ENC28J60 Ethernet Async` feature.
|
||||
|
||||
```cpp
|
||||
Start AsyncHTTPRequest_ESP32_ENC on ESP32_DEV with ESP32_ENC28J60
|
||||
WebServer_ESP32_ENC v1.5.1 for core v2.0.0+
|
||||
AsyncHTTPRequest_Generic v1.11.0
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
|
||||
ETH Started
|
||||
ETH Connected
|
||||
@@ -1071,6 +1106,61 @@ week_number: 48
|
||||
```
|
||||
|
||||
|
||||
#### 13. [AsyncHTTPRequest_ESP32_W5500](examples/ESP32_W5500/AsyncHTTPRequest_ESP32_W5500) on ESP32_DEV with ESP32_W5500
|
||||
|
||||
The terminal output of [AsyncHTTPRequest_ESP32_W5500 example](examples/AsyncHTTPRequest_ESP32_W5500) running on `ESP32_DEV with ESP32_W5500` to demonstrate how to use ESP32 `LwIP W5500 Ethernet Async` feature.
|
||||
|
||||
```cpp
|
||||
Start AsyncHTTPRequest_ESP32_W5500 on ESP32_DEV with ESP32_W5500
|
||||
WebServer_ESP32_W5500 v1.5.1 for core v2.0.0+
|
||||
AsyncHTTPRequest_Generic v1.12.0
|
||||
|
||||
ETH Started
|
||||
ETH Connected
|
||||
ETH MAC: DE:AD:BE:EF:FE:11, IPv4: 192.168.2.101
|
||||
FULL_DUPLEX, 100Mbps
|
||||
|
||||
HTTP WebClient is @ IP : 192.168.2.101
|
||||
|
||||
**************************************
|
||||
abbreviation: EST
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2022-11-30T16:37:13.534844-05:00
|
||||
day_of_week: 3
|
||||
day_of_year: 334
|
||||
dst: false
|
||||
dst_from:
|
||||
dst_offset: 0
|
||||
dst_until:
|
||||
raw_offset: -18000
|
||||
timezone: America/Toronto
|
||||
unixtime: 1669844233
|
||||
utc_datetime: 2022-11-30T21:37:13.534844+00:00
|
||||
utc_offset: -05:00
|
||||
week_number: 48
|
||||
**************************************
|
||||
HHHHHH
|
||||
**************************************
|
||||
abbreviation: EST
|
||||
client_ip: aaa.bbb.ccc.ddd
|
||||
datetime: 2022-11-30T16:38:13.531153-05:00
|
||||
day_of_week: 3
|
||||
day_of_year: 334
|
||||
dst: false
|
||||
dst_from:
|
||||
dst_offset: 0
|
||||
dst_until:
|
||||
raw_offset: -18000
|
||||
timezone: America/Toronto
|
||||
unixtime: 1669844293
|
||||
utc_datetime: 2022-11-30T21:38:13.531153+00:00
|
||||
utc_offset: -05:00
|
||||
week_number: 48
|
||||
**************************************
|
||||
HHHH
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
@@ -1137,9 +1227,10 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
|
||||
22. Not try to reconnect to the same `host:port` after connected
|
||||
23. Fix bug of wrong `reqStates` introduced from `v1.9.0`
|
||||
24. Default to reconnect to the same `host:port` after connected for new HTTP sites.
|
||||
25. Add support to ESP32 boards using LwIP ENC28J60 Ethernet
|
||||
25. Add support to ESP32 boards using `LwIP ENC28J60 Ethernet`
|
||||
26. Use `allman astyle` and add `utils`. Restyle the library
|
||||
|
||||
27. Add support to ESP32 boards using `LwIP W5500 Ethernet`
|
||||
28. [Fix "blank new line in chunk" bug #50](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/50)
|
||||
|
||||
---
|
||||
---
|
||||
@@ -1160,6 +1251,7 @@ This library is based on, modified, bug-fixed and improved from:
|
||||
10. Thanks to [ValentinsStorre](https://github.com/ValentinsStorre) to report [Release 1.9 breaks previously running code #39](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/39) leading to new release v1.10.1
|
||||
11. Thanks to [Dirk Vranckaert](https://github.com/dirkvranckaert) to report [Callback behaviour is buggy (ESP8266) #43](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/43) leading to new release v1.10.1
|
||||
12. Thanks to [SeeliSoft](https://github.com/SeeliSoft-CH) to report [Host/Headers not always sent with 1.10.1 #44](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/44) leading to new release v1.10.2
|
||||
13. Thanks to [1618033](https://github.com/1618033) to make PR [Fix "blank new line in chunk" bug #50](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/50) leading to new release v1.12.0
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -1177,6 +1269,9 @@ This library is based on, modified, bug-fixed and improved from:
|
||||
<td align="center"><a href="https://github.com/ValentinsStorre"><img src="https://github.com/ValentinsStorre.png" width="100px;" alt="ValentinsStorre"/><br /><sub><b>ValentinsStorre</b></sub></a><br /></td>
|
||||
<td align="center"><a href="https://github.com/dirkvranckaert"><img src="https://github.com/dirkvranckaert.png" width="100px;" alt="dirkvranckaert"/><br /><sub><b>Dirk Vranckaert</b></sub></a><br /></td>
|
||||
<td align="center"><a href="https://github.com/SeeliSoft-CH"><img src="https://github.com/SeeliSoft-CH.png" width="100px;" alt="SeeliSoft-CH"/><br /><sub><b>SeeliSoft</b></sub></a><br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/1618033"><img src="https://github.com/1618033.png" width="100px;" alt="1618033"/><br /><sub><b>1618033</b></sub></a><br /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
+7
-1
@@ -18,6 +18,7 @@
|
||||
## Table of Contents
|
||||
|
||||
* [Changelog](#changelog)
|
||||
* [Releases v1.12.0](#releases-v1120)
|
||||
* [Releases v1.11.0](#releases-v1110)
|
||||
* [Releases v1.10.2](#releases-v1102)
|
||||
* [Releases v1.10.1](#releases-v1101)
|
||||
@@ -52,9 +53,14 @@
|
||||
|
||||
## Changelog
|
||||
|
||||
### Releases v1.12.0
|
||||
|
||||
1. Add support to ESP32 boards using `LwIP W5500 Ethernet`
|
||||
2. Fix bug. Check [Fix "blank new line in chunk" bug #50](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/pull/50)
|
||||
|
||||
### Releases v1.11.0
|
||||
|
||||
1. Add support to ESP32 boards using LwIP ENC28J60 Ethernet
|
||||
1. Add support to ESP32 boards using `LwIP ENC28J60 Ethernet`
|
||||
2. Use `allman astyle` and add `utils`. Restyle the library
|
||||
|
||||
### Releases v1.10.2
|
||||
|
||||
+308
@@ -0,0 +1,308 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPMultiRequests_ESP32_W5500.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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/>.
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
|
||||
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
|
||||
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
|
||||
// headers and payload, gathering the response headers and any payload, and processing
|
||||
// of that response, can (and probably should) all be done asynchronously.
|
||||
//
|
||||
// In this example, a Ticker function is setup to fire every 300 seconds to initiate a request.
|
||||
// Everything is handled in AsyncHTTPRequest without blocking.
|
||||
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
|
||||
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
|
||||
//
|
||||
// Note that there is no code in loop(). A code entered into loop would run oblivious to
|
||||
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
|
||||
// could be made in loop(), resulting in the same asynchronous handling.
|
||||
//
|
||||
// For demo purposes, debug is turned on for handling of the first request. These are the
|
||||
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
|
||||
// nnn is the elapsed time in milliseconds since the transaction was started.
|
||||
//
|
||||
//*************************************************************************************************************
|
||||
|
||||
#if !( defined(ESP32) )
|
||||
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
|
||||
// 10s
|
||||
#define HEARTBEAT_INTERVAL 10
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
// Optional values to override default settings
|
||||
// Don't change unless you know what you're doing
|
||||
//#define ETH_SPI_HOST SPI3_HOST
|
||||
//#define SPI_CLOCK_MHZ 25
|
||||
|
||||
// Must connect INT to GPIOxx or not working
|
||||
//#define INT_GPIO 4
|
||||
|
||||
//#define MISO_GPIO 19
|
||||
//#define MOSI_GPIO 23
|
||||
//#define SCK_GPIO 18
|
||||
//#define CS_GPIO 5
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#include <WebServer_ESP32_W5500.h> // https://github.com/khoih-prog/WebServer_ESP32_W5500
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.12.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1012000
|
||||
|
||||
// Uncomment for certain HTTP site to optimize
|
||||
//#define NOT_SEND_HEADER_AFTER_CONNECTED true
|
||||
|
||||
// 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
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
Ticker ticker;
|
||||
Ticker ticker1;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
|
||||
};
|
||||
|
||||
// Select the IP address according to your local network
|
||||
IPAddress myIP(192, 168, 2, 232);
|
||||
IPAddress myGW(192, 168, 2, 1);
|
||||
IPAddress mySN(255, 255, 255, 0);
|
||||
|
||||
// Google DNS Server IP
|
||||
IPAddress myDNS(8, 8, 8, 8);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
void heartBeatPrint(void)
|
||||
{
|
||||
static int num = 1;
|
||||
|
||||
if (ESP32_W5500_isConnected())
|
||||
Serial.print(F("H")); // H means connected to WiFi
|
||||
else
|
||||
Serial.print(F("F")); // F means not connected to WiFi
|
||||
|
||||
if (num == 80)
|
||||
{
|
||||
Serial.println();
|
||||
num = 1;
|
||||
}
|
||||
else if (num++ % 10 == 0)
|
||||
{
|
||||
Serial.print(F(" "));
|
||||
}
|
||||
}
|
||||
|
||||
// To replace with your real APP_API
|
||||
#define APP_API "SECRECT_APP_API"
|
||||
|
||||
String requestPart1 = "http://api.openweathermap.org/data/2.5/onecall?lat=-24.32&lon=-46.9983";
|
||||
String requestAPPID = "&appid=" + String(APP_API);
|
||||
|
||||
// exclude fields: current,minutely,hourly,daily,alerts
|
||||
String requestCurrent = requestPart1 + "&exclude=minutely,hourly,daily,alerts" + requestAPPID;
|
||||
String requestMinutely = requestPart1 + "&exclude=current,hourly,daily,alerts" + requestAPPID;
|
||||
String requestHourly = requestPart1 + "&exclude=current,minutely,daily,alerts" + requestAPPID;
|
||||
String requestDaily = requestPart1 + "&exclude=current,minutely,hourly,alerts" + requestAPPID;
|
||||
String requestAlert = requestPart1 + "&exclude=current,minutely,hourly,daily" + requestAPPID;
|
||||
|
||||
#define NUM_REQUESTS 5
|
||||
|
||||
const char* requestName[ NUM_REQUESTS ] = { "Current", "Minutely", "Hourly", "Daily", "Alert" };
|
||||
|
||||
const char* requestAll[ NUM_REQUESTS ] = { requestCurrent.c_str(), requestMinutely.c_str(), requestHourly.c_str(), requestDaily.c_str(), requestAlert.c_str() };
|
||||
|
||||
uint8_t requestIndex = 0;
|
||||
|
||||
void sendRequest()
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
requestOpenResult = request.open("GET", requestAll[requestIndex] );
|
||||
|
||||
if (requestOpenResult)
|
||||
{
|
||||
// Only send() if open() returns true, or crash
|
||||
request.send();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Can't send bad request");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Can't send request");
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if (requestIndex == 1)
|
||||
requestIndex = 3;
|
||||
else
|
||||
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
|
||||
|
||||
#else
|
||||
// hourly too long, not display anyway. Not enough heap.
|
||||
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
|
||||
#endif
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
delay(200);
|
||||
|
||||
Serial.print("\nStart AsyncHTTPMultiRequests_ESP32_W5500 on ");
|
||||
Serial.print(ARDUINO_BOARD);
|
||||
Serial.print(" with ");
|
||||
Serial.println(SHIELD_TYPE);
|
||||
Serial.println(WEBSERVER_ESP32_W5500_VERSION);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
|
||||
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
{
|
||||
Serial.print("Warning. Must use this example on Version equal or later than : ");
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
AHTTP_LOGWARN(F("Default SPI pinout:"));
|
||||
AHTTP_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
|
||||
AHTTP_LOGWARN1(F("MOSI:"), MOSI_GPIO);
|
||||
AHTTP_LOGWARN1(F("MISO:"), MISO_GPIO);
|
||||
AHTTP_LOGWARN1(F("SCK:"), SCK_GPIO);
|
||||
AHTTP_LOGWARN1(F("CS:"), CS_GPIO);
|
||||
AHTTP_LOGWARN1(F("INT:"), INT_GPIO);
|
||||
AHTTP_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
|
||||
AHTTP_LOGWARN(F("========================="));
|
||||
|
||||
///////////////////////////////////
|
||||
|
||||
// To be called before ETH.begin()
|
||||
ESP32_W5500_onEvent();
|
||||
|
||||
// start the ethernet connection and the server:
|
||||
// Use DHCP dynamic IP and random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
|
||||
// int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac);
|
||||
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
|
||||
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] );
|
||||
|
||||
// Static IP, leave without this line to get IP via DHCP
|
||||
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
|
||||
//ETH.config(myIP, myGW, mySN, myDNS);
|
||||
|
||||
ESP32_W5500_waitForConnect();
|
||||
|
||||
///////////////////////////////////
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(ETH.localIP());
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
|
||||
|
||||
ticker1.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
|
||||
|
||||
// Send first request now
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPRequest_ESP32_W5500.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
|
||||
|
||||
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
|
||||
|
||||
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
|
||||
|
||||
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
|
||||
|
||||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
Licensed under MIT license
|
||||
|
||||
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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/>.
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
|
||||
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
|
||||
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
|
||||
// headers and payload, gathering the response headers and any payload, and processing
|
||||
// of that response, can (and probably should) all be done asynchronously.
|
||||
//
|
||||
// In this example, a Ticker function is setup to fire every 300 seconds to initiate a request.
|
||||
// Everything is handled in AsyncHTTPRequest without blocking.
|
||||
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
|
||||
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
|
||||
//
|
||||
// Note that there is no code in loop(). A code entered into loop would run oblivious to
|
||||
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
|
||||
// could be made in loop(), resulting in the same asynchronous handling.
|
||||
//
|
||||
// For demo purposes, debug is turned on for handling of the first request. These are the
|
||||
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
|
||||
// nnn is the elapsed time in milliseconds since the transaction was started.
|
||||
//
|
||||
//*************************************************************************************************************
|
||||
|
||||
#if !( defined(ESP32) )
|
||||
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
|
||||
// 10s
|
||||
#define HEARTBEAT_INTERVAL 10
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
// Optional values to override default settings
|
||||
// Don't change unless you know what you're doing
|
||||
//#define ETH_SPI_HOST SPI3_HOST
|
||||
//#define SPI_CLOCK_MHZ 25
|
||||
|
||||
// Must connect INT to GPIOxx or not working
|
||||
//#define INT_GPIO 4
|
||||
|
||||
//#define MISO_GPIO 19
|
||||
//#define MOSI_GPIO 23
|
||||
//#define SCK_GPIO 18
|
||||
//#define CS_GPIO 5
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#include <WebServer_ESP32_W5500.h> // https://github.com/khoih-prog/WebServer_ESP32_W5500
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.12.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1012000
|
||||
|
||||
// Uncomment for certain HTTP site to optimize
|
||||
//#define NOT_SEND_HEADER_AFTER_CONNECTED true
|
||||
|
||||
// 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
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
Ticker ticker;
|
||||
Ticker ticker1;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
// Enter a MAC address and IP address for your controller below.
|
||||
#define NUMBER_OF_MAC 20
|
||||
|
||||
byte mac[][NUMBER_OF_MAC] =
|
||||
{
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
|
||||
};
|
||||
|
||||
// Select the IP address according to your local network
|
||||
IPAddress myIP(192, 168, 2, 232);
|
||||
IPAddress myGW(192, 168, 2, 1);
|
||||
IPAddress mySN(255, 255, 255, 0);
|
||||
|
||||
// Google DNS Server IP
|
||||
IPAddress myDNS(8, 8, 8, 8);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
void heartBeatPrint(void)
|
||||
{
|
||||
static int num = 1;
|
||||
|
||||
if (ESP32_W5500_isConnected())
|
||||
Serial.print(F("H")); // H means connected
|
||||
else
|
||||
Serial.print(F("F")); // F means not connected
|
||||
|
||||
if (num == 80)
|
||||
{
|
||||
Serial.println();
|
||||
num = 1;
|
||||
}
|
||||
else if (num++ % 10 == 0)
|
||||
{
|
||||
Serial.print(F(" "));
|
||||
}
|
||||
}
|
||||
|
||||
void sendRequest()
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
//requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
|
||||
requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
|
||||
|
||||
if (requestOpenResult)
|
||||
{
|
||||
// Only send() if open() returns true, or crash
|
||||
request.send();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Can't send bad request");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Can't send request");
|
||||
}
|
||||
}
|
||||
|
||||
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("**************************************"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial && millis() < 5000);
|
||||
|
||||
delay(200);
|
||||
|
||||
Serial.print("\nStart AsyncHTTPRequest_ESP32_W5500 on ");
|
||||
Serial.print(ARDUINO_BOARD);
|
||||
Serial.print(" with ");
|
||||
Serial.println(SHIELD_TYPE);
|
||||
Serial.println(WEBSERVER_ESP32_W5500_VERSION);
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
|
||||
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
|
||||
{
|
||||
Serial.print("Warning. Must use this example on Version equal or later than : ");
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
AHTTP_LOGWARN(F("Default SPI pinout:"));
|
||||
AHTTP_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
|
||||
AHTTP_LOGWARN1(F("MOSI:"), MOSI_GPIO);
|
||||
AHTTP_LOGWARN1(F("MISO:"), MISO_GPIO);
|
||||
AHTTP_LOGWARN1(F("SCK:"), SCK_GPIO);
|
||||
AHTTP_LOGWARN1(F("CS:"), CS_GPIO);
|
||||
AHTTP_LOGWARN1(F("INT:"), INT_GPIO);
|
||||
AHTTP_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
|
||||
AHTTP_LOGWARN(F("========================="));
|
||||
|
||||
///////////////////////////////////
|
||||
|
||||
// To be called before ETH.begin()
|
||||
ESP32_W5500_onEvent();
|
||||
|
||||
// start the ethernet connection and the server:
|
||||
// Use DHCP dynamic IP and random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
|
||||
// int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac);
|
||||
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
|
||||
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] );
|
||||
|
||||
// Static IP, leave without this line to get IP via DHCP
|
||||
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
|
||||
//ETH.config(myIP, myGW, mySN, myDNS);
|
||||
|
||||
ESP32_W5500_waitForConnect();
|
||||
|
||||
///////////////////////////////////
|
||||
|
||||
Serial.print(F("\nHTTP WebClient is @ IP : "));
|
||||
Serial.println(ETH.localIP());
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
|
||||
|
||||
ticker1.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
|
||||
|
||||
// Send first request now
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
+7
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name":"AsyncHTTPRequest_Generic",
|
||||
"version": "1.11.0",
|
||||
"version": "1.12.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), ESP32 with LwIP ENC28J60, 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, nucleo-144, stm32f7, W5x00, ENC28J60",
|
||||
"authors": [
|
||||
@@ -72,6 +72,12 @@
|
||||
"version": ">=1.5.1",
|
||||
"platforms": ["espressif32"]
|
||||
},
|
||||
{
|
||||
"owner": "khoih-prog",
|
||||
"name": "WebServer_ESP32_W5500",
|
||||
"version": ">=1.5.1",
|
||||
"platforms": ["espressif32"]
|
||||
},
|
||||
{
|
||||
"name": "STM32AsyncTCP",
|
||||
"version": "https://github.com/khoih-prog/STM32AsyncTCP",
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
name=AsyncHTTPRequest_Generic
|
||||
version=1.11.0
|
||||
version=1.12.0
|
||||
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
|
||||
maintainer=Khoi Hoang <khoih.prog@gmail.com>
|
||||
license=GPLv3
|
||||
@@ -8,5 +8,5 @@ paragraph=This AsyncHTTPRequest_Generic Library, supporting GET, POST, PUT, PATC
|
||||
category=Communication
|
||||
url=https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
architectures=*
|
||||
depends=ESPAsync_WiFiManager, STM32duino LwIP, STM32duino STM32Ethernet, WebServer_WT32_ETH01, WebServer_ESP32_ENC
|
||||
depends=ESPAsync_WiFiManager, STM32duino LwIP, STM32duino STM32Ethernet, WebServer_WT32_ETH01, WebServer_ESP32_ENC, WebServer_ESP32_W5500
|
||||
includes=AsyncHTTPRequest_Generic.h, 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 1.11.0
|
||||
Version: 1.12.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -36,6 +36,7 @@
|
||||
1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates
|
||||
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
|
||||
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
|
||||
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
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.11.0
|
||||
Version: 1.12.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -36,6 +36,7 @@
|
||||
1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates
|
||||
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
|
||||
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
|
||||
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
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.11.0
|
||||
Version: 1.12.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -36,6 +36,7 @@
|
||||
1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates
|
||||
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
|
||||
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
|
||||
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -45,13 +46,13 @@
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.11.0"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.12.0"
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 11
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 12
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 0
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1011000
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1012000
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
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.11.0
|
||||
Version: 1.12.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -36,6 +36,7 @@
|
||||
1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates
|
||||
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
|
||||
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
|
||||
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -1448,7 +1449,7 @@ void AsyncHTTPRequest::_processChunks()
|
||||
size_t chunkLength = strtol(chunkHeader.c_str(), nullptr, 16);
|
||||
_contentLength += chunkLength;
|
||||
|
||||
if (chunkLength == 0)
|
||||
if (chunkHeader == "0\r\n")
|
||||
{
|
||||
char* connectionHdr = respHeaderValue("connection");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user