mirror of
https://github.com/khoih-prog/AsyncHTTPRequest_Generic.git
synced 2025-06-25 01:31:32 +02:00
v1.2.0 to add support to LAN8720 for STM32
### Releases v1.2.0 1. Add support to **LAN8720** Ethernet for many **STM32F4** (F407xx, NUCLEO_F429ZI) and **STM32F7** (DISCO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG) boards. 2. Add LAN8720 examples 3. Add Packages' Patches for STM32 to use LAN8720 with STM32Ethernet and LwIP libraries 4. Update ESP_WiFiManager-related example to fix multiWiFi timings to work better with latest esp32 core v1.0.6
This commit is contained in:
@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
|
||||
Please ensure to specify the following:
|
||||
|
||||
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
|
||||
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v2.7.4, ESP32 v1.0.5 or STM32 v1.9.0)
|
||||
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v2.7.4, ESP32 v1.0.6 or STM32 v1.9.0)
|
||||
* Contextual information (e.g. what you were trying to achieve)
|
||||
* Simplest possible steps to reproduce
|
||||
* Anything that might be relevant in your opinion, such as:
|
||||
@ -27,9 +27,9 @@ Please ensure to specify the following:
|
||||
|
||||
```
|
||||
Arduino IDE version: 1.8.13
|
||||
ESP32 Core Version 1.0.5
|
||||
ESP32 Core Version 1.0.6
|
||||
OS: Ubuntu 20.04 LTS
|
||||
Linux xy-Inspiron-3593 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
|
||||
Linux xy-Inspiron-3593 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
|
||||
|
||||
Context:
|
||||
I encountered an endless loop while trying to connect to Local WiFi.
|
||||
|
BIN
Images/STM32F407VET6.png
Normal file
BIN
Images/STM32F407VET6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 569 KiB |
236
README.md
236
README.md
@ -18,6 +18,7 @@
|
||||
* [Principles of operation](#principles-of-operation)
|
||||
* [Currently supported Boards](#currently-supported-boards)
|
||||
* [Changelog](#changelog)
|
||||
* [Releases v1.2.0](#releases-v120)
|
||||
* [Releases v1.1.5](#releases-v115)
|
||||
* [Releases v1.1.4](#releases-v114)
|
||||
* [Releases v1.1.3](#releases-v113)
|
||||
@ -43,6 +44,8 @@
|
||||
* [5. For Adafruit SAMD boards](#5-for-adafruit-samd-boards)
|
||||
* [6. For Seeeduino SAMD boards](#6-for-seeeduino-samd-boards)
|
||||
* [7. For STM32 boards](#7-for-stm32-boards)
|
||||
* [7.1. For STM32 boards to use LAN8720](#71-for-stm32-boards-to-use-lan8720)
|
||||
* [7.2. For STM32 boards to use Serial1](#72-for-stm32-boards-to-use-serial1)
|
||||
* [HOWTO Install esp32-s2 core for ESP32-S2 (Saola, AI-Thinker ESP-12K) boards into Arduino IDE)](#howto-install-esp32-s2-core-for-esp32-s2-saola-ai-thinker-esp-12k-boards-into-arduino-ide)
|
||||
* [1. Save the original esp32 core](#1-save-the-original-esp32-core)
|
||||
* [2. Download esp32-s2 core](#2-download-esp32-s2-core)
|
||||
@ -64,15 +67,29 @@
|
||||
* [1. ESP32 has 2 ADCs, named ADC1 and ADC2](#1--esp32-has-2-adcs-named-adc1-and-adc2)
|
||||
* [2. ESP32 ADCs functions](#2-esp32-adcs-functions)
|
||||
* [3. ESP32 WiFi uses ADC2 for WiFi functions](#3-esp32-wifi-uses-adc2-for-wifi-functions)
|
||||
* [HOWTO use STM32F4 with LAN8720](#howto-use-stm32f4-with-lan8720)
|
||||
* [1. Wiring](#1-wiring)
|
||||
* [2. HOWTO program using STLink V-2 or V-3](#2-howto-program-using-stlink-v-2-or-v-3)
|
||||
* [3. HOWTO use Serial Port for Debugging](#3-howto-use-serial-port-for-debugging)
|
||||
* [Examples](#examples)
|
||||
* [AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
|
||||
* [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
|
||||
* [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
|
||||
* [AsyncCustomHeader_STM32](examples/AsyncCustomHeader_STM32)
|
||||
* [AsyncDweetGet_STM32](examples/AsyncDweetGet_STM32)
|
||||
* [AsyncDweetPost_STM32](examples/AsyncDweetPost_STM32)
|
||||
* [AsyncSimpleGET_STM32](examples/AsyncSimpleGET_STM32)
|
||||
* [AsyncWebClientRepeating_STM32](examples/AsyncWebClientRepeating_STM32)
|
||||
* [For ESP32 and ESP8266](#for-esp32-and-esp8266)
|
||||
* [1. AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
|
||||
* [2. AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
|
||||
* [3. AsyncHTTPMultiRequests_ESP](examples/AsyncHTTPMultiRequests_ESP)
|
||||
* [For STM32 using LAN8742A](#for-stm32-using-lan8742a)
|
||||
* [1. AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
|
||||
* [2. AsyncCustomHeader_STM32](examples/AsyncCustomHeader_STM32)
|
||||
* [3. AsyncDweetGet_STM32](examples/AsyncDweetGet_STM32)
|
||||
* [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)
|
||||
* [Example AsyncHTTPRequest_STM32](#example-asynchttprequest_stm32)
|
||||
* [1. File AsyncHTTPRequest_STM32.ino](#1-file-asynchttprequest_stm32ino)
|
||||
* [2. File defines.h](#2-file-definesh)
|
||||
@ -82,6 +99,7 @@
|
||||
* [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)
|
||||
* [Debug](#debug)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
* [Issues](#issues)
|
||||
@ -100,10 +118,10 @@
|
||||
|
||||
### Features
|
||||
|
||||
1. Asynchronous HTTP Request library for ESP8266, including ESP32-S2 (ESP32-S2 Saola, AI-Thinker ESP-12K, etc.) using built-in WiFi, and STM32 boards using built-in LAN8742A Ethernet.
|
||||
1. Asynchronous HTTP Request library for ESP8266, including ESP32-S2 (ESP32-S2 Saola, AI-Thinker ESP-12K, etc.) using built-in WiFi, and STM32 boards using LAN8720 or built-in LAN8742A Ethernet.
|
||||
2. Providing a subset of HTTP.
|
||||
3. Relying on on **[`ESPAsyncTCP`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266, [`AsyncTCP`](https://github.com/me-no-dev/AsyncTCP) for ESP32** using built-in WiFi
|
||||
4. Relying on **[`STM32duino LwIP`](https://github.com/stm32duino/LwIP)/[`STM32duino STM32Ethernet`](https://github.com/stm32duino/STM32Ethernet)/[`STM32AsyncTCP`](https://github.com/philbowles/STM32AsyncTCP) for STM32 using built-in LAN8742A Ethernet.**
|
||||
4. Relying on **[`STM32duino LwIP`](https://github.com/stm32duino/LwIP)/[`STM32duino STM32Ethernet`](https://github.com/stm32duino/STM32Ethernet)/[`STM32AsyncTCP`](https://github.com/philbowles/STM32AsyncTCP) for STM32 using LAN8720 or built-in LAN8742A Ethernet.**
|
||||
5. Methods similar in format and usage to XmlHTTPrequest in Javascript.
|
||||
|
||||
### Supports
|
||||
@ -147,6 +165,12 @@ This library is based on, modified from:
|
||||
2. Discovery STM32F746G-DISCOVERY
|
||||
3. Any STM32 boards with enough flash/memory and already configured to run LAN8742A Ethernet.
|
||||
|
||||
#### 4. STM32 boards using Ethernet LAN8720
|
||||
|
||||
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)**
|
||||
|
||||
|
||||
---
|
||||
---
|
||||
@ -154,6 +178,13 @@ This library is based on, modified from:
|
||||
|
||||
## Changelog
|
||||
|
||||
### Releases v1.2.0
|
||||
|
||||
1. Add support to **LAN8720** Ethernet for many **STM32F4** (F407xx, NUCLEO_F429ZI) and **STM32F7** (DISCO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG) boards.
|
||||
2. Add LAN8720 examples
|
||||
3. Add Packages' Patches for STM32 to use LAN8720 with STM32Ethernet and LwIP libraries
|
||||
4. Update ESP_WiFiManager-related example to fix multiWiFi timings to work better with latest esp32 core v1.0.6
|
||||
|
||||
### Releases v1.1.5
|
||||
|
||||
1. Fix dependency on unpublished [**STM32AsyncTCP Library**](https://github.com/philbowles/STM32AsyncTCP). Check [Compilation broken due to error in STM32AsyncTCP dependency](https://github.com/khoih-prog/AsyncWebServer_STM32/issues/4) and [how to run one of the examples?](https://github.com/khoih-prog/AsyncWebServer_STM32/issues/2).
|
||||
@ -206,7 +237,7 @@ This library is based on, modified from:
|
||||
|
||||
1. [`Arduino IDE 1.8.13+` for Arduino](https://www.arduino.cc/en/Main/Software)
|
||||
2. [`ESP8266 Core 2.7.4+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [](https://github.com/esp8266/Arduino/releases/latest/)
|
||||
3. [`ESP32 Core 1.0.5+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [Latest stable release 
|
||||
3. [`ESP32 Core 1.0.6+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [Latest stable release 
|
||||
4. [`ESP32S2 Core 1.0.4+`](https://github.com/espressif/arduino-esp32/tree/esp32s2) for ESP32-S2-based boards.
|
||||
5. [`Arduino Core for STM32 1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A. [](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
|
||||
6. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266.
|
||||
@ -214,8 +245,8 @@ This library is based on, modified from:
|
||||
8. [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [](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). [](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.6.0+`](https://github.com/khoih-prog/ESPAsync_WiFiManager) for ESP32/ESP8266 using some examples. [](https://github.com/khoih-prog/ESPAsync_WiFiManager/releases)
|
||||
12. [`LittleFS_esp32 v1.0.5+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS. To install, check [](https://www.ardu-badge.com/LittleFS_esp32).
|
||||
11. [`ESPAsync_WiFiManager library v1.6.2+`](https://github.com/khoih-prog/ESPAsync_WiFiManager) for ESP32/ESP8266 using some examples. [](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. To install, check [](https://www.ardu-badge.com/LittleFS_esp32).
|
||||
|
||||
---
|
||||
|
||||
@ -366,6 +397,30 @@ This file must be copied into the directory:
|
||||
|
||||
#### 7. For STM32 boards
|
||||
|
||||
#### 7.1. For STM32 boards to use LAN8720
|
||||
|
||||
To use LAN8720 on some STM32 boards
|
||||
|
||||
- **Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)**
|
||||
- **Discovery (DISCO_F746NG)**
|
||||
- **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)**
|
||||
|
||||
you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0/system) to overwrite the old files.
|
||||
|
||||
Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
|
||||
|
||||
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
|
||||
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
|
||||
|
||||
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
|
||||
theses files must be copied into the corresponding directory:
|
||||
|
||||
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h`
|
||||
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h
|
||||
|
||||
|
||||
#### 7.2. For STM32 boards to use Serial1
|
||||
|
||||
**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/1.9.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
|
||||
|
||||
Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
|
||||
@ -584,20 +639,94 @@ Look in file [**adc_common.c**](https://github.com/espressif/esp-idf/blob/master
|
||||
- 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).
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
### HOWTO use STM32F4 with LAN8720
|
||||
|
||||
#### 1. Wiring
|
||||
|
||||
This is the Wiring for STM32F4 (BLACK_F407VE, etc.) using LAN8720
|
||||
|
||||
|
||||
|LAN8720 PHY|<--->|STM32F4|
|
||||
|:-:|:-:|:-:|
|
||||
|TX1|<--->|PB_13|
|
||||
|TX_EN|<--->|PB_11|
|
||||
|TX0|<--->|PB_12|
|
||||
|RX0|<--->|PC_4|
|
||||
|RX1|<--->|PC_5|
|
||||
|nINT/RETCLK|<--->|PA_1|
|
||||
|CRS|<--->|PA_7|
|
||||
|MDIO|<--->|PA_2|
|
||||
|MDC|<--->|PC_1|
|
||||
|GND|<--->|GND|
|
||||
|VCC|<--->|+3.3V|
|
||||
|
||||
---
|
||||
|
||||
#### 2. HOWTO program using STLink V-2 or V-3
|
||||
|
||||
Connect as follows. To program, use **STM32CubeProgrammer** or Arduino IDE with
|
||||
|
||||
- **U(S)ART Support: "Enabled (generic Serial)"**
|
||||
- **Upload Method : "STM32CubeProgrammer (SWD)"**
|
||||
|
||||
|
||||
|STLink|<--->|STM32F4|
|
||||
|:-:|:-:|:-:|
|
||||
|SWCLK|<--->|SWCLK|
|
||||
|SWDIO|<--->|SWDIO|
|
||||
|RST|<--->|NRST|
|
||||
|GND|<--->|GND|
|
||||
|5v|<--->|5V|
|
||||
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/khoih-prog/AsyncHTTPRequest_Generic/blob/master/Images/STM32F407VET6.png">
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
#### 3. HOWTO use Serial Port for Debugging
|
||||
|
||||
Connect FDTI (USB to Serial) as follows:
|
||||
|
||||
|FDTI|<--->|STM32F4|
|
||||
|:-:|:-:|:-:|
|
||||
|RX|<--->|TX=PA_9|
|
||||
|TX|<--->|RX=PA_10|
|
||||
|GND|<--->|GND|
|
||||
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
### Examples
|
||||
|
||||
Also see examples:
|
||||
#### For ESP32 and ESP8266
|
||||
|
||||
1. [AsyncHTTPRequest_ESP](examples/AsyncHTTPRequest_ESP)
|
||||
2. [AsyncHTTPRequest_ESP_WiFiManager](examples/AsyncHTTPRequest_ESP_WiFiManager)
|
||||
3. [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
|
||||
4. [AsyncCustomHeader_STM32](examples/AsyncCustomHeader_STM32)
|
||||
5. [AsyncDweetGet_STM32](examples/AsyncDweetGet_STM32)
|
||||
6. [AsyncDweetPost_STM32](examples/AsyncDweetPost_STM32)
|
||||
7. [AsyncSimpleGET_STM32](examples/AsyncSimpleGET_STM32)
|
||||
8. [AsyncWebClientRepeating_STM32](examples/AsyncWebClientRepeating_STM32)
|
||||
3. [AsyncHTTPMultiRequests_ESP](examples/AsyncHTTPMultiRequests_ESP)
|
||||
|
||||
#### For STM32 using LAN8742A
|
||||
|
||||
1. [AsyncHTTPRequest_STM32](examples/AsyncHTTPRequest_STM32)
|
||||
2. [AsyncCustomHeader_STM32](examples/AsyncCustomHeader_STM32)
|
||||
3. [AsyncDweetGet_STM32](examples/AsyncDweetGet_STM32)
|
||||
4. [AsyncDweetPost_STM32](examples/AsyncDweetPost_STM32)
|
||||
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)
|
||||
|
||||
---
|
||||
|
||||
@ -1039,6 +1168,62 @@ 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.2.0
|
||||
AsyncHTTPRequest @ IP : 192.168.2.150
|
||||
|
||||
|
||||
**************************************
|
||||
|
||||
`:;;;,` .:;;:.
|
||||
.;;;;;;;;;;;` :;;;;;;;;;;: TM
|
||||
`;;;;;;;;;;;;;;;` :;;;;;;;;;;;;;;;
|
||||
:;;;;;;;;;;;;;;;;;; `;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;; .;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;:` `;;;;;;;;; ,;;;;;;;;.` .;;;;;;;;
|
||||
.;;;;;;, :;;;;;;; .;;;;;;; ;;;;;;;
|
||||
;;;;;; ;;;;;;; ;;;;;;, ;;;;;;.
|
||||
,;;;;; ;;;;;;.;;;;;;` ;;;;;;
|
||||
;;;;;. ;;;;;;;;;;;` ``` ;;;;;`
|
||||
;;;;; ;;;;;;;;;, ;;; .;;;;;
|
||||
`;;;;: `;;;;;;;; ;;; ;;;;;
|
||||
,;;;;` `,,,,,,,, ;;;;;;; .,,;;;,,, ;;;;;
|
||||
:;;;;` .;;;;;;;; ;;;;;, :;;;;;;;; ;;;;;
|
||||
:;;;;` .;;;;;;;; `;;;;;; :;;;;;;;; ;;;;;
|
||||
.;;;;. ;;;;;;;. ;;; ;;;;;
|
||||
;;;;; ;;;;;;;;; ;;; ;;;;;
|
||||
;;;;; .;;;;;;;;;; ;;; ;;;;;,
|
||||
;;;;;; `;;;;;;;;;;;; ;;;;;
|
||||
`;;;;;, .;;;;;; ;;;;;;; ;;;;;;
|
||||
;;;;;;: :;;;;;;. ;;;;;;; ;;;;;;
|
||||
;;;;;;;` .;;;;;;;, ;;;;;;;; ;;;;;;;:
|
||||
;;;;;;;;;:,:;;;;;;;;;: ;;;;;;;;;;:,;;;;;;;;;;
|
||||
`;;;;;;;;;;;;;;;;;;;. ;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;; :;;;;;;;;;;;;;;;;:
|
||||
,;;;;;;;;;;;;;, ;;;;;;;;;;;;;;
|
||||
.;;;;;;;;;` ,;;;;;;;;:
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ;;;;;` ;;;;: .;; ;; ,;;;;;, ;;. `;, ;;;;
|
||||
;;; ;;:;;; ;;;;;; .;; ;; ,;;;;;: ;;; `;, ;;;:;;
|
||||
,;:; ;; ;; ;; ;; .;; ;; ,;, ;;;,`;, ;; ;;
|
||||
;; ;: ;; ;; ;; ;; .;; ;; ,;, ;;;;`;, ;; ;;.
|
||||
;: ;; ;;;;;: ;; ;; .;; ;; ,;, ;;`;;;, ;; ;;`
|
||||
,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;;
|
||||
;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;;
|
||||
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
|
||||
|
||||
**************************************
|
||||
```
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
@ -1054,6 +1239,7 @@ You can also change the debugging level from 0 to 4
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Troubleshooting
|
||||
@ -1084,12 +1270,20 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
|
||||
2. Add more examples.
|
||||
3. Add debugging features.
|
||||
4. Add PUT, PATCH, DELETE and HEAD besides GET and POST.
|
||||
5. Add support to **Ethernet LAN8720** using [STM32Ethernet library](https://github.com/stm32duino/STM32Ethernet), for boards such as **Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG), Discovery (DISCO_F746NG)** and **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)**
|
||||
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
## Releases
|
||||
|
||||
### Releases v1.2.0
|
||||
|
||||
1. Add support to **LAN8720** Ethernet for many **STM32F4** (F407xx, NUCLEO_F429ZI) and **STM32F7** (DISCO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG) boards.
|
||||
2. Add LAN8720 examples
|
||||
3. Add Packages' Patches for STM32 to use LAN8720 with STM32Ethernet and LwIP libraries
|
||||
4. Update ESP_WiFiManager-related example to fix multiWiFi timings to work better with latest esp32 core v1.0.6
|
||||
|
||||
### Releases v1.1.5
|
||||
|
||||
1. Fix dependency on unpublished [**STM32AsyncTCP Library**](https://github.com/philbowles/STM32AsyncTCP). Check [Compilation broken due to error in STM32AsyncTCP dependency](https://github.com/khoih-prog/AsyncWebServer_STM32/issues/4) and [how to run one of the examples?](https://github.com/khoih-prog/AsyncWebServer_STM32/issues/2).
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/**
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
// Dweet.io POST client. Connects to dweet.io once every ten seconds, sends a POST request and a request body.
|
||||
@ -44,7 +45,7 @@ const char POST_ServerAddress[] = "dweet.io";
|
||||
String dweetName = "/dweet/for/pinA0-Read?";
|
||||
|
||||
// 60s = 60 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
@ -67,14 +68,14 @@ void sendRequest(void)
|
||||
postData += analogRead(A0);
|
||||
|
||||
Serial.println("\nMaking new POST request");
|
||||
|
||||
|
||||
requestOpenResult = request.open("POST", (POST_ServerAddress + dweetName + postData).c_str() );
|
||||
|
||||
if (requestOpenResult)
|
||||
{
|
||||
// Only send() if open() returns true, or crash
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Can't send bad request");
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 4
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
@ -62,7 +63,9 @@
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _WIFIMGR_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
@ -331,14 +334,20 @@ void configWiFi(WiFi_STA_IPConfig in_WM_STA_IPconfig)
|
||||
uint8_t connectMultiWiFi()
|
||||
{
|
||||
#if ESP32
|
||||
// For ESP32, this better be 0 to shorten the connect time
|
||||
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 0
|
||||
// For ESP32, this better be 0 to shorten the connect time.
|
||||
// For ESP32-S2, must be > 500
|
||||
#if ( ARDUINO_ESP32S2_DEV || ARDUINO_FEATHERS2 || ARDUINO_PROS2 || ARDUINO_MICROS2 )
|
||||
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 500L
|
||||
#else
|
||||
// For ESP32 core v1.0.6, must be >= 500
|
||||
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 800L
|
||||
#endif
|
||||
#else
|
||||
// For ESP8266, this better be 2200 to enable connect the 1st time
|
||||
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 2200L
|
||||
#define WIFI_MULTI_1ST_CONNECT_WAITING_MS 2200L
|
||||
#endif
|
||||
|
||||
#define WIFI_MULTI_CONNECT_WAITING_MS 100L
|
||||
#define WIFI_MULTI_CONNECT_WAITING_MS 100L
|
||||
|
||||
uint8_t status;
|
||||
|
||||
@ -370,6 +379,7 @@ uint8_t connectMultiWiFi()
|
||||
|
||||
int i = 0;
|
||||
status = wifiMulti.run();
|
||||
|
||||
delay(WIFI_MULTI_1ST_CONNECT_WAITING_MS);
|
||||
|
||||
while ( ( i++ < 20 ) && ( status != WL_CONNECTED ) )
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
@ -0,0 +1,134 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncCustomHeader_STM32_LAN8720.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
//char GET_ServerAddress[] = "192.168.2.110/";
|
||||
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
Serial.println("\nSending GET Request to " + String(GET_ServerAddress));
|
||||
|
||||
requestOpenResult = request.open("GET", GET_ServerAddress);
|
||||
//request.setReqHeader("X-CUSTOM-HEADER", "custom_value");
|
||||
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)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("\nStart AsyncCustomHeader_STM32_LAN8720 on " + String(BOARD_NAME));
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
// 5s timeout
|
||||
request.setTimeout(5);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
|
||||
// Send first request now
|
||||
delay(10000);
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
133
examples/STM32_LAN8720/AsyncCustomHeader_STM32_LAN8720/defines.h
Normal file
133
examples/STM32_LAN8720/AsyncCustomHeader_STM32_LAN8720/defines.h
Normal file
@ -0,0 +1,133 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(ARDUINO_BLACK_F407VE) || defined(ARDUINO_BLACK_F407VG) || defined(ARDUINO_BLACK_F407ZE) || defined(ARDUINO_BLACK_F407ZG) || \
|
||||
defined(ARDUINO_BLUE_F407VE_Mini) || defined(ARDUINO_DIYMORE_F407VGT) || defined(ARDUINO_FK407M1) || defined(ARDUINO_NUCLEO_F429ZI) || \
|
||||
defined(ARDUINO_DISCO_F746NG) || defined(ARDUINO_NUCLEO_F746ZG) || defined(ARDUINO_NUCLEO_F756ZG) || defined(ARDUINO_NUCLEO_H743ZI) )
|
||||
#error This code is designed to run on some STM32F407XX NUCLEO-F429ZI, STM32F746 and STM32F756 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
#define USING_LAN8720 true
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
// 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, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
@ -0,0 +1,7 @@
|
||||
// Note: Must replace
|
||||
// .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
|
||||
// as described in README.md
|
||||
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
|
||||
#define LAN8742A_PHY_ADDRESS 0x01U
|
@ -0,0 +1,174 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncDweetGET_STM32_LAN8720.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/**
|
||||
Connects to dweet.io once every 1 minutes, sends a GET request and a request body.
|
||||
|
||||
Shows how to use Strings to assemble path and parse content from response.
|
||||
dweet.io expects: https://dweet.io/dweet/for/thingName
|
||||
|
||||
For more on dweet.io, see https://dweet.io/play/
|
||||
* */
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char GET_ServerAddress[] = "dweet.io";
|
||||
|
||||
// use your own thing name here
|
||||
String dweetName = "/dweet/for/currentSecond?second=";
|
||||
|
||||
// 60s = 60 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
requestOpenResult = request.open("GET", (GET_ServerAddress + dweetName + String(millis()/1000)).c_str() );
|
||||
|
||||
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 parseResponse(String responseText)
|
||||
{
|
||||
/*
|
||||
Typical response is:
|
||||
{"this":"succeeded",
|
||||
"by":"getting",
|
||||
"the":"dweets",
|
||||
"with":[{"thing":"my-thing-name",
|
||||
"created":"2016-02-16T05:10:36.589Z",
|
||||
"content":{"sensorValue":456}}]}
|
||||
|
||||
You want "content": numberValue
|
||||
*/
|
||||
// now parse the response looking for "content":
|
||||
int labelStart = responseText.indexOf("content\":");
|
||||
// find the first { after "content":
|
||||
int contentStart = responseText.indexOf("{", labelStart);
|
||||
// find the following } and get what's between the braces:
|
||||
int contentEnd = responseText.indexOf("}", labelStart);
|
||||
String content = responseText.substring(contentStart + 1, contentEnd);
|
||||
|
||||
Serial.println(content);
|
||||
|
||||
// now get the value after the colon, and convert to an int:
|
||||
int valueStart = content.indexOf(":");
|
||||
String valueString = content.substring(valueStart + 1);
|
||||
int number = valueString.toInt();
|
||||
|
||||
Serial.print("Value string: ");
|
||||
Serial.println(valueString);
|
||||
Serial.print("Actual value: ");
|
||||
Serial.println(number);
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
|
||||
parseResponse(responseText);
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("\nStart AsyncDweetGET_STM32_LAN8720 on " + String(BOARD_NAME));
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
134
examples/STM32_LAN8720/AsyncDweetGet_STM32_LAN8720/defines.h
Normal file
134
examples/STM32_LAN8720/AsyncDweetGet_STM32_LAN8720/defines.h
Normal file
@ -0,0 +1,134 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(ARDUINO_BLACK_F407VE) || defined(ARDUINO_BLACK_F407VG) || defined(ARDUINO_BLACK_F407ZE) || defined(ARDUINO_BLACK_F407ZG) || \
|
||||
defined(ARDUINO_BLUE_F407VE_Mini) || defined(ARDUINO_DIYMORE_F407VGT) || defined(ARDUINO_FK407M1) || defined(ARDUINO_NUCLEO_F429ZI) || \
|
||||
defined(ARDUINO_DISCO_F746NG) || defined(ARDUINO_NUCLEO_F746ZG) || defined(ARDUINO_NUCLEO_F756ZG) || defined(ARDUINO_NUCLEO_H743ZI) )
|
||||
#error This code is designed to run on some STM32F407XX NUCLEO-F429ZI, STM32F746 and STM32F756 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
#define USING_LAN8720 true
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
// 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, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
@ -0,0 +1,7 @@
|
||||
// Note: Must replace
|
||||
// .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
|
||||
// as described in README.md
|
||||
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
|
||||
#define LAN8742A_PHY_ADDRESS 0x01U
|
@ -0,0 +1,173 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncDweetPOST_STM32_LAN8720.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
// Dweet.io POST client. Connects to dweet.io once every ten seconds, sends a POST request and a request body.
|
||||
// Shows how to use Strings to assemble path and body
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char POST_ServerAddress[] = "dweet.io";
|
||||
|
||||
// use your own thing name here
|
||||
String dweetName = "/dweet/for/pinA0-Read?";
|
||||
|
||||
// 60s = 60 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 10000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
String postData = "sensorValue=";
|
||||
postData += analogRead(A0);
|
||||
|
||||
Serial.println("\nMaking new POST request");
|
||||
|
||||
requestOpenResult = request.open("POST", (POST_ServerAddress + dweetName + postData).c_str() );
|
||||
|
||||
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 parseResponse(String responseText)
|
||||
{
|
||||
/*
|
||||
Typical response is:
|
||||
{"this":"succeeded",
|
||||
"by":"getting",
|
||||
"the":"dweets",
|
||||
"with":[{"thing":"my-thing-name",
|
||||
"created":"2016-02-16T05:10:36.589Z",
|
||||
"content":{"sensorValue":456}}]}
|
||||
|
||||
You want "content": numberValue
|
||||
*/
|
||||
// now parse the response looking for "content":
|
||||
int labelStart = responseText.indexOf("content\":");
|
||||
// find the first { after "content":
|
||||
int contentStart = responseText.indexOf("{", labelStart);
|
||||
// find the following } and get what's between the braces:
|
||||
int contentEnd = responseText.indexOf("}", labelStart);
|
||||
String content = responseText.substring(contentStart + 1, contentEnd);
|
||||
|
||||
Serial.println(content);
|
||||
|
||||
// now get the value after the colon, and convert to an int:
|
||||
int valueStart = content.indexOf(":");
|
||||
String valueString = content.substring(valueStart + 1);
|
||||
int number = valueString.toInt();
|
||||
|
||||
Serial.print("Value string: ");
|
||||
Serial.println(valueString);
|
||||
Serial.print("Actual value: ");
|
||||
Serial.println(number);
|
||||
}
|
||||
|
||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
{
|
||||
(void) optParm;
|
||||
|
||||
if (readyState == readyStateDone)
|
||||
{
|
||||
String responseText = request->responseText();
|
||||
|
||||
Serial.println("\n**************************************");
|
||||
//Serial.println(request->responseText());
|
||||
Serial.println(responseText);
|
||||
Serial.println("**************************************");
|
||||
|
||||
parseResponse(responseText);
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("\nStart AsyncDweetPOST_STM32_LAN8720 on " + String(BOARD_NAME));
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
134
examples/STM32_LAN8720/AsyncDweetPost_STM32_LAN8720/defines.h
Normal file
134
examples/STM32_LAN8720/AsyncDweetPost_STM32_LAN8720/defines.h
Normal file
@ -0,0 +1,134 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(ARDUINO_BLACK_F407VE) || defined(ARDUINO_BLACK_F407VG) || defined(ARDUINO_BLACK_F407ZE) || defined(ARDUINO_BLACK_F407ZG) || \
|
||||
defined(ARDUINO_BLUE_F407VE_Mini) || defined(ARDUINO_DIYMORE_F407VGT) || defined(ARDUINO_FK407M1) || defined(ARDUINO_NUCLEO_F429ZI) || \
|
||||
defined(ARDUINO_DISCO_F746NG) || defined(ARDUINO_NUCLEO_F746ZG) || defined(ARDUINO_NUCLEO_F756ZG) || defined(ARDUINO_NUCLEO_H743ZI) )
|
||||
#error This code is designed to run on some STM32F407XX NUCLEO-F429ZI, STM32F746 and STM32F756 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 4
|
||||
|
||||
#define USING_LAN8720 true
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
// 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, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
@ -0,0 +1,7 @@
|
||||
// Note: Must replace
|
||||
// .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
|
||||
// as described in README.md
|
||||
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
|
||||
#define LAN8742A_PHY_ADDRESS 0x01U
|
@ -0,0 +1,147 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncHTTPRequest_STM32_LAN8720.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
//************************************************************************************************************
|
||||
//
|
||||
// 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 5 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.
|
||||
//
|
||||
//*************************************************************************************************************
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("\nStart AsyncHTTPRequest_STM32_LAN8720 on " + String(BOARD_NAME));
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
|
||||
// Send first request now
|
||||
//delay(60);
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
133
examples/STM32_LAN8720/AsyncHTTPRequest_STM32_LAN8720/defines.h
Normal file
133
examples/STM32_LAN8720/AsyncHTTPRequest_STM32_LAN8720/defines.h
Normal file
@ -0,0 +1,133 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(ARDUINO_BLACK_F407VE) || defined(ARDUINO_BLACK_F407VG) || defined(ARDUINO_BLACK_F407ZE) || defined(ARDUINO_BLACK_F407ZG) || \
|
||||
defined(ARDUINO_BLUE_F407VE_Mini) || defined(ARDUINO_DIYMORE_F407VGT) || defined(ARDUINO_FK407M1) || defined(ARDUINO_NUCLEO_F429ZI) || \
|
||||
defined(ARDUINO_DISCO_F746NG) || defined(ARDUINO_NUCLEO_F746ZG) || defined(ARDUINO_NUCLEO_F756ZG) || defined(ARDUINO_NUCLEO_H743ZI) )
|
||||
#error This code is designed to run on some STM32F407XX NUCLEO-F429ZI, STM32F746 and STM32F756 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
#define USING_LAN8720 true
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
// 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, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
@ -0,0 +1,7 @@
|
||||
// Note: Must replace
|
||||
// .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
|
||||
// as described in README.md
|
||||
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
|
||||
#define LAN8742A_PHY_ADDRESS 0x01U
|
@ -0,0 +1,128 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncSimpleGET_STM32_LAN8720.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
|
||||
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
|
||||
|
||||
// 600s = 10 minutes to not flooding, 60s in testing
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
requestOpenResult = request.open("GET", GET_ServerAddress);
|
||||
|
||||
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)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("\nStart AsyncSimpleGET_STM32_LAN8720 on " + String(BOARD_NAME));
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker.
|
||||
|
||||
// Send first request now
|
||||
delay(10000);
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
134
examples/STM32_LAN8720/AsyncSimpleGET_STM32_LAN8720/defines.h
Normal file
134
examples/STM32_LAN8720/AsyncSimpleGET_STM32_LAN8720/defines.h
Normal file
@ -0,0 +1,134 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with LAN8720 or 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/>.
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(ARDUINO_BLACK_F407VE) || defined(ARDUINO_BLACK_F407VG) || defined(ARDUINO_BLACK_F407ZE) || defined(ARDUINO_BLACK_F407ZG) || \
|
||||
defined(ARDUINO_BLUE_F407VE_Mini) || defined(ARDUINO_DIYMORE_F407VGT) || defined(ARDUINO_FK407M1) || defined(ARDUINO_NUCLEO_F429ZI) || \
|
||||
defined(ARDUINO_DISCO_F746NG) || defined(ARDUINO_NUCLEO_F746ZG) || defined(ARDUINO_NUCLEO_F756ZG) || defined(ARDUINO_NUCLEO_H743ZI) )
|
||||
#error This code is designed to run on some STM32F407XX NUCLEO-F429ZI, STM32F746 and STM32F756 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
#define USING_LAN8720 true
|
||||
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
// 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, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 232);
|
||||
|
||||
#endif //defines_h
|
@ -0,0 +1,7 @@
|
||||
// Note: Must replace
|
||||
// .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
|
||||
// as described in README.md
|
||||
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
|
||||
#define LAN8742A_PHY_ADDRESS 0x01U
|
@ -0,0 +1,129 @@
|
||||
/****************************************************************************************************************************
|
||||
AsyncWebClientRepeating_STM32_LAN8720.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with _LAN8720 or 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/>.
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// Select a test server address
|
||||
const char GET_ServerAddress[] = "arduino.cc";
|
||||
|
||||
// GET location
|
||||
String GET_Location = "/asciilogo.txt";
|
||||
|
||||
// 60s = 60 seconds to not flooding the server
|
||||
#define HTTP_REQUEST_INTERVAL_MS 60000
|
||||
|
||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
|
||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||
|
||||
AsyncHTTPRequest request;
|
||||
|
||||
void sendRequest(void);
|
||||
|
||||
// Repeat forever, millis() resolution
|
||||
Ticker sendHTTPRequest(sendRequest, HTTP_REQUEST_INTERVAL_MS, 0, MILLIS);
|
||||
|
||||
void sendRequest(void)
|
||||
{
|
||||
static bool requestOpenResult;
|
||||
|
||||
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
|
||||
{
|
||||
requestOpenResult = request.open("GET", (GET_ServerAddress + GET_Location).c_str());
|
||||
|
||||
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)
|
||||
{
|
||||
Serial.println("\n**************************************");
|
||||
Serial.println(request->responseText());
|
||||
Serial.println("**************************************");
|
||||
|
||||
request->setDebug(false);
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
|
||||
Serial.println("\nStart AsyncWebClientRepeating_STM32_LAN8720 on " + String(BOARD_NAME));
|
||||
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||
|
||||
// start the ethernet connection and the server
|
||||
// Use random mac
|
||||
uint16_t index = millis() % NUMBER_OF_MAC;
|
||||
|
||||
// Use Static IP
|
||||
//Ethernet.begin(mac[index], ip);
|
||||
// Use DHCP dynamic IP and random mac
|
||||
Ethernet.begin(mac[index]);
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(Ethernet.localIP());
|
||||
Serial.println();
|
||||
|
||||
request.setDebug(false);
|
||||
|
||||
request.onReadyStateChange(requestCB);
|
||||
sendHTTPRequest.start(); //start the ticker
|
||||
|
||||
// Send first request now
|
||||
sendRequest();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
sendHTTPRequest.update();
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
/****************************************************************************************************************************
|
||||
defines.h
|
||||
|
||||
Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32
|
||||
|
||||
For ESP8266, ESP32 and STM32 with _LAN8720 or 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/>.
|
||||
*****************************************************************************************************************************/
|
||||
/*
|
||||
Currently support
|
||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
||||
- Nucleo-144 (F429ZI, F767ZI)
|
||||
- Discovery (STM32F746G-DISCOVERY)
|
||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
||||
*/
|
||||
|
||||
#ifndef defines_h
|
||||
#define defines_h
|
||||
|
||||
#if !( defined(ARDUINO_BLACK_F407VE) || defined(ARDUINO_BLACK_F407VG) || defined(ARDUINO_BLACK_F407ZE) || defined(ARDUINO_BLACK_F407ZG) || \
|
||||
defined(ARDUINO_BLUE_F407VE_Mini) || defined(ARDUINO_DIYMORE_F407VGT) || defined(ARDUINO_FK407M1) || defined(ARDUINO_NUCLEO_F429ZI) || \
|
||||
defined(ARDUINO_DISCO_F746NG) || defined(ARDUINO_NUCLEO_F746ZG) || defined(ARDUINO_NUCLEO_F756ZG) || defined(ARDUINO_NUCLEO_H743ZI) )
|
||||
#error This code is designed to run on some STM32F407XX NUCLEO-F429ZI, STM32F746 and STM32F756 platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
|
||||
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
|
||||
#define USING_LAN8720 true
|
||||
|
||||
#if defined(STM32F0)
|
||||
#warning STM32F0 board selected
|
||||
#define BOARD_TYPE "STM32F0"
|
||||
#elif defined(STM32F1)
|
||||
#warning STM32F1 board selected
|
||||
#define BOARD_TYPE "STM32F1"
|
||||
#elif defined(STM32F2)
|
||||
#warning STM32F2 board selected
|
||||
#define BOARD_TYPE "STM32F2"
|
||||
#elif defined(STM32F3)
|
||||
#warning STM32F3 board selected
|
||||
#define BOARD_TYPE "STM32F3"
|
||||
#elif defined(STM32F4)
|
||||
#warning STM32F4 board selected
|
||||
#define BOARD_TYPE "STM32F4"
|
||||
#elif defined(STM32F7)
|
||||
#warning STM32F7 board selected
|
||||
#define BOARD_TYPE "STM32F7"
|
||||
#elif defined(STM32L0)
|
||||
#warning STM32L0 board selected
|
||||
#define BOARD_TYPE "STM32L0"
|
||||
#elif defined(STM32L1)
|
||||
#warning STM32L1 board selected
|
||||
#define BOARD_TYPE "STM32L1"
|
||||
#elif defined(STM32L4)
|
||||
#warning STM32L4 board selected
|
||||
#define BOARD_TYPE "STM32L4"
|
||||
#elif defined(STM32H7)
|
||||
#warning STM32H7 board selected
|
||||
#define BOARD_TYPE "STM32H7"
|
||||
#elif defined(STM32G0)
|
||||
#warning STM32G0 board selected
|
||||
#define BOARD_TYPE "STM32G0"
|
||||
#elif defined(STM32G4)
|
||||
#warning STM32G4 board selected
|
||||
#define BOARD_TYPE "STM32G4"
|
||||
#elif defined(STM32WB)
|
||||
#warning STM32WB board selected
|
||||
#define BOARD_TYPE "STM32WB"
|
||||
#elif defined(STM32MP1)
|
||||
#warning STM32MP1 board selected
|
||||
#define BOARD_TYPE "STM32MP1"
|
||||
#else
|
||||
#warning STM32 unknown board selected
|
||||
#define BOARD_TYPE "STM32 Unknown"
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_NAME
|
||||
#define BOARD_NAME BOARD_TYPE
|
||||
#endif
|
||||
|
||||
#include <LwIP.h>
|
||||
#include <STM32Ethernet.h>
|
||||
|
||||
//#include <AsyncUDP_STM32.h>
|
||||
|
||||
// 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, 0x32, 0x01 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x02 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x03 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x04 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x05 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x06 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x07 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x08 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x09 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0A },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0B },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0C },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0D },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0E },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x0F },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x10 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x11 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x12 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x13 },
|
||||
{ 0xDE, 0xAD, 0xBE, 0xEF, 0x32, 0x14 },
|
||||
};
|
||||
|
||||
// Select the static IP address according to your local network
|
||||
IPAddress ip(192, 168, 2, 220);
|
||||
|
||||
#endif //defines_h
|
@ -0,0 +1,7 @@
|
||||
// Note: Must replace
|
||||
// .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h
|
||||
// as described in README.md
|
||||
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
|
||||
#define LAN8742A_PHY_ADDRESS 0x01U
|
10
library.json
10
library.json
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name":"AsyncHTTPRequest_Generic",
|
||||
"version": "1.1.5",
|
||||
"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), ESP8266 and currently STM32 with built-in LAN8742A Ethernet.",
|
||||
"keywords":"async,tcp,http,ESP8266,ESP32,ESP32-S2,ESPAsyncTCP,AsyncTCP,stm32,ethernet,wifi,lan8742a",
|
||||
"version": "1.2.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), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
|
||||
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESPAsyncTCP, AsyncTCP, stm32, ethernet, wifi, lan8742a, lan8720, f407ve, nucleo, nucleo-144, stm32f7, stm32f4",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Bob Lemaire",
|
||||
@ -39,7 +39,7 @@
|
||||
{
|
||||
"owner": "khoih.prog",
|
||||
"name": "ESPAsync_WiFiManager",
|
||||
"version": ">=1.6.0",
|
||||
"version": ">=1.6.2",
|
||||
"platforms": ["espressif8266", "espressif32"]
|
||||
},
|
||||
{
|
||||
@ -57,7 +57,7 @@
|
||||
{
|
||||
"owner": "lorol",
|
||||
"name": "LittleFS_esp32",
|
||||
"version": ">=1.0.5",
|
||||
"version": ">=1.0.6",
|
||||
"platforms": ["espressif32"]
|
||||
},
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
name=AsyncHTTPRequest_Generic
|
||||
version=1.1.5
|
||||
version=1.2.0
|
||||
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
|
||||
maintainer=Khoi Hoang <khoih.prog@gmail.com>
|
||||
license=MIT
|
||||
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), ESP8266 and currently STM32 with built-in LAN8742A Ethernet.
|
||||
paragraph=This AsyncHTTPRequest_Generic Library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, for ESP32 (including ESP32-S2), ESP8266 and STM32 with built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, etc.
|
||||
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), ESP8266 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 and STM32 with LAN8720 or built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, F407VE, etc.
|
||||
category=Communication,AsyncTCP,AsyncHTTP
|
||||
url=https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||
architectures=*
|
||||
|
@ -40,8 +40,8 @@ lib_deps =
|
||||
; https://github.com/khoih-prog/STM32AsyncTCP.git
|
||||
; STM32duino LwIP@>=2.1.2
|
||||
; STM32duino STM32Ethernet@>=1.2.0
|
||||
; ESPAsync_WiFiManager@>=1.6.0
|
||||
; LittleFS_esp32@>=1.0.5
|
||||
; ESPAsync_WiFiManager@>=1.6.2
|
||||
; LittleFS_esp32@>=1.0.6
|
||||
; PlatformIO 5.x
|
||||
me-no-dev/AsyncTCP@>=1.1.1
|
||||
me-no-dev/ESPAsyncTCP@>=1.2.2
|
||||
@ -49,8 +49,8 @@ lib_deps =
|
||||
https://github.com/khoih-prog/STM32AsyncTCP.git
|
||||
stm32duino/STM32duino LwIP@>=2.1.2
|
||||
stm32duino/STM32duino STM32Ethernet@>=1.2.0
|
||||
khoih-prog/ESPAsync_WiFiManager@>=1.6.0
|
||||
lorol/LittleFS_esp32@>=1.0.5
|
||||
khoih-prog/ESPAsync_WiFiManager@>=1.6.2
|
||||
lorol/LittleFS_esp32@>=1.0.6
|
||||
|
||||
build_flags =
|
||||
; set your debug output (default=Serial)
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@ -37,7 +38,7 @@
|
||||
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_H
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.5"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.2.0"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@ -181,6 +182,8 @@ 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);
|
||||
|
||||
SAFE_DELETE_ARRAY(hostName)
|
||||
|
||||
_lastActivity = millis();
|
||||
@ -189,8 +192,6 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
||||
_requestReadyToSend = true;
|
||||
//////
|
||||
|
||||
AHTTP_LOGDEBUG1("open: conneting to hostname =", hostName);
|
||||
|
||||
return _connect();
|
||||
}
|
||||
else
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
@ -17,13 +17,20 @@
|
||||
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/>.
|
||||
|
||||
x-special/nautilus-clipboard
|
||||
copy
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/utility
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Debug_Generic.h
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Generic.h
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Impl_Generic.h
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
@ -17,13 +17,20 @@
|
||||
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/>.
|
||||
|
||||
x-special/nautilus-clipboard
|
||||
copy
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/utility
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Debug_Generic.h
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Generic.h
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Impl_Generic.h
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "AsyncHTTPRequest_Debug_Generic.h"
|
||||
|
@ -17,13 +17,20 @@
|
||||
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/>.
|
||||
|
||||
x-special/nautilus-clipboard
|
||||
copy
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/utility
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Debug_Generic.h
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Generic.h
|
||||
file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_Impl_Generic.h
|
||||
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@ -31,7 +38,7 @@ file:///home/kh/Arduino/libraries/AsyncHTTPRequest_Generic/src/AsyncHTTPRequest_
|
||||
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_H
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.5"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.2.0"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
@ -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.1.3
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -28,6 +28,9 @@
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#include "utility/xbuf.h"
|
||||
|
@ -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.1.3
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -28,6 +28,9 @@
|
||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@ -37,7 +38,7 @@
|
||||
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_H
|
||||
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.5"
|
||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.2.0"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@ -181,6 +182,8 @@ 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);
|
||||
|
||||
SAFE_DELETE_ARRAY(hostName)
|
||||
|
||||
_lastActivity = millis();
|
||||
@ -189,8 +192,6 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
||||
_requestReadyToSend = true;
|
||||
//////
|
||||
|
||||
AHTTP_LOGDEBUG1("open: conneting to hostname =", hostName);
|
||||
|
||||
return _connect();
|
||||
}
|
||||
else
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
|
@ -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.1.5
|
||||
Version: 1.2.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@ -30,6 +30,7 @@
|
||||
1.1.3 K Hoang 25/02/2021 Fix non-persistent Connection header bug
|
||||
1.1.4 K Hoang 21/03/2021 Fix `library.properties` dependency
|
||||
1.1.5 K Hoang 22/03/2021 Fix dependency on STM32AsyncTCP Library
|
||||
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
Reference in New Issue
Block a user