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

Commit

Permalink
v1.6.0 to save heap when sending large data
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
khoih-prog authored Oct 6, 2022
1 parent a8bb3c3 commit 2f284d9
Show file tree
Hide file tree
Showing 44 changed files with 2,746 additions and 1,478 deletions.
21 changes: 11 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
## Contributing to AsyncWebServer_Ethernet
## Contributing to AsyncWebServer_Teensy41

### Reporting Bugs

Please report bugs in AsyncWebServer_Ethernet if you find them.
Please report bugs in AsyncWebServer_Teensy41 if you find them.

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

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

If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_Ethernet/issues/new).
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_Teensy41/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. ESP8266 core v3.0.2)
* `Teensyduino` Core Version (e.g. `Teensyduino core v1.57`)
* `QNEthernet` library version (e.g. `QNEthernet v0.15.0`)
* Board type and relevant info
* 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:
Expand All @@ -27,26 +29,25 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.19
ESP8266_NODEMCU_ESP12E using ESP8266_W5500 Ethernet
ESP8266 core v3.0.2
Teensyduino core v1.57
Teensy 4.1 using QNEthernet v0.15.0
OS: Ubuntu 20.04 LTS
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
Context:
I encountered a crash while using this library
I encountered an endless loop while using this library
Steps to reproduce:
1. ...
2. ...
3. ...
4. ...
```

### 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_Ethernet/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
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.

### Sending Pull Requests

Expand Down
27 changes: 17 additions & 10 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# AsyncWebServer_Ethernet
# AsyncWebServer_Teensy41

[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_Ethernet.svg?)](https://www.ardu-badge.com/AsyncWebServer_Ethernet)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_Ethernet.svg)](https://github.com/khoih-prog/AsyncWebServer_Ethernet/releases)
[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_Teensy41.svg?)](https://www.ardu-badge.com/AsyncWebServer_Teensy41)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_Teensy41.svg)](https://github.com/khoih-prog/AsyncWebServer_Teensy41/releases)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/AsyncWebServer_Teensy41/blob/master/LICENSE)
[![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_Ethernet.svg)](http://github.com/khoih-prog/AsyncWebServer_Ethernet/issues)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/AsyncWebServer_Teensy41.svg)](http://github.com/khoih-prog/AsyncWebServer_Teensy41/issues)

---
---

## Table of contents

* [Table of contents](#table-of-contents)
* [Changelog](#changelog)
* [Releases v1.6.0](#releases-v160)
* [Releases v1.5.0](#releases-v150)
* [Releases v1.4.1](#releases-v141)

Expand All @@ -19,16 +22,20 @@

## Changelog

#### Releases v1.5.0
### 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](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)
2. Add multiple examples to demo the new feature

#### Releases v1.4.1
### Releases v1.5.0

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)
2. Add functions and example `Async_AdvancedWebServer_favicon` to support `favicon.ico`

### Releases v1.4.1

1. Initial porting and coding for **Teensy 4.1 using built-in QNEthernet**
2. Bump up version to v1.4.1 to sync with [AsyncWebServer_STM32](https://github.com/khoih-prog/AsyncWebServer_STM32) v1.4.1

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


128 changes: 74 additions & 54 deletions examples/AsyncMultiWebServer/AsyncMultiWebServer.ino
Original file line number Diff line number Diff line change
@@ -1,22 +1,49 @@
/****************************************************************************************************************************
AsyncMultiWebServer.h
AsyncMultiWebServer.h - Dead simple AsyncWebServer for Teensy41 QNEthernet
For ESP8266 using W5x00/ENC8266 Ethernet
AsyncWebServer_Ethernet is a library for the Ethernet with lwIP_5100, lwIP_5500 or lwIP_enc28j60 library
For Teensy41 with QNEthernet
AsyncWebServer_Teensy41 is a library for the Teensy41 with QNEthernet
Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_Ethernet
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_Teensy41
Licensed under GPLv3 license
*****************************************************************************************************************************/

#include "defines.h"
#if !( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) )
#error Only Teensy 4.1 supported
#endif

// Debug Level from 0 to 4
#define _TEENSY41_ASYNC_TCP_LOGLEVEL_ 1
#define _AWS_TEENSY41_LOGLEVEL_ 1

#define SHIELD_TYPE "Teensy4.1 QNEthernet"

#if (_AWS_TEENSY41_LOGLEVEL_ > 3)
#warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error
#endif

#define USING_DHCP true
//#define USING_DHCP false

#if !USING_DHCP
// Set the static IP address to use if the DHCP fails to assign
IPAddress myIP(192, 168, 2, 222);
IPAddress myNetmask(255, 255, 255, 0);
IPAddress myGW(192, 168, 2, 1);
//IPAddress mydnsServer(192, 168, 2, 1);
IPAddress mydnsServer(8, 8, 8, 8);
#endif

#include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet
using namespace qindesign::network;

#include <AsyncWebServer_Ethernet.h>
#include <AsyncWebServer_Teensy41.h>

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

#define BUFFER_SIZE 512
#define BUFFER_SIZE 500

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

void initEthernet()
void setup()
{
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV4);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
Serial.begin(115200);
while (!Serial && millis() < 5000);

#if !USING_DHCP
eth.config(localIP, gateway, netMask, gateway);
delay(200);

Serial.print("\nStart AsyncMultiWebServer on "); Serial.print(BOARD_NAME);
Serial.print(" with "); Serial.println(SHIELD_TYPE);
Serial.println(ASYNC_WEBSERVER_TEENSY41_VERSION);

delay(500);

#if USING_DHCP
// Start the Ethernet connection, using DHCP
Serial.print("Initialize Ethernet using DHCP => ");
Ethernet.begin();
#else
// Start the Ethernet connection, using static IP
Serial.print("Initialize Ethernet using static IP => ");
Ethernet.begin(myIP, myNetmask, myGW);
Ethernet.setDNSServerIP(mydnsServer);
#endif

eth.setDefault();

if (!eth.begin())

if (!Ethernet.waitForLocalIP(5000))
{
Serial.println("No Ethernet hardware ... Stop here");
while (true)
Serial.println(F("Failed to configure Ethernet"));

if (!Ethernet.linkStatus())
{
delay(1000);
Serial.println(F("Ethernet cable is not connected."));
}
}
else
{
Serial.print("Connecting to network : ");

while (!eth.connected())

// Stay here forever
while (true)
{
Serial.print(".");
delay(1000);
delay(1);
}
}

Serial.println();
else
{
Serial.print(F("Connected! IP address:")); Serial.println(Ethernet.localIP());
}

#if USING_DHCP
Serial.print("Ethernet DHCP IP address: ");
#else
Serial.print("Ethernet Static IP address: ");
#if USING_DHCP
delay(1000);
#else
delay(2000);
#endif

Serial.println(eth.localIP());
}

void setup()
{
Serial.begin(115200);
while (!Serial && millis() < 5000);

delay(200);

Serial.print("\nStart AsyncMultiWebServer on "); Serial.print(BOARD_NAME);
Serial.print(" with "); Serial.println(SHIELD_TYPE);
Serial.println(ASYNC_WEBSERVER_ETHERNET_VERSION);

initEthernet();

for (serverIndex = 0; serverIndex < NUM_SERVERS; serverIndex++)
{
multiServer[serverIndex] = new AsyncWebServer(http_port[serverIndex]);
Expand Down
Loading

0 comments on commit 2f284d9

Please sign in to comment.