Skip to content
This repository was archived by the owner on Jan 31, 2024. It is now read-only.

Commit ffe036c

Browse files
authored
v1.6.0 to save heap when sending large data
### Releases v1.6.0 1. Support using `CString` to save heap to send `very large data`. Check [request->send(200, textPlainStr, jsonChartDataCharStr); - Without using String Class - to save heap #8](khoih-prog/Portenta_H7_AsyncWebServer#8) and [All memmove() removed - string no longer destroyed #11](khoih-prog/Portenta_H7_AsyncWebServer#11) 2. Add multiple examples to demo the new feature
1 parent 6b85614 commit ffe036c

File tree

62 files changed

+11542
-839
lines changed

Some content is hidden

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

62 files changed

+11542
-839
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
## Contributing to AsyncWebServer_Teensy41
1+
## Contributing to AsyncWebServer_Ethernet
22

33
### Reporting Bugs
44

5-
Please report bugs in AsyncWebServer_Teensy41 if you find them.
5+
Please report bugs in AsyncWebServer_Ethernet if you find them.
66

77
However, before reporting a bug please check through the following:
88

9-
* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_Teensy41/issues) - someone might have already encountered this.
9+
* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_Ethernet/issues) - someone might have already encountered this.
1010

11-
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_Teensy41/issues/new).
11+
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_Ethernet/issues/new).
1212

1313
### How to submit a bug report
1414

1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* `Teensyduino` Core Version (e.g. `Teensyduino core v1.57`)
19-
* `QNEthernet` library version (e.g. `QNEthernet v0.15.0`)
20-
* Board type and relevant info
18+
* Board Core Version (e.g. ESP8266 core v3.0.2)
2119
* Contextual information (e.g. what you were trying to achieve)
2220
* Simplest possible steps to reproduce
2321
* Anything that might be relevant in your opinion, such as:
@@ -29,25 +27,26 @@ Please ensure to specify the following:
2927

3028
```
3129
Arduino IDE version: 1.8.19
32-
Teensyduino core v1.57
33-
Teensy 4.1 using QNEthernet v0.15.0
30+
ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet
31+
ESP8266 core v3.0.2
3432
OS: Ubuntu 20.04 LTS
3533
Linux xy-Inspiron-3593 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3634
3735
Context:
38-
I encountered an endless loop while using this library
36+
I encountered a crash while using this library
3937
4038
Steps to reproduce:
4139
1. ...
4240
2. ...
4341
3. ...
4442
4. ...
4543
```
44+
4645
### Sending Feature Requests
4746

4847
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
4948

50-
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/AsyncWebServer_Teensy41/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
49+
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/AsyncWebServer_Ethernet/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
5150

5251
### Sending Pull Requests
5352

changelog.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# AsyncWebServer_Teensy41
1+
# AsyncWebServer_Ethernet
22

