This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#### Releases v1.8.1 1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32_S2/S3/C3 boards using `LwIP W6100 Ethernet` 2. Bump up to `v1.8.1` to sync with [AsyncWebServer_ESP32_W5500 v1.8.1](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500) 3. Use `allman astyle`
- Loading branch information
1 parent
a330e0e
commit db52447
Showing
81 changed files
with
22,302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See: https://github.com/codespell-project/codespell#using-a-config-file | ||
[codespell] | ||
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: | ||
ignore-words-list = , | ||
check-filenames = | ||
check-hidden = | ||
skip = ./.git,./src,./examples,./Packages_Patches,./LibraryPatches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
## Contributing to AsyncWebServer_ESP32_SC_W6100 | ||
|
||
### Reporting Bugs | ||
|
||
Please report bugs in AsyncWebServer_ESP32_SC_W6100 if you find them. | ||
|
||
However, before reporting a bug please check through the following: | ||
|
||
* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W6100/issues) - someone might have already encountered this. | ||
|
||
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W6100/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 | ||
* Board type (e.g. ESP32S3_DEV, ESP32S2_DEV, ESP32C3_DEV) | ||
* Board Core Version (e.g. ESP32 core 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: | ||
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a` | ||
* 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 | ||
ESP32S3_DEV board | ||
ESP32 core v2.0.6 | ||
OS: Ubuntu 20.04 LTS | ||
Linux xy-Inspiron-3593 5.15.0-57-generic #63~20.04.1-Ubuntu SMP Wed Nov 30 13:40:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux | ||
Context: | ||
I encountered a crash while using this library | ||
Steps to reproduce: | ||
1. ... | ||
2. ... | ||
3. ... | ||
4. ... | ||
``` | ||
|
||
### Additional context | ||
|
||
Add any other context about the problem here. | ||
|
||
--- | ||
|
||
### Sending Feature Requests | ||
|
||
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful. | ||
|
||
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W6100/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them. | ||
|
||
--- | ||
|
||
### Sending Pull Requests | ||
|
||
Pull Requests with changes and fixes are also welcome! | ||
|
||
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux) | ||
|
||
1. Change directory to the library GitHub | ||
|
||
``` | ||
xy@xy-Inspiron-3593:~$ cd Arduino/xy/AsyncWebServer_ESP32_SC_W6100_GitHub/ | ||
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_SC_W6100_GitHub$ | ||
``` | ||
|
||
2. Issue astyle command | ||
|
||
``` | ||
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_SC_W6100_GitHub$ bash utils/restyle.sh | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# AsyncWebServer_ESP32_SC_W6100 Library | ||
|
||
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_SC_W6100.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_SC_W6100) | ||
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_ESP32_SC_W6100.svg)](https://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W6100/releases) | ||
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) | ||
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncWebServer_ESP32_SC_W6100.svg)](http://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W6100/issues) | ||
|
||
<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> | ||
|
||
|
||
--- | ||
--- | ||
|
||
## Table of contents | ||
|
||
* [Changelog](#changelog) | ||
* [Releases v1.8.1](#releases-v181) | ||
* [Releases v1.8.0](#releases-v180) | ||
* [Releases v1.7.0](#releases-v170) | ||
* [Releases v1.6.3](#releases-v163) | ||
|
||
|
||
--- | ||
--- | ||
|
||
## Changelog | ||
|
||
#### Releases v1.8.1 | ||
|
||
1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32_S2/S3/C3 boards using `LwIP W6100 Ethernet` | ||
2. Bump up to `v1.8.1` to sync with [AsyncWebServer_ESP32_W5500 v1.8.1](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500) | ||
3. Use `allman astyle` | ||
|
||
|
267 changes: 267 additions & 0 deletions
267
examples/AsyncMultiWebServer_ESP32_W6100/AsyncMultiWebServer_ESP32_W6100.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,267 @@ | ||
/**************************************************************************************************************************** | ||
AsyncMultiWebServer_ESP32_W6100.ino | ||
For W6100 LwIP Ethernet in ESP32_SC_W6100 (ESP32_S2/3, ESP32_C3 + W6100) | ||
AsyncWebServer_ESP32_SC_W6100 is a library for the LwIP Ethernet W6100 in ESP32_S2/3, ESP32_C3 to run AsyncWebServer | ||
Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer) | ||
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W6100 | ||
Licensed under GPLv3 license | ||
*****************************************************************************************************************************/ | ||
|
||
#if !( defined(ESP32) ) | ||
#error This code is designed for (ESP32_S2/3, ESP32_C3 + W6100) to run on ESP32 platform! Please check your Tools->Board setting. | ||
#endif | ||
|
||
#include <Arduino.h> | ||
|
||
#define _ASYNC_WEBSERVER_LOGLEVEL_ 2 | ||
|
||
// 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); | ||
|
||
////////////////////////////////////////////////////////// | ||
|
||
// For ESP32-S3 | ||
// 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 13 | ||
//#define MOSI_GPIO 11 | ||
//#define SCK_GPIO 12 | ||
//#define CS_GPIO 10 | ||
|
||
// For ESP32_C3 | ||
// Optional values to override default settings | ||
// Don't change unless you know what you're doing | ||
//#define ETH_SPI_HOST SPI2_HOST | ||
//#define SPI_CLOCK_MHZ 25 | ||
|
||
// Must connect INT to GPIOxx or not working | ||
//#define INT_GPIO 10 | ||
|
||
//#define MISO_GPIO 5 | ||
//#define MOSI_GPIO 6 | ||
//#define SCK_GPIO 4 | ||
//#define CS_GPIO 7 | ||
|
||
////////////////////////////////////////////////////////// | ||
|
||
#include <AsyncTCP.h> | ||
|
||
#include <AsyncWebServer_ESP32_SC_W6100.h> | ||
|
||
unsigned int analogReadPin [] = { 12, 13, 14 }; | ||
|
||
#define BUFFER_SIZE 500 | ||
|
||
#define HTTP_PORT1 8080 | ||
#define HTTP_PORT2 8081 | ||
#define HTTP_PORT3 8082 | ||
|
||
AsyncWebServer* server1; | ||
AsyncWebServer* server2; | ||
AsyncWebServer* server3; | ||
|
||
AsyncWebServer* multiServer [] = { server1, server2, server3 }; | ||
uint16_t http_port [] = { HTTP_PORT1, HTTP_PORT2, HTTP_PORT3 }; | ||
|
||
#define NUM_SERVERS ( sizeof(multiServer) / sizeof(AsyncWebServer*) ) | ||
|
||
unsigned int serverIndex; | ||
|
||
String createBuffer() | ||
{ | ||
char temp[BUFFER_SIZE]; | ||
|
||
memset(temp, 0, sizeof(temp)); | ||
|
||
int sec = millis() / 1000; | ||
int min = sec / 60; | ||
int hr = min / 60; | ||
int day = hr / 24; | ||
|
||
snprintf(temp, BUFFER_SIZE - 1, | ||
"<html>\ | ||
<head>\ | ||
<meta http-equiv='refresh' content='5'/>\ | ||
<title>%s</title>\ | ||
<style>\ | ||
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\ | ||
</style>\ | ||
</head>\ | ||
<body>\ | ||
<h1>Hello from %s</h1>\ | ||
<h2>running AsyncMultiWebServer_ESP32_SC_W6100</h2>\ | ||
<h3>on %s</h3>\ | ||
<h3>Uptime: %d d %02d:%02d:%02d</h3>\ | ||
</body>\ | ||
</html>", ARDUINO_BOARD, ARDUINO_BOARD, SHIELD_TYPE, day, hr, min % 60, sec % 60); | ||
|
||
return temp; | ||
} | ||
|
||
|
||
void handleRoot(AsyncWebServerRequest * request) | ||
{ | ||
String message = createBuffer(); | ||
request->send(200, F("text/html"), message); | ||
} | ||
|
||
String createNotFoundBuffer(AsyncWebServerRequest * request) | ||
{ | ||
String message; | ||
|
||
message.reserve(500); | ||
|
||
message = F("File Not Found\n\n"); | ||
|
||
message += F("URI: "); | ||
message += request->url(); | ||
message += F("\nMethod: "); | ||
message += (request->method() == HTTP_GET) ? F("GET") : F("POST"); | ||
message += F("\nArguments: "); | ||
message += request->args(); | ||
message += F("\n"); | ||
|
||
for (uint8_t i = 0; i < request->args(); i++) | ||
{ | ||
message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; | ||
} | ||
|
||
return message; | ||
} | ||
|
||
void handleNotFound(AsyncWebServerRequest * request) | ||
{ | ||
String message = createNotFoundBuffer(request); | ||
request->send(404, F("text/plain"), message); | ||
} | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
|
||
while (!Serial && millis() < 5000); | ||
|
||
delay(500); | ||
|
||
Serial.print(F("\nStart AsyncMultiWebServer_ESP32_W6100 on ")); | ||
Serial.print(ARDUINO_BOARD); | ||
Serial.print(F(" with ")); | ||
Serial.println(SHIELD_TYPE); | ||
Serial.println(ASYNC_WEBSERVER_ESP32_SC_W6100_VERSION); | ||
|
||
AWS_LOGWARN(F("Default SPI pinout:")); | ||
AWS_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST); | ||
AWS_LOGWARN1(F("MOSI:"), MOSI_GPIO); | ||
AWS_LOGWARN1(F("MISO:"), MISO_GPIO); | ||
AWS_LOGWARN1(F("SCK:"), SCK_GPIO); | ||
AWS_LOGWARN1(F("CS:"), CS_GPIO); | ||
AWS_LOGWARN1(F("INT:"), INT_GPIO); | ||
AWS_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ); | ||
AWS_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 | ||
//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[millis() % NUMBER_OF_MAC] ); | ||
|
||
// 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("\nConnected to network. IP = "); | ||
Serial.println(ETH.localIP()); | ||
|
||
for (serverIndex = 0; serverIndex < NUM_SERVERS; serverIndex++) | ||
{ | ||
multiServer[serverIndex] = new AsyncWebServer(http_port[serverIndex]); | ||
|
||
if (multiServer[serverIndex]) | ||
{ | ||
Serial.printf("Initialize multiServer OK, serverIndex = %d, port = %d\n", serverIndex, http_port[serverIndex]); | ||
} | ||
else | ||
{ | ||
Serial.printf("Error initialize multiServer, serverIndex = %d\n", serverIndex); | ||
|
||
while (1); | ||
} | ||
|
||
multiServer[serverIndex]->on("/", HTTP_GET, [](AsyncWebServerRequest * request) | ||
{ | ||
handleRoot(request); | ||
}); | ||
|
||
multiServer[serverIndex]->on("/hello", HTTP_GET, [](AsyncWebServerRequest * request) | ||
{ | ||
String message = F("Hello from AsyncMultiWebServer_ESP32_W6100 using W6100 Ethernet, running on "); | ||
message += ARDUINO_BOARD; | ||
|
||
request->send(200, "text/plain", message); | ||
}); | ||
|
||
multiServer[serverIndex]->onNotFound([](AsyncWebServerRequest * request) | ||
{ | ||
handleNotFound(request); | ||
}); | ||
|
||
multiServer[serverIndex]->begin(); | ||
|
||
Serial.printf("HTTP server started at ports %d\n", http_port[serverIndex]); | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
} |
Oops, something went wrong.