Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 3b8cecd

Browse files
authored
v1.6.4 for ESP32 + LwIP W6100
#### Releases v1.6.4 1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32 boards using `LwIP W6100 Ethernet`. 2. Bump up to `v1.6.4` to sync with [AsyncWebServer_ESP32_W5500 v1.6.4](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500) 3. Use `allman astyle`
1 parent 56baf88 commit 3b8cecd

File tree

76 files changed

+21880
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+21880
-0
lines changed

.codespellrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# See: https://github.com/codespell-project/codespell#using-a-config-file
2+
[codespell]
3+
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
4+
ignore-words-list = ,
5+
check-filenames =
6+
check-hidden =
7+
skip = ./.git,./src,./examples,./Packages_Patches,./LibraryPatches

CONTRIBUTING.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
## Contributing to AsyncWebServer_ESP32_W6100
2+
3+
### Reporting Bugs
4+
5+
Please report bugs in AsyncWebServer_ESP32_W6100 if you find them.
6+
7+
However, before reporting a bug please check through the following:
8+
9+
* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_ESP32_W6100/issues) - someone might have already encountered this.
10+
11+
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_ESP32_W6100/issues/new).
12+
13+
---
14+
15+
### How to submit a bug report
16+
17+
Please ensure to specify the following:
18+
19+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
20+
* Board Core Version (e.g. ESP32 core v2.0.6)
21+
* Contextual information (e.g. what you were trying to achieve)
22+
* Simplest possible steps to reproduce
23+
* Anything that might be relevant in your opinion, such as:
24+
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
25+
* Network configuration
26+
27+
28+
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.
29+
30+
---
31+
32+
### Example
33+
34+
```
35+
Arduino IDE version: 1.8.19
36+
ESP32_DEV board
37+
ESP32 core v2.0.6
38+
OS: Ubuntu 20.04 LTS
39+
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
40+
41+
Context:
42+
I encountered a crash while using this library
43+
Steps to reproduce:
44+
1. ...
45+
2. ...
46+
3. ...
47+
4. ...
48+
```
49+
50+
---
51+
52+
### Additional context
53+
54+
Add any other context about the problem here.
55+
56+
---
57+
58+
### Sending Feature Requests
59+
60+
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
61+
62+
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/AsyncWebServer_ESP32_W6100/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
63+
64+
---
65+
66+
### Sending Pull Requests
67+
68+
Pull Requests with changes and fixes are also welcome!
69+
70+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
71+
72+
1. Change directory to the library GitHub
73+
74+
```
75+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/AsyncWebServer_ESP32_W6100_GitHub/
76+
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_W6100_GitHub$
77+
```
78+
79+
2. Issue astyle command
80+
81+
```
82+
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_W6100_GitHub$ bash utils/restyle.sh
83+
```
84+

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

changelog.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# AsyncWebServer_ESP32_W6100 Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_W6100.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_W6100)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_ESP32_W6100.svg)](https://github.com/khoih-prog/AsyncWebServer_ESP32_W6100/releases)
5+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
6+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncWebServer_ESP32_W6100.svg)](http://github.com/khoih-prog/AsyncWebServer_ESP32_W6100/issues)
7+
8+
<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>
9+
<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>
10+
11+
12+
---
13+
---
14+
15+
## Table of contents
16+
17+
* [Changelog](#changelog)
18+
* [Releases v1.6.4](#releases-v164)
19+
20+
21+
---
22+
---
23+
24+
## Changelog
25+
26+
#### Releases v1.6.4
27+
28+
1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32 boards using `LwIP W6100 Ethernet`.
29+
2. Bump up to `v1.6.4` to sync with [AsyncWebServer_ESP32_W5500 v1.6.4](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500)
30+
3. Use `allman astyle`
31+
32+
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
/****************************************************************************************************************************
2+
AsyncMultiWebServer_ESP32_W6100.ino
3+
4+
For W6100 LwIP Ethernet in ESP32 (ESP32 + W6100)
5+
6+
AsyncWebServer_ESP32_W6100 is a library for the LwIP Ethernet W6100 in ESP32 to run AsyncWebServer
7+
8+
Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer)
9+
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_ESP32_W6100
10+
Licensed under GPLv3 license
11+
*****************************************************************************************************************************/
12+
13+
#if !( defined(ESP32) )
14+
#error This code is designed for (ESP32 + W6100) to run on ESP32 platform! Please check your Tools->Board setting.
15+
#endif
16+
17+
#include <Arduino.h>
18+
19+
#define _ASYNC_WEBSERVER_LOGLEVEL_ 2
20+
21+
// Enter a MAC address and IP address for your controller below.
22+
#define NUMBER_OF_MAC 20
23+
24+
byte mac[][NUMBER_OF_MAC] =
25+
{
26+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
27+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
28+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
29+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
30+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
31+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
32+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
33+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
34+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
35+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
36+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
37+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
38+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
39+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
40+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
41+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
42+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
43+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
44+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
45+
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
46+
};
47+
48+
// Select the IP address according to your local network
49+
IPAddress myIP(192, 168, 2, 232);
50+
IPAddress myGW(192, 168, 2, 1);
51+
IPAddress mySN(255, 255, 255, 0);
52+
53+
// Google DNS Server IP
54+
IPAddress myDNS(8, 8, 8, 8);
55+
56+
//////////////////////////////////////////////////////////
57+
58+
// Optional values to override default settings
59+
// Don't change unless you know what you're doing
60+
//#define ETH_SPI_HOST SPI3_HOST
61+
//#define SPI_CLOCK_MHZ 25
62+
63+
// Must connect INT to GPIOxx or not working
64+
//#define INT_GPIO 4
65+
66+
//#define MISO_GPIO 19
67+
//#define MOSI_GPIO 23
68+
//#define SCK_GPIO 18
69+
//#define CS_GPIO 5
70+
71+
//////////////////////////////////////////////////////////
72+
73+
#include <AsyncTCP.h>
74+
75+
#include <AsyncWebServer_ESP32_W6100.h>
76+
77+
unsigned int analogReadPin [] = { 12, 13, 14 };
78+
79+
#define BUFFER_SIZE 500
80+
81+
#define HTTP_PORT1 8080
82+
#define HTTP_PORT2 8081
83+
#define HTTP_PORT3 8082
84+
85+
AsyncWebServer* server1;
86+
AsyncWebServer* server2;
87+
AsyncWebServer* server3;
88+
89+
AsyncWebServer* multiServer [] = { server1, server2, server3 };
90+
uint16_t http_port [] = { HTTP_PORT1, HTTP_PORT2, HTTP_PORT3 };
91+
92+
#define NUM_SERVERS ( sizeof(multiServer) / sizeof(AsyncWebServer*) )
93+
94+
unsigned int serverIndex;
95+
96+
String createBuffer()
97+
{
98+
char temp[BUFFER_SIZE];
99+
100+
memset(temp, 0, sizeof(temp));
101+
102+
int sec = millis() / 1000;
103+
int min = sec / 60;
104+
int hr = min / 60;
105+
int day = hr / 24;
106+
107+
snprintf(temp, BUFFER_SIZE - 1,
108+
"<html>\
109+
<head>\
110+
<meta http-equiv='refresh' content='5'/>\
111+
<title>%s</title>\
112+
<style>\
113+
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
114+
</style>\
115+
</head>\
116+
<body>\
117+
<h1>Hello from %s</h1>\
118+
<h2>running AsyncMultiWebServer_ESP32_W6100</h2>\
119+
<h3>on %s</h3>\
120+
<h3>Uptime: %d d %02d:%02d:%02d</h3>\
121+
</body>\
122+
</html>", ARDUINO_BOARD, ARDUINO_BOARD, SHIELD_TYPE, day, hr, min % 60, sec % 60);
123+
124+
return temp;
125+
}
126+
127+
128+
void handleRoot(AsyncWebServerRequest * request)
129+
{
130+
String message = createBuffer();
131+
request->send(200, F("text/html"), message);
132+
}
133+
134+
String createNotFoundBuffer(AsyncWebServerRequest * request)
135+
{
136+
String message;
137+
138+
message.reserve(500);
139+
140+
message = F("File Not Found\n\n");
141+
142+
message += F("URI: ");
143+
message += request->url();
144+
message += F("\nMethod: ");
145+
message += (request->method() == HTTP_GET) ? F("GET") : F("POST");
146+
message += F("\nArguments: ");
147+
message += request->args();
148+
message += F("\n");
149+
150+
for (uint8_t i = 0; i < request->args(); i++)
151+
{
152+
message += " " + request->argName(i) + ": " + request->arg(i) + "\n";
153+
}
154+
155+
return message;
156+
}
157+
158+
void handleNotFound(AsyncWebServerRequest * request)
159+
{
160+
String message = createNotFoundBuffer(request);
161+
request->send(404, F("text/plain"), message);
162+
}
163+
164+
void setup()
165+
{
166+
Serial.begin(115200);
167+
168+
while (!Serial && millis() < 5000);
169+
170+
delay(200);
171+
172+
Serial.print(F("\nStart AsyncMultiWebServer_ESP32_W6100 on "));
173+
Serial.print(ARDUINO_BOARD);
174+
Serial.print(F(" with "));
175+
Serial.println(SHIELD_TYPE);
176+
Serial.println(ASYNC_WEBSERVER_ESP32_W6100_VERSION);
177+
178+
AWS_LOGWARN(F("Default SPI pinout:"));
179+
AWS_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
180+
AWS_LOGWARN1(F("MOSI:"), MOSI_GPIO);
181+
AWS_LOGWARN1(F("MISO:"), MISO_GPIO);
182+
AWS_LOGWARN1(F("SCK:"), SCK_GPIO);
183+
AWS_LOGWARN1(F("CS:"), CS_GPIO);
184+
AWS_LOGWARN1(F("INT:"), INT_GPIO);
185+
AWS_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
186+
AWS_LOGWARN(F("========================="));
187+
188+
///////////////////////////////////
189+
190+
// To be called before ETH.begin()
191+
ESP32_W6100_onEvent();
192+
193+
// start the ethernet connection and the server:
194+
// Use DHCP dynamic IP and random mac
195+
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
196+
// int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac);
197+
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
198+
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] );
199+
200+
// Static IP, leave without this line to get IP via DHCP
201+
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
202+
//ETH.config(myIP, myGW, mySN, myDNS);
203+
204+
ESP32_W6100_waitForConnect();
205+
206+
///////////////////////////////////
207+
208+
Serial.print("\nConnected to network. IP = ");
209+
Serial.println(ETH.localIP());
210+
211+
for (serverIndex = 0; serverIndex < NUM_SERVERS; serverIndex++)
212+
{
213+
multiServer[serverIndex] = new AsyncWebServer(http_port[serverIndex]);
214+
215+
if (multiServer[serverIndex])
216+
{
217+
Serial.printf("Initialize multiServer OK, serverIndex = %d, port = %d\n", serverIndex, http_port[serverIndex]);
218+
}
219+
else
220+
{
221+
Serial.printf("Error initialize multiServer, serverIndex = %d\n", serverIndex);
222+
223+
while (1);
224+
}
225+
226+
multiServer[serverIndex]->on("/", HTTP_GET, [](AsyncWebServerRequest * request)
227+
{
228+
handleRoot(request);
229+
});
230+
231+
multiServer[serverIndex]->on("/hello", HTTP_GET, [](AsyncWebServerRequest * request)
232+
{
233+
String message = F("Hello from AsyncMultiWebServer_ESP32_W6100 using W6100 Ethernet, running on ");
234+
message += ARDUINO_BOARD;
235+
236+
request->send(200, "text/plain", message);
237+
});
238+
239+
multiServer[serverIndex]->onNotFound([](AsyncWebServerRequest * request)
240+
{
241+
handleNotFound(request);
242+
});
243+
244+
multiServer[serverIndex]->begin();
245+
246+
Serial.printf("HTTP server started at ports %d\n", http_port[serverIndex]);
247+
}
248+
}
249+
250+
void loop()
251+
{
252+
}

0 commit comments

Comments
 (0)