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

Commit

Permalink
v1.6.4 for ESP32 + LwIP W6100
Browse files Browse the repository at this point in the history
#### 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`
  • Loading branch information
khoih-prog committed Jan 9, 2023
1 parent 56baf88 commit 3b8cecd
Show file tree
Hide file tree
Showing 76 changed files with 21,880 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .codespellrc
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
84 changes: 84 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## Contributing to AsyncWebServer_ESP32_W6100

### Reporting Bugs

Please report bugs in AsyncWebServer_ESP32_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_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_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 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
ESP32_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_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_W6100_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_W6100_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_W6100_GitHub$ bash utils/restyle.sh
```

674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# AsyncWebServer_ESP32_W6100 Library

[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_W6100.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_W6100)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_ESP32_W6100.svg)](https://github.com/khoih-prog/AsyncWebServer_ESP32_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_W6100.svg)](http:https://github.com/khoih-prog/AsyncWebServer_ESP32_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.6.4](#releases-v164)


---
---

## Changelog

#### 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`


Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
/****************************************************************************************************************************
AsyncMultiWebServer_ESP32_W6100.ino
For W6100 LwIP Ethernet in ESP32 (ESP32 + W6100)
AsyncWebServer_ESP32_W6100 is a library for the LwIP Ethernet W6100 in ESP32 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_W6100
Licensed under GPLv3 license
*****************************************************************************************************************************/

#if !( defined(ESP32) )
#error This code is designed for (ESP32 + 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);

//////////////////////////////////////////////////////////

// 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 <AsyncTCP.h>

#include <AsyncWebServer_ESP32_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_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(200);

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_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()
{
}
Loading

0 comments on commit 3b8cecd

Please sign in to comment.