Compare commits

...
7 Commits
Author SHA1 Message Date
Khoi Hoang dc88bb078f v1.13.0 for LwIP W6100 and fix bug
### Releases v1.13.0

1. Add support to ESP32 boards using `LwIP W6100 Ethernet`
2. Fix bug of `_parseURL()`. Check [Bug with _parseURL() #21](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/21)
3. Improve `README.md` so that links can be used in other sites, such as `PIO`
2023-02-01 01:00:41 -05:00
Khoi Hoang e1ae41ed24 v1.13.0 for LwIP W6100 and fix bug
### Releases v1.13.0

1. Add support to ESP32 boards using `LwIP W6100 Ethernet`
2. Fix bug of `_parseURL()`. Check [Bug with _parseURL() #21](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/21)
3. Improve `README.md` so that links can be used in other sites, such as `PIO`
2023-02-01 00:58:15 -05:00
Khoi Hoang c9a376e2fc v1.13.0 for LwIP W6100 and fix bug
### Releases v1.13.0

1. Add support to ESP32 boards using `LwIP W6100 Ethernet`
2. Fix bug of `_parseURL()`. Check [Bug with _parseURL() #21](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/21)
3. Improve `README.md` so that links can be used in other sites, such as `PIO`
2023-02-01 00:54:32 -05:00
Khoi Hoang cad009d718 v1.13.0 for LwIP W6100 and fix bug
### Releases v1.13.0

1. Add support to ESP32 boards using `LwIP W6100 Ethernet`
2. Fix bug of `_parseURL()`. Check [Bug with _parseURL() #21](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/21)
3. Improve `README.md` so that links can be used in other sites, such as `PIO`
2023-02-01 00:53:15 -05:00
Khoi Hoang 08d950eb13 Update .github 2023-02-01 00:52:12 -05:00
Khoi Hoang 8b03589b02 Update README.md 2022-12-04 23:15:57 -05:00
Khoi Hoang b93352c940 Update changelog.md 2022-12-04 23:15:43 -05:00
13 changed files with 948 additions and 257 deletions
+9 -3
View File
@@ -31,12 +31,14 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
---
### Information
Please ensure to specify the following:
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.5 or STM32 v2.3.0)
* `ESP8266` or`ESP32` Core Version (e.g. ESP8266 core v3.1.1, ESP32 v2.0.6)
* 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:
@@ -44,13 +46,17 @@ Please ensure to specify the following:
* Network configuration
Please be educated, civilized and constructive as you've always been. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted.
---
### Example
```
Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.5
ESP32 Core Version 2.0.6
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-58-generic #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while using this library
+9 -3
View File
@@ -10,12 +10,14 @@ However, before reporting a bug please check through the following:
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/new).
---
### How to submit a bug report
Please ensure to specify the following:
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.5 or STM32 v2.3.0)
* `ESP8266` or`ESP32` Core Version (e.g. ESP8266 core v3.1.1, ESP32 v2.0.6)
* 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:
@@ -23,13 +25,17 @@ Please ensure to specify the following:
* Network configuration
Please be educated, civilized and constructive as you've always been. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted.
---
### Example
```
Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.5
ESP32 Core Version 2.0.6
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-58-generic #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while using this library
+286 -226
View File
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -9,8 +9,7 @@
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
<a href="https://profile-counter.glitch.me/khoih-prog-AsyncHTTPRequest_Generic/count.svg" title="AsyncHTTPRequest_Generic Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-AsyncHTTPRequest_Generic/count.svg" style="height: 30px;width: 200px;"></a>
---
---
@@ -18,6 +17,7 @@
## Table of Contents
* [Changelog](#changelog)
* [Releases v1.13.0](#releases-v1130)
* [Releases v1.12.0](#releases-v1120)
* [Releases v1.11.0](#releases-v1110)
* [Releases v1.10.2](#releases-v1102)
@@ -53,6 +53,12 @@
## Changelog
### Releases v1.13.0
1. Add support to ESP32 boards using `LwIP W6100 Ethernet`
2. Fix bug of `_parseURL()`. Check [Bug with _parseURL() #21](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/21)
3. Improve `README.md` so that links can be used in other sites, such as `PIO`
### Releases v1.12.0
1. Add support to ESP32 boards using `LwIP W5500 Ethernet`
@@ -0,0 +1,308 @@
/****************************************************************************************************************************
AsyncHTTPMultiRequests_ESP32_W6100.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*****************************************************************************************************************************/
//************************************************************************************************************
//
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
// headers and payload, gathering the response headers and any payload, and processing
// of that response, can (and probably should) all be done asynchronously.
//
// In this example, a Ticker function is setup to fire every 300 seconds to initiate a request.
// Everything is handled in AsyncHTTPRequest without blocking.
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
//
// Note that there is no code in loop(). A code entered into loop would run oblivious to
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
// could be made in loop(), resulting in the same asynchronous handling.
//
// For demo purposes, debug is turned on for handling of the first request. These are the
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
// nnn is the elapsed time in milliseconds since the transaction was started.
//
//*************************************************************************************************************
#if !( defined(ESP32) )
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
#endif
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 1
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
// 300s = 5 minutes to not flooding
#define HTTP_REQUEST_INTERVAL 60 //300
// 10s
#define HEARTBEAT_INTERVAL 10
//////////////////////////////////////////////////////////
// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI3_HOST
//#define SPI_CLOCK_MHZ 25
// Must connect INT to GPIOxx or not working
//#define INT_GPIO 4
//#define MISO_GPIO 19
//#define MOSI_GPIO 23
//#define SCK_GPIO 18
//#define CS_GPIO 5
//////////////////////////////////////////////////////////
#include <WebServer_ESP32_W6100.h> // https://github.com/khoih-prog/WebServer_ESP32_W6100
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.12.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1012000
// Uncomment for certain HTTP site to optimize
//#define NOT_SEND_HEADER_AFTER_CONNECTED true
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
Ticker ticker;
Ticker ticker1;
/////////////////////////////////////////////
// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20
byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
};
// Select the IP address according to your local network
IPAddress myIP(192, 168, 2, 232);
IPAddress myGW(192, 168, 2, 1);
IPAddress mySN(255, 255, 255, 0);
// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);
/////////////////////////////////////////////
void heartBeatPrint(void)
{
static int num = 1;
if (ESP32_W6100_isConnected())
Serial.print(F("H")); // H means connected to WiFi
else
Serial.print(F("F")); // F means not connected to WiFi
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}
// To replace with your real APP_API
#define APP_API "SECRECT_APP_API"
String requestPart1 = "http://api.openweathermap.org/data/2.5/onecall?lat=-24.32&lon=-46.9983";
String requestAPPID = "&appid=" + String(APP_API);
// exclude fields: current,minutely,hourly,daily,alerts
String requestCurrent = requestPart1 + "&exclude=minutely,hourly,daily,alerts" + requestAPPID;
String requestMinutely = requestPart1 + "&exclude=current,hourly,daily,alerts" + requestAPPID;
String requestHourly = requestPart1 + "&exclude=current,minutely,daily,alerts" + requestAPPID;
String requestDaily = requestPart1 + "&exclude=current,minutely,hourly,alerts" + requestAPPID;
String requestAlert = requestPart1 + "&exclude=current,minutely,hourly,daily" + requestAPPID;
#define NUM_REQUESTS 5
const char* requestName[ NUM_REQUESTS ] = { "Current", "Minutely", "Hourly", "Daily", "Alert" };
const char* requestAll[ NUM_REQUESTS ] = { requestCurrent.c_str(), requestMinutely.c_str(), requestHourly.c_str(), requestDaily.c_str(), requestAlert.c_str() };
uint8_t requestIndex = 0;
void sendRequest()
{
static bool requestOpenResult;
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
requestOpenResult = request.open("GET", requestAll[requestIndex] );
if (requestOpenResult)
{
// Only send() if open() returns true, or crash
request.send();
}
else
{
Serial.println("Can't send bad request");
}
}
else
{
Serial.println("Can't send request");
}
}
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.print(F("\n***************"));
Serial.print(requestName[ requestIndex ]);
Serial.println(F("***************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
#if 1
// Bypass hourly
if (requestIndex == 1)
requestIndex = 3;
else
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
#else
// hourly too long, not display anyway. Not enough heap.
requestIndex = (requestIndex + 1) % NUM_REQUESTS;
#endif
request->setDebug(false);
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial && millis() < 5000);
delay(200);
Serial.print("\nStart AsyncHTTPMultiRequests_ESP32_W6100 on ");
Serial.print(ARDUINO_BOARD);
Serial.print(" with ");
Serial.println(SHIELD_TYPE);
Serial.println(WEBSERVER_ESP32_W6100_VERSION);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
Serial.setDebugOutput(true);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
AHTTP_LOGWARN(F("Default SPI pinout:"));
AHTTP_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
AHTTP_LOGWARN1(F("MOSI:"), MOSI_GPIO);
AHTTP_LOGWARN1(F("MISO:"), MISO_GPIO);
AHTTP_LOGWARN1(F("SCK:"), SCK_GPIO);
AHTTP_LOGWARN1(F("CS:"), CS_GPIO);
AHTTP_LOGWARN1(F("INT:"), INT_GPIO);
AHTTP_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
AHTTP_LOGWARN(F("========================="));
///////////////////////////////////
// To be called before ETH.begin()
ESP32_W6100_onEvent();
// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
// int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac);
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] );
// Static IP, leave without this line to get IP via DHCP
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
//ETH.config(myIP, myGW, mySN, myDNS);
ESP32_W6100_waitForConnect();
///////////////////////////////////
Serial.print(F("AsyncHTTPRequest @ IP : "));
Serial.println(ETH.localIP());
request.setDebug(false);
request.onReadyStateChange(requestCB);
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
ticker1.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
// Send first request now
sendRequest();
}
void loop()
{
}
@@ -0,0 +1,270 @@
/****************************************************************************************************************************
AsyncHTTPRequest_ESP32_W6100.ino - Dead simple AsyncHTTPRequest for ESP8266, ESP32 and currently STM32 with built-in LAN8742A Ethernet
For ESP8266, ESP32 and STM32 with built-in LAN8742A Ethernet (Nucleo-144, DISCOVERY, etc)
AsyncHTTPRequest_Generic is a library for the ESP8266, ESP32 and currently STM32 run built-in Ethernet WebServer
Based on and modified from asyncHTTPrequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPRequest_Generic
Licensed under MIT license
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*****************************************************************************************************************************/
//************************************************************************************************************
//
// There are scores of ways to use AsyncHTTPRequest. The important thing to keep in mind is that
// it is asynchronous and just like in JavaScript, everything is event driven. You will have some
// reason to initiate an asynchronous HTTP request in your program, but then sending the request
// headers and payload, gathering the response headers and any payload, and processing
// of that response, can (and probably should) all be done asynchronously.
//
// In this example, a Ticker function is setup to fire every 300 seconds to initiate a request.
// Everything is handled in AsyncHTTPRequest without blocking.
// The callback onReadyStateChange is made progressively and like most JS scripts, we look for
// readyState == 4 (complete) here. At that time the response is retrieved and printed.
//
// Note that there is no code in loop(). A code entered into loop would run oblivious to
// the ongoing HTTP requests. The Ticker could be removed and periodic calls to sendRequest()
// could be made in loop(), resulting in the same asynchronous handling.
//
// For demo purposes, debug is turned on for handling of the first request. These are the
// events that are being handled in AsyncHTTPRequest. They all begin with Debug(nnn) where
// nnn is the elapsed time in milliseconds since the transaction was started.
//
//*************************************************************************************************************
#if !( defined(ESP32) )
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
#endif
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 1
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
// 300s = 5 minutes to not flooding
#define HTTP_REQUEST_INTERVAL 60 //300
// 10s
#define HEARTBEAT_INTERVAL 10
//////////////////////////////////////////////////////////
// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI3_HOST
//#define SPI_CLOCK_MHZ 25
// Must connect INT to GPIOxx or not working
//#define INT_GPIO 4
//#define MISO_GPIO 19
//#define MOSI_GPIO 23
//#define SCK_GPIO 18
//#define CS_GPIO 5
//////////////////////////////////////////////////////////
#include <WebServer_ESP32_W6100.h> // https://github.com/khoih-prog/WebServer_ESP32_W6100
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.12.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1012000
// Uncomment for certain HTTP site to optimize
//#define NOT_SEND_HEADER_AFTER_CONNECTED true
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
#include <Ticker.h>
AsyncHTTPRequest request;
Ticker ticker;
Ticker ticker1;
/////////////////////////////////////////////
// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20
byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
};
// Select the IP address according to your local network
IPAddress myIP(192, 168, 2, 232);
IPAddress myGW(192, 168, 2, 1);
IPAddress mySN(255, 255, 255, 0);
// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);
/////////////////////////////////////////////
void heartBeatPrint(void)
{
static int num = 1;
if (ESP32_W6100_isConnected())
Serial.print(F("H")); // H means connected
else
Serial.print(F("F")); // F means not connected
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}
void sendRequest()
{
static bool requestOpenResult;
if (request.readyState() == readyStateUnsent || request.readyState() == readyStateDone)
{
//requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/Europe/London.txt");
requestOpenResult = request.open("GET", "http://worldtimeapi.org/api/timezone/America/Toronto.txt");
if (requestOpenResult)
{
// Only send() if open() returns true, or crash
request.send();
}
else
{
Serial.println("Can't send bad request");
}
}
else
{
Serial.println("Can't send request");
}
}
void requestCB(void *optParm, AsyncHTTPRequest *request, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGDEBUG(F("\n**************************************"));
AHTTP_LOGDEBUG1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
Serial.println(F("\n**************************************"));
Serial.println(request->responseText());
Serial.println(F("**************************************"));
}
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial && millis() < 5000);
delay(200);
Serial.print("\nStart AsyncHTTPRequest_ESP32_W6100 on ");
Serial.print(ARDUINO_BOARD);
Serial.print(" with ");
Serial.println(SHIELD_TYPE);
Serial.println(WEBSERVER_ESP32_W6100_VERSION);
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
Serial.setDebugOutput(true);
#if defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
if (ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT < ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN)
{
Serial.print("Warning. Must use this example on Version equal or later than : ");
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET);
}
#endif
AHTTP_LOGWARN(F("Default SPI pinout:"));
AHTTP_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
AHTTP_LOGWARN1(F("MOSI:"), MOSI_GPIO);
AHTTP_LOGWARN1(F("MISO:"), MISO_GPIO);
AHTTP_LOGWARN1(F("SCK:"), SCK_GPIO);
AHTTP_LOGWARN1(F("CS:"), CS_GPIO);
AHTTP_LOGWARN1(F("INT:"), INT_GPIO);
AHTTP_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
AHTTP_LOGWARN(F("========================="));
///////////////////////////////////
// To be called before ETH.begin()
ESP32_W6100_onEvent();
// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
// int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac);
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] );
// Static IP, leave without this line to get IP via DHCP
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
//ETH.config(myIP, myGW, mySN, myDNS);
ESP32_W6100_waitForConnect();
///////////////////////////////////
Serial.print(F("\nHTTP WebClient is @ IP : "));
Serial.println(ETH.localIP());
request.setDebug(false);
request.onReadyStateChange(requestCB);
ticker.attach(HTTP_REQUEST_INTERVAL, sendRequest);
ticker1.attach(HEARTBEAT_INTERVAL, heartBeatPrint);
// Send first request now
sendRequest();
}
void loop()
{
}
+11 -5
View File
@@ -1,8 +1,8 @@
{
"name":"AsyncHTTPRequest_Generic",
"version": "1.12.0",
"description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP32 with LwIP ENC28J60, ESP8266 (WiFi, W5x00 or ENC28J60) and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, wt32-eth01, stm32, ethernet, wifi, lan8742a, nucleo-144, stm32f7, W5x00, ENC28J60",
"version": "1.13.0",
"description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP32 with LwIP ENC28J60, W5500 or W6100, ESP8266 (WiFi, W5x00 or ENC28J60) and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, wt32-eth01, stm32, ethernet, wifi, lan8742a, nucleo-144, stm32f7, W5x00, ENC28J60, w6100, lwip, lwip-ethernet",
"authors": [
{
"name": "Bob Lemaire",
@@ -69,13 +69,19 @@
{
"owner": "khoih-prog",
"name": "WebServer_ESP32_ENC",
"version": ">=1.5.1",
"version": ">=1.5.3",
"platforms": ["espressif32"]
},
{
"owner": "khoih-prog",
"name": "WebServer_ESP32_W5500",
"version": ">=1.5.1",
"version": ">=1.5.3",
"platforms": ["espressif32"]
},
{
"owner": "khoih-prog",
"name": "WebServer_ESP32_W6100",
"version": ">=1.5.3",
"platforms": ["espressif32"]
},
{
+3 -3
View File
@@ -1,12 +1,12 @@
name=AsyncHTTPRequest_Generic
version=1.12.0
version=1.13.0
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=GPLv3
sentence=Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP32 with LwIP ENC28J60, ESP8266 (WiFi, W5x00 or ENC28J60) and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.
sentence=Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP32 with LwIP ENC28J60, W5500 or W6100, ESP8266 (WiFi, W5x00 or ENC28J60) and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.
paragraph=This AsyncHTTPRequest_Generic Library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, for ESP32 (including WT32_ETH01, LwIP ENC28J60), ESP8266 (WiFi, W5x00 or ENC28J60) and STM32 built-in LAN8742A Ethernet, such as Nucleo-144 F767ZI, etc.
category=Communication
url=https://github.com/khoih-prog/AsyncHTTPRequest_Generic
architectures=*
depends=ESPAsync_WiFiManager, STM32duino LwIP, STM32duino STM32Ethernet, WebServer_WT32_ETH01, WebServer_ESP32_ENC, WebServer_ESP32_W5500
depends=ESPAsync_WiFiManager, STM32duino LwIP, STM32duino STM32Ethernet, WebServer_WT32_ETH01, WebServer_ESP32_ENC, WebServer_ESP32_W5500, WebServer_ESP32_W6100
includes=AsyncHTTPRequest_Generic.h, AsyncHTTPRequest_Generic.hpp
+12 -4
View File
@@ -48,7 +48,9 @@ lib_deps =
; ESPAsync_WiFiManager@>=1.15.1
; LittleFS_esp32@>=1.0.6
; WebServer_WT32_ETH01@>=1.5.1
; WebServer_ESP32_ENC@>=1.5.1
; WebServer_ESP32_ENC@>=1.5.3
; WebServer_ESP32_W5500@>=1.5.3
; WebServer_ESP32_W6100@>=1.5.3
;
; PlatformIO 5.x
; me-no-dev/AsyncTCP@>=1.1.1
@@ -60,7 +62,9 @@ lib_deps =
; khoih-prog/ESPAsync_WiFiManager@>=1.15.1
; lorol/LittleFS_esp32@>=1.0.6
; khoih-prog/WebServer_WT32_ETH01@>=1.5.1
; khoih-prog/WebServer_ESP32_ENC@>=1.5.1
; khoih-prog/WebServer_ESP32_ENC@>=1.5.3
; khoih-prog/WebServer_ESP32_W5500@>=1.5.3
; khoih-prog/WebServer_ESP32_W6100@>=1.5.3
build_flags =
; set your debug output (default=Serial)
@@ -133,14 +137,18 @@ lib_deps =
; ESPAsync_WiFiManager@>=1.15.1
; LittleFS_esp32@>=1.0.6
; WebServer_WT32_ETH01@>=1.5.1
; WebServer_ESP32_ENC@>=1.5.1
; WebServer_ESP32_ENC@>=1.5.3
; WebServer_ESP32_W5500@>=1.5.3
; WebServer_ESP32_W6100@>=1.5.3
;
; PlatformIO 5.x
me-no-dev/AsyncTCP@>=1.1.1
khoih-prog/ESPAsync_WiFiManager@>=1.15.1
; lorol/LittleFS_esp32@>=1.0.6
khoih-prog/WebServer_WT32_ETH01@>=1.5.1
khoih-prog/WebServer_ESP32_ENC@>=1.5.1
khoih-prog/WebServer_ESP32_ENC@>=1.5.3
khoih-prog/WebServer_ESP32_W5500@>=1.5.3
khoih-prog/WebServer_ESP32_W6100@>=1.5.3
; ============================================================
; Board configuration
+2 -1
View File
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.12.0
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
1.13.0 K Hoang 01/02/2023 Add support to ESP32 using LwIP W6100 Ethernet. Fix _parseURL() bug
*****************************************************************************************************************************/
#pragma once
+2 -1
View File
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.12.0
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
1.13.0 K Hoang 01/02/2023 Add support to ESP32 using LwIP W6100 Ethernet. Fix _parseURL() bug
*****************************************************************************************************************************/
#pragma once
+5 -4
View File
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.12.0
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
1.13.0 K Hoang 01/02/2023 Add support to ESP32 using LwIP W6100 Ethernet. Fix _parseURL() bug
*****************************************************************************************************************************/
#pragma once
@@ -46,13 +47,13 @@
////////////////////////////////////////
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.12.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.13.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 12
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 13
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 0
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1012000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1013000
////////////////////////////////////////
+23 -5
View File
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.12.0
Version: 1.13.0
Version Modified By Date Comments
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
1.10.2 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
1.11.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
1.12.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
1.13.0 K Hoang 01/02/2023 Add support to ESP32 using LwIP W6100 Ethernet. Fix _parseURL() bug
*****************************************************************************************************************************/
#pragma once
@@ -1198,12 +1199,29 @@ bool AsyncHTTPRequest::_parseURL(const String& url)
}
int pathBeg = url.indexOf('/', hostBeg);
int hostEnd;
int portBeg;
if (pathBeg < 0)
return false;
{
if ( url.indexOf(':', hostBeg) < 0 )
{
// No port, just https://www.aaa.com
hostEnd = url.length();
}
else
{
// with port, https://www.aaa.com:443
hostEnd = url.indexOf(':', hostBeg);
}
}
else
{
hostEnd = pathBeg;
}
int hostEnd = pathBeg;
int portBeg = url.indexOf(':', hostBeg);
portBeg = url.indexOf(':', hostBeg);
if (portBeg > 0 && portBeg < pathBeg)
{