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

Commit db52447

Browse files
authored
v1.8.1 for ESP32_SC + LwIP W6100
#### 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`
1 parent a330e0e commit db52447

File tree

81 files changed

+22302
-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.

81 files changed

+22302
-0
lines changed

.codespellrc

+7
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

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## Contributing to AsyncWebServer_ESP32_SC_W6100
2+
3+
### Reporting Bugs
4+
5+
Please report bugs in AsyncWebServer_ESP32_SC_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_SC_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_SC_W6100/issues/new).
12+
13+
### How to submit a bug report
14+
15+
Please ensure to specify the following:
16+
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* Board type (e.g. ESP32S3_DEV, ESP32S2_DEV, ESP32C3_DEV)
19+
* Board Core Version (e.g. ESP32 core v2.0.6)
20+
* Contextual information (e.g. what you were trying to achieve)
21+
* Simplest possible steps to reproduce
22+
* Anything that might be relevant in your opinion, such as:
23+
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
24+
* Network configuration
25+
26+
27+
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.
28+
29+
30+
### Example
31+
32+
```
33+
Arduino IDE version: 1.8.19
34+
ESP32S3_DEV board
35+
ESP32 core v2.0.6
36+
OS: Ubuntu 20.04 LTS
37+
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
38+
39+
Context:
40+
I encountered a crash while using this library
41+
Steps to reproduce:
42+
1. ...
43+
2. ...
44+
3. ...
45+
4. ...
46+
```
47+
48+
### Additional context
49+
50+
Add any other context about the problem here.
51+
52+
---
53+
54+
### Sending Feature Requests
55+
56+
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
57+
58+
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.
59+
60+
---
61+
62+
### Sending Pull Requests
63+
64+
Pull Requests with changes and fixes are also welcome!
65+
66+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
67+
68+
1. Change directory to the library GitHub
69+
70+
```
71+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/AsyncWebServer_ESP32_SC_W6100_GitHub/
72+
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_SC_W6100_GitHub$
73+
```
74+
75+
2. Issue astyle command
76+
77+
```
78+
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_SC_W6100_GitHub$ bash utils/restyle.sh
79+
```
80+

LICENSE

+674
Large diffs are not rendered by default.

changelog.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# AsyncWebServer_ESP32_SC_W6100 Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_SC_W6100.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_SC_W6100)
4+
[![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)
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_SC_W6100.svg)](http://github.com/khoih-prog/AsyncWebServer_ESP32_SC_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.8.1](#releases-v181)
19+
* [Releases v1.8.0](#releases-v180)
20+
* [Releases v1.7.0](#releases-v170)
21+
* [Releases v1.6.3](#releases-v163)
22+
23+
24+
---
25+
---
26+
27+
## Changelog
28+
29+
#### Releases v1.8.1
30+
31+
1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32_S2/S3/C3 boards using `LwIP W6100 Ethernet`
32+
2. Bump up to `v1.8.1` to sync with [AsyncWebServer_ESP32_W5500 v1.8.1](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500)
33+
3. Use `allman astyle`
34+
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
/****************************************************************************************************************************
2+
AsyncMultiWebServer_ESP32_W6100.ino
3+
4+
For W6100 LwIP Ethernet in ESP32_SC_W6100 (ESP32_S2/3, ESP32_C3 + W6100)
5+
6+
AsyncWebServer_ESP32_SC_W6100 is a library for the LwIP Ethernet W6100 in ESP32_S2/3, ESP32_C3 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_SC_W6100
10+
Licensed under GPLv3 license
11+
*****************************************************************************************************************************/
12+
13+
#if !( defined(ESP32) )
14+
#error This code is designed for (ESP32_S2/3, ESP32_C3 + 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+
// For ESP32-S3
59+
// Optional values to override default settings
60+
// Don't change unless you know what you're doing
61+
//#define ETH_SPI_HOST SPI3_HOST
62+
//#define SPI_CLOCK_MHZ 25
63+
64+
// Must connect INT to GPIOxx or not working
65+
//#define INT_GPIO 4
66+
67+
//#define MISO_GPIO 13
68+
//#define MOSI_GPIO 11
69+
//#define SCK_GPIO 12
70+
//#define CS_GPIO 10
71+
72+
// For ESP32_C3
73+
// Optional values to override default settings
74+
// Don't change unless you know what you're doing
75+
//#define ETH_SPI_HOST SPI2_HOST
76+
//#define SPI_CLOCK_MHZ 25
77+
78+
// Must connect INT to GPIOxx or not working
79+
//#define INT_GPIO 10
80+
81+
//#define MISO_GPIO 5
82+
//#define MOSI_GPIO 6
83+
//#define SCK_GPIO 4
84+
//#define CS_GPIO 7
85+
86+
//////////////////////////////////////////////////////////
87+
88+
#include <AsyncTCP.h>
89+
90+
#include <AsyncWebServer_ESP32_SC_W6100.h>
91+
92+
unsigned int analogReadPin [] = { 12, 13, 14 };
93+
94+
#define BUFFER_SIZE 500
95+
96+
#define HTTP_PORT1 8080
97+
#define HTTP_PORT2 8081
98+
#define HTTP_PORT3 8082
99+
100+
AsyncWebServer* server1;
101+
AsyncWebServer* server2;
102+
AsyncWebServer* server3;
103+
104+
AsyncWebServer* multiServer [] = { server1, server2, server3 };
105+
uint16_t http_port [] = { HTTP_PORT1, HTTP_PORT2, HTTP_PORT3 };
106+
107+
#define NUM_SERVERS ( sizeof(multiServer) / sizeof(AsyncWebServer*) )
108+
109+
unsigned int serverIndex;
110+
111+
String createBuffer()
112+
{
113+
char temp[BUFFER_SIZE];
114+
115+
memset(temp, 0, sizeof(temp));
116+
117+
int sec = millis() / 1000;
118+
int min = sec / 60;
119+
int hr = min / 60;
120+
int day = hr / 24;
121+
122+
snprintf(temp, BUFFER_SIZE - 1,
123+
"<html>\
124+
<head>\
125+
<meta http-equiv='refresh' content='5'/>\
126+
<title>%s</title>\
127+
<style>\
128+
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
129+
</style>\
130+
</head>\
131+
<body>\
132+
<h1>Hello from %s</h1>\
133+
<h2>running AsyncMultiWebServer_ESP32_SC_W6100</h2>\
134+
<h3>on %s</h3>\
135+
<h3>Uptime: %d d %02d:%02d:%02d</h3>\
136+
</body>\
137+
</html>", ARDUINO_BOARD, ARDUINO_BOARD, SHIELD_TYPE, day, hr, min % 60, sec % 60);
138+
139+
return temp;
140+
}
141+
142+
143+
void handleRoot(AsyncWebServerRequest * request)
144+
{
145+
String message = createBuffer();
146+
request->send(200, F("text/html"), message);
147+
}
148+
149+
String createNotFoundBuffer(AsyncWebServerRequest * request)
150+
{
151+
String message;
152+
153+
message.reserve(500);
154+
155+
message = F("File Not Found\n\n");
156+
157+
message += F("URI: ");
158+
message += request->url();
159+
message += F("\nMethod: ");
160+
message += (request->method() == HTTP_GET) ? F("GET") : F("POST");
161+
message += F("\nArguments: ");
162+
message += request->args();
163+
message += F("\n");
164+
165+
for (uint8_t i = 0; i < request->args(); i++)
166+
{
167+
message += " " + request->argName(i) + ": " + request->arg(i) + "\n";
168+
}
169+
170+
return message;
171+
}
172+
173+
void handleNotFound(AsyncWebServerRequest * request)
174+
{
175+
String message = createNotFoundBuffer(request);
176+
request->send(404, F("text/plain"), message);
177+
}
178+
179+
void setup()
180+
{
181+
Serial.begin(115200);
182+
183+
while (!Serial && millis() < 5000);
184+
185+
delay(500);
186+
187+
Serial.print(F("\nStart AsyncMultiWebServer_ESP32_W6100 on "));
188+
Serial.print(ARDUINO_BOARD);
189+
Serial.print(F(" with "));
190+
Serial.println(SHIELD_TYPE);
191+
Serial.println(ASYNC_WEBSERVER_ESP32_SC_W6100_VERSION);
192+
193+
AWS_LOGWARN(F("Default SPI pinout:"));
194+
AWS_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
195+
AWS_LOGWARN1(F("MOSI:"), MOSI_GPIO);
196+
AWS_LOGWARN1(F("MISO:"), MISO_GPIO);
197+
AWS_LOGWARN1(F("SCK:"), SCK_GPIO);
198+
AWS_LOGWARN1(F("CS:"), CS_GPIO);
199+
AWS_LOGWARN1(F("INT:"), INT_GPIO);
200+
AWS_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
201+
AWS_LOGWARN(F("========================="));
202+
203+
///////////////////////////////////
204+
205+
// To be called before ETH.begin()
206+
ESP32_W6100_onEvent();
207+
208+
// start the ethernet connection and the server:
209+
// Use DHCP dynamic IP and random mac
210+
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
211+
// int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac);
212+
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
213+
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] );
214+
215+
// Static IP, leave without this line to get IP via DHCP
216+
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
217+
//ETH.config(myIP, myGW, mySN, myDNS);
218+
219+
ESP32_W6100_waitForConnect();
220+
221+
///////////////////////////////////
222+
223+
Serial.print("\nConnected to network. IP = ");
224+
Serial.println(ETH.localIP());
225+
226+
for (serverIndex = 0; serverIndex < NUM_SERVERS; serverIndex++)
227+
{
228+
multiServer[serverIndex] = new AsyncWebServer(http_port[serverIndex]);
229+
230+
if (multiServer[serverIndex])
231+
{
232+
Serial.printf("Initialize multiServer OK, serverIndex = %d, port = %d\n", serverIndex, http_port[serverIndex]);
233+
}
234+
else
235+
{
236+
Serial.printf("Error initialize multiServer, serverIndex = %d\n", serverIndex);
237+
238+
while (1);
239+
}
240+
241+
multiServer[serverIndex]->on("/", HTTP_GET, [](AsyncWebServerRequest * request)
242+
{
243+
handleRoot(request);
244+
});
245+
246+
multiServer[serverIndex]->on("/hello", HTTP_GET, [](AsyncWebServerRequest * request)
247+
{
248+
String message = F("Hello from AsyncMultiWebServer_ESP32_W6100 using W6100 Ethernet, running on ");
249+
message += ARDUINO_BOARD;
250+
251+
request->send(200, "text/plain", message);
252+
});
253+
254+
multiServer[serverIndex]->onNotFound([](AsyncWebServerRequest * request)
255+
{
256+
handleNotFound(request);
257+
});
258+
259+
multiServer[serverIndex]->begin();
260+
261+
Serial.printf("HTTP server started at ports %d\n", http_port[serverIndex]);
262+
}
263+
}
264+
265+
void loop()
266+
{
267+
}

0 commit comments

Comments
 (0)