3-
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_Teensy41.svg?)](https://www.ardu-badge.com/AsyncWebServer_Teensy41)
4-
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_Teensy41.svg)](https://github.com/khoih-prog/AsyncWebServer_Teensy41/releases)
5-
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/AsyncWebServer_Teensy41/blob/master/LICENSE)
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_Ethernet.svg?)](https://www.ardu-badge.com/AsyncWebServer_Ethernet)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_Ethernet.svg)](https://github.com/khoih-prog/AsyncWebServer_Ethernet/releases)
65
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
7-
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncWebServer_Teensy41.svg)](http://github.com/khoih-prog/AsyncWebServer_Teensy41/issues)
6+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncWebServer_Ethernet.svg)](http://github.com/khoih-prog/AsyncWebServer_Ethernet/issues)
87

98
---
109
---
1110

1211
## Table of contents
1312

14-
* [Table of contents](#table-of-contents)
1513
* [Changelog](#changelog)
1614
* [Releases v1.5.0](#releases-v150)
1715
* [Releases v1.4.1](#releases-v141)
@@ -21,15 +19,16 @@
2119

2220
## Changelog
2321

24-
### Releases v1.5.0
22+
#### Releases v1.5.0
2523

26-
1. Fix issue with slow browsers or network. Check [Target stops responding after variable time when using Firefox on Windows 10 #3](https://github.com/khoih-prog/AsyncWebServer_RP2040W/issues/3)
27-
2. Add functions and example `Async_AdvancedWebServer_favicon` to support `favicon.ico`
24+
1. Support using `CString` to save heap to send `very large data`. Check [request->send(200, textPlainStr, jsonChartDataCharStr); - Without using String Class - to save heap #8](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/pull/8) and [All memmove() removed - string no longer destroyed #11](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/pull/11)
25+
2. Add multiple examples to demo the new feature
2826

29-
### Releases v1.4.1
30-
31-
1. Initial porting and coding for **Teensy 4.1 using built-in QNEthernet**
32-
2. Bump up version to v1.4.1 to sync with [AsyncWebServer_STM32](https://github.com/khoih-prog/AsyncWebServer_STM32) v1.4.1
27+
#### Releases v1.4.1
3328

29+
1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP8266 boards using W5x00 / ENC28J60 Ethernet.
30+
2. Add more examples.
31+
3. Add debugging features.
32+
4. Bump up to v1.4.1 to sync with [AsyncWebServer_WT32_ETH01 v1.4.1](https://github.com/khoih-prog/AsyncWebServer_WT32_ETH01).
3433

3534

examples/AsyncMultiWebServer/AsyncMultiWebServer.ino

Lines changed: 54 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,22 @@
11
/****************************************************************************************************************************
2-
AsyncMultiWebServer.h - Dead simple AsyncWebServer for Teensy41 QNEthernet
2+
AsyncMultiWebServer.h
33
4-
For Teensy41 with QNEthernet
5-
6-
AsyncWebServer_Teensy41 is a library for the Teensy41 with QNEthernet
4+
For ESP8266 using W5x00/ENC8266 Ethernet
5+
6+
AsyncWebServer_Ethernet is a library for the Ethernet with lwIP_5100, lwIP_5500 or lwIP_enc28j60 library
77
88
Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer)
9-
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_Teensy41
9+
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_Ethernet
1010
Licensed under GPLv3 license
1111
*****************************************************************************************************************************/
1212

13-
#if !( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) )
14-
#error Only Teensy 4.1 supported
15-
#endif
16-
17-
// Debug Level from 0 to 4
18-
#define _TEENSY41_ASYNC_TCP_LOGLEVEL_ 1
19-
#define _AWS_TEENSY41_LOGLEVEL_ 1
20-
21-
#define SHIELD_TYPE "Teensy4.1 QNEthernet"
22-
23-
#if (_AWS_TEENSY41_LOGLEVEL_ > 3)
24-
#warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error
25-
#endif
26-
27-
#define USING_DHCP true
28-
//#define USING_DHCP false
29-
30-
#if !USING_DHCP
31-
// Set the static IP address to use if the DHCP fails to assign
32-
IPAddress myIP(192, 168, 2, 222);
33-
IPAddress myNetmask(255, 255, 255, 0);
34-
IPAddress myGW(192, 168, 2, 1);
35-
//IPAddress mydnsServer(192, 168, 2, 1);
36-
IPAddress mydnsServer(8, 8, 8, 8);
37-
#endif
38-
39-
#include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet
40-
using namespace qindesign::network;
13+
#include "defines.h"
4114

42-
#include <AsyncWebServer_Teensy41.h>
15+
#include <AsyncWebServer_Ethernet.h>
4316

4417
unsigned int analogReadPin [] = { 12, 13, 14 };
4518

46-
#define BUFFER_SIZE 500
19+
#define BUFFER_SIZE 512
4720

4821
#define HTTP_PORT1 8080
4922
#define HTTP_PORT2 8081
@@ -82,7 +55,7 @@ body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Col
8255
</head>\
8356
<body>\
8457
<h1>Hello from %s</h1>\
85-
<h2>running AsyncWebServer_Teensy41</h2>\
58+
<h2>running AsyncWebServer_Ethernet</h2>\
8659
<h3>on %s</h3>\
8760
<h3>Uptime: %d d %02d:%02d:%02d</h3>\
8861
</body>\
@@ -128,56 +101,63 @@ void handleNotFound(AsyncWebServerRequest * request)
128101
request->send(404, F("text/plain"), message);
129102
}
130103

131-
void setup()
104+
void initEthernet()
132105
{
133-
Serial.begin(115200);
134-
while (!Serial && millis() < 5000);
106+
SPI.begin();
107+
SPI.setClockDivider(SPI_CLOCK_DIV4);
108+
SPI.setBitOrder(MSBFIRST);
109+
SPI.setDataMode(SPI_MODE0);
135110

136-
delay(200);
137-
138-
Serial.print("\nStart AsyncMultiWebServer on "); Serial.print(BOARD_NAME);
139-
Serial.print(" with "); Serial.println(SHIELD_TYPE);
140-
Serial.println(ASYNC_WEBSERVER_TEENSY41_VERSION);
141-
142-
delay(500);
143-
144-
#if USING_DHCP
145-
// Start the Ethernet connection, using DHCP
146-
Serial.print("Initialize Ethernet using DHCP => ");
147-
Ethernet.begin();
148-
#else
149-
// Start the Ethernet connection, using static IP
150-
Serial.print("Initialize Ethernet using static IP => ");
151-
Ethernet.begin(myIP, myNetmask, myGW);
152-
Ethernet.setDNSServerIP(mydnsServer);
111+
#if !USING_DHCP
112+
eth.config(localIP, gateway, netMask, gateway);
153113
#endif
154-
155-
if (!Ethernet.waitForLocalIP(5000))
114+
115+
eth.setDefault();
116+
117+
if (!eth.begin())
156118
{
157-
Serial.println(F("Failed to configure Ethernet"));
158-
159-
if (!Ethernet.linkStatus())
119+
Serial.println("No Ethernet hardware ... Stop here");
120+
121+
while (true)
160122
{
161-
Serial.println(F("Ethernet cable is not connected."));
123+
delay(1000);
162124
}
163-
164-
// Stay here forever
165-
while (true)
125+
}
126+
else
127+
{
128+
Serial.print("Connecting to network : ");
129+
130+
while (!eth.connected())
166131
{
167-
delay(1);
132+
Serial.print(".");
133+
delay(1000);
168134
}
169135
}
170-
else
171-
{
172-
Serial.print(F("Connected! IP address:")); Serial.println(Ethernet.localIP());
173-
}
136+
137+
Serial.println();
174138

175-
#if USING_DHCP
176-
delay(1000);
177-
#else
178-
delay(2000);
139+
#if USING_DHCP
140+
Serial.print("Ethernet DHCP IP address: ");
141+
#else
142+
Serial.print("Ethernet Static IP address: ");
179143
#endif
144+
145+
Serial.println(eth.localIP());
146+
}
180147

148+
void setup()
149+
{
150+
Serial.begin(115200);
151+
while (!Serial && millis() < 5000);
152+
153+
delay(200);
154+
155+
Serial.print("\nStart AsyncMultiWebServer on "); Serial.print(BOARD_NAME);
156+
Serial.print(" with "); Serial.println(SHIELD_TYPE);
157+
Serial.println(ASYNC_WEBSERVER_ETHERNET_VERSION);
158+
159+
initEthernet();
160+
181161
for (serverIndex = 0; serverIndex < NUM_SERVERS; serverIndex++)
182162
{
183163
multiServer[serverIndex] = new AsyncWebServer(http_port[serverIndex]);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/****************************************************************************************************************************
2+
defines.h
3+
4+
For ESP8266 using W5x00/ENC8266 Ethernet
5+
6+
AsyncWebServer_Ethernet is a library for the Ethernet with lwIP_5100, lwIP_5500 or lwIP_enc28j60 library
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_Ethernet
10+
Licensed under GPLv3 license
11+
***************************************************************************************************************************************/
12+
13+
#ifndef defines_h
14+
#define defines_h
15+
16+
#if defined(ESP8266)
17+
#define LED_ON LOW
18+
#define LED_OFF HIGH
19+
#else
20+
#error Only ESP8266
21+
#endif
22+
23+
#define _AWS_ETHERNET_LOGLEVEL_ 1
24+
25+
//////////////////////////////////////////////////////////
26+
27+
#define USING_W5500 true
28+
#define USING_W5100 false
29+
#define USING_ENC28J60 false
30+
31+
#include <SPI.h>
32+
33+
#define CSPIN 16 // 5
34+
35+
#if USING_W5500
36+
#include "W5500lwIP.h"
37+
#define SHIELD_TYPE "ESP8266_W5500 Ethernet"
38+
39+
Wiznet5500lwIP eth(CSPIN);
40+
41+
#elif USING_W5100
42+
#include <W5100lwIP.h>
43+
#define SHIELD_TYPE "ESP8266_W5100 Ethernet"
44+
45+
Wiznet5100lwIP eth(CSPIN);
46+
47+
#elif USING_ENC28J60
48+
#include <ENC28J60lwIP.h>
49+
#define SHIELD_TYPE "ESP8266_ENC28J60 Ethernet"
50+
51+
ENC28J60lwIP eth(CSPIN);
52+
#else
53+
// default if none selected
54+
#include "W5500lwIP.h"
55+
56+
Wiznet5500lwIP eth(CSPIN);
57+
#endif
58+
59+
#include <WiFiClient.h> // WiFiClient (-> TCPClient)
60+
61+
using TCPClient = WiFiClient;
62+
63+
//////////////////////////////////////////////////////////
64+
65+
#define USING_DHCP true
66+
67+
#if !USING_DHCP
68+
IPAddress localIP(192, 168, 2, 222);
69+
IPAddress gateway(192, 168, 2, 1);
70+
IPAddress netMask(255, 255, 255, 0);
71+
#endif
72+
73+
#endif //defines_h

0 commit comments

Comments
 (0)