From e11b91ed539146ded506b2e9453d10a0e54b1bcb Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Sun, 27 Nov 2022 23:45:47 -0500 Subject: [PATCH] v1.6.2 for `ESP32 + ENC28J60` #### Releases v1.6.2 1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32 boards using ENC28J60 Ethernet. 2. Bump up to `v1.6.2` to sync with [AsyncWebServer_ESP32_ENC v1.6.2](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC). 3. Use `allman astyle` --- CONTRIBUTING.md | 76 + LICENSE | 8 +- README.md | 1840 ++++++++++++++++ changelog.md | 33 + .../AsyncMultiWebServer_ESP32_ENC.ino | 250 +++ .../AsyncSimpleServer_ESP32_ENC.ino | 171 ++ .../AsyncWebServer_SendChunked.ino | 266 +++ .../Async_AdvancedWebServer.ino | 252 +++ ...bServer_MemoryIssues_SendArduinoString.ino | 334 +++ ...cedWebServer_MemoryIssues_Send_CString.ino | 344 +++ .../Async_AdvancedWebServer_SendChunked.ino | 301 +++ .../Async_HelloServer/Async_HelloServer.ino | 167 ++ .../Async_HelloServer2/Async_HelloServer2.ino | 190 ++ .../Async_PostServer/Async_PostServer.ino | 242 +++ .../Async_RegexPatterns_ESP32_ENC.ino | 174 ++ keywords.txt | 530 +++++ library.json | 38 + library.properties | 12 + pics/AsyncMultiWebServer_ESP32_ENC_SVR1.png | Bin 0 -> 31808 bytes pics/AsyncMultiWebServer_ESP32_ENC_SVR2.png | Bin 0 -> 32129 bytes pics/AsyncMultiWebServer_ESP32_ENC_SVR3.png | Bin 0 -> 31986 bytes pics/AsyncWebServer_SendChunked.png | Bin 0 -> 63916 bytes pics/Async_AdvancedWebServer.png | Bin 0 -> 20711 bytes ...cedWebServer_MemoryIssues_Send_CString.png | Bin 0 -> 56382 bytes platformio/platformio.ini | 88 + src/AsyncEventSource.cpp | 564 +++++ src/AsyncEventSource.h | 206 ++ src/AsyncJson.h | 445 ++++ src/AsyncWebServer_ESP32_ENC.cpp | 165 ++ src/AsyncWebServer_ESP32_ENC.h | 921 ++++++++ src/AsyncWebServer_ESP32_ENC_Debug.h | 113 + src/AsyncWebSocket.cpp | 1928 +++++++++++++++++ src/AsyncWebSocket.h | 609 ++++++ src/AsyncWebSynchronization.h | 122 ++ src/Crypto/Hash.cpp | 109 + src/Crypto/Hash.h | 46 + src/Crypto/bearssl_hash.h | 1357 ++++++++++++ src/Crypto/md5.h | 95 + src/Crypto/sha1.c | 330 +++ src/Crypto/sha1.h | 101 + src/ESP32_ENC_SPIFFSEditor.cpp | 687 ++++++ src/ESP32_ENC_SPIFFSEditor.h | 63 + src/StringArray.h | 351 +++ src/WebAuthentication.cpp | 358 +++ src/WebAuthentication.h | 53 + src/WebHandlerImpl.h | 243 +++ src/WebHandlers.cpp | 292 +++ src/WebRequest.cpp | 1751 +++++++++++++++ src/WebResponseImpl.h | 276 +++ src/WebResponses.cpp | 1298 +++++++++++ src/WebServer.cpp | 313 +++ src/edit.htm | 627 ++++++ src/enc28j60/esp32_enc28j60.cpp | 427 ++++ src/enc28j60/esp32_enc28j60.h | 118 + src/enc28j60/extmod/enc28j60.h | 238 ++ src/enc28j60/extmod/esp_eth_enc28j60.h | 150 ++ src/enc28j60/extmod/esp_eth_mac_enc28j60.c | 1375 ++++++++++++ src/enc28j60/extmod/esp_eth_phy_enc28j60.c | 390 ++++ src/enc28j60/extmod/esp_eth_spi_enc28j60.c | 69 + src/libb64/cdecode.c | 150 ++ src/libb64/cdecode.h | 62 + src/libb64/cencode.c | 154 ++ src/libb64/cencode.h | 65 + utils/astyle_library.conf | 70 + utils/restyle.sh | 6 + 65 files changed, 22009 insertions(+), 4 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 README.md create mode 100644 changelog.md create mode 100644 examples/AsyncMultiWebServer_ESP32_ENC/AsyncMultiWebServer_ESP32_ENC.ino create mode 100644 examples/AsyncSimpleServer_ESP32_ENC/AsyncSimpleServer_ESP32_ENC.ino create mode 100644 examples/AsyncWebServer_SendChunked/AsyncWebServer_SendChunked.ino create mode 100644 examples/Async_AdvancedWebServer/Async_AdvancedWebServer.ino create mode 100644 examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString/Async_AdvancedWebServer_MemoryIssues_SendArduinoString.ino create mode 100644 examples/Async_AdvancedWebServer_MemoryIssues_Send_CString/Async_AdvancedWebServer_MemoryIssues_Send_CString.ino create mode 100644 examples/Async_AdvancedWebServer_SendChunked/Async_AdvancedWebServer_SendChunked.ino create mode 100644 examples/Async_HelloServer/Async_HelloServer.ino create mode 100644 examples/Async_HelloServer2/Async_HelloServer2.ino create mode 100644 examples/Async_PostServer/Async_PostServer.ino create mode 100644 examples/Async_RegexPatterns_ESP32_ENC/Async_RegexPatterns_ESP32_ENC.ino create mode 100644 keywords.txt create mode 100644 library.json create mode 100644 library.properties create mode 100644 pics/AsyncMultiWebServer_ESP32_ENC_SVR1.png create mode 100644 pics/AsyncMultiWebServer_ESP32_ENC_SVR2.png create mode 100644 pics/AsyncMultiWebServer_ESP32_ENC_SVR3.png create mode 100644 pics/AsyncWebServer_SendChunked.png create mode 100644 pics/Async_AdvancedWebServer.png create mode 100644 pics/Async_AdvancedWebServer_MemoryIssues_Send_CString.png create mode 100644 platformio/platformio.ini create mode 100644 src/AsyncEventSource.cpp create mode 100644 src/AsyncEventSource.h create mode 100644 src/AsyncJson.h create mode 100644 src/AsyncWebServer_ESP32_ENC.cpp create mode 100644 src/AsyncWebServer_ESP32_ENC.h create mode 100644 src/AsyncWebServer_ESP32_ENC_Debug.h create mode 100644 src/AsyncWebSocket.cpp create mode 100644 src/AsyncWebSocket.h create mode 100644 src/AsyncWebSynchronization.h create mode 100644 src/Crypto/Hash.cpp create mode 100644 src/Crypto/Hash.h create mode 100644 src/Crypto/bearssl_hash.h create mode 100644 src/Crypto/md5.h create mode 100644 src/Crypto/sha1.c create mode 100644 src/Crypto/sha1.h create mode 100644 src/ESP32_ENC_SPIFFSEditor.cpp create mode 100644 src/ESP32_ENC_SPIFFSEditor.h create mode 100644 src/StringArray.h create mode 100644 src/WebAuthentication.cpp create mode 100644 src/WebAuthentication.h create mode 100644 src/WebHandlerImpl.h create mode 100644 src/WebHandlers.cpp create mode 100644 src/WebRequest.cpp create mode 100644 src/WebResponseImpl.h create mode 100644 src/WebResponses.cpp create mode 100644 src/WebServer.cpp create mode 100644 src/edit.htm create mode 100644 src/enc28j60/esp32_enc28j60.cpp create mode 100644 src/enc28j60/esp32_enc28j60.h create mode 100644 src/enc28j60/extmod/enc28j60.h create mode 100644 src/enc28j60/extmod/esp_eth_enc28j60.h create mode 100644 src/enc28j60/extmod/esp_eth_mac_enc28j60.c create mode 100644 src/enc28j60/extmod/esp_eth_phy_enc28j60.c create mode 100644 src/enc28j60/extmod/esp_eth_spi_enc28j60.c create mode 100644 src/libb64/cdecode.c create mode 100644 src/libb64/cdecode.h create mode 100644 src/libb64/cencode.c create mode 100644 src/libb64/cencode.h create mode 100644 utils/astyle_library.conf create mode 100644 utils/restyle.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f7f80a2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,76 @@ +## Contributing to AsyncWebServer_ESP32_ENC + +### Reporting Bugs + +Please report bugs in AsyncWebServer_ESP32_ENC if you find them. + +However, before reporting a bug please check through the following: + +* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/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_ENC/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.5) +* 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 + + +### Example + +``` +Arduino IDE version: 1.8.19 +ESP32_DEV board +ESP32 core v2.0.5 +OS: Ubuntu 20.04 LTS +Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 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_ENC/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_ENC_GitHub/ +xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_ENC_GitHub$ +``` + +2. Issue astyle command + +``` +xy@xy-Inspiron-3593:~/Arduino/xy/AsyncWebServer_ESP32_ENC_GitHub$ bash utils/restyle.sh +``` + diff --git a/LICENSE b/LICENSE index f288702..94a9ed0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..de52d85 --- /dev/null +++ b/README.md @@ -0,0 +1,1840 @@ +# AsyncWebServer_ESP32_ENC + +[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_ENC.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_ENC) +[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_ESP32_ENC.svg)](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/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_ENC.svg)](http://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/issues) + + +Donate to my libraries using BuyMeACoffee + + + + +--- +--- + +## Table of contents + +* [Table of contents](#table-of-contents) +* [Important Note from v1.6.2](#Important-Note-from-v162) +* [Why do we need this AsyncWebServer_ESP32_ENC library](#why-do-we-need-this-asyncwebserver_ESP32_ENC-library) + * [Features](#features) + * [Why Async is better](#why-async-is-better) + * [Currently supported Boards](#currently-supported-boards) +* [Changelog](changelog.md) +* [Prerequisites](#prerequisites) +* [Installation](#installation) + * [Use Arduino Library Manager](#use-arduino-library-manager) + * [Manual Install](#manual-install) + * [VS Code & PlatformIO](#vs-code--platformio) +* [Important things to remember](#important-things-to-remember) +* [Principles of operation](#principles-of-operation) + * [The Async Web server](#the-async-web-server) + * [Request Life Cycle](#request-life-cycle) + * [Rewrites and how do they work](#rewrites-and-how-do-they-work) + * [Handlers and how do they work](#handlers-and-how-do-they-work) + * [Responses and how do they work](#responses-and-how-do-they-work) + * [Template processing](#template-processing) +* [Request Variables](#request-variables) + * [Common Variables](#common-variables) + * [Headers](#headers) + * [GET, POST and FILE parameters](#get-post-and-file-parameters) + * [JSON body handling with ArduinoJson](#json-body-handling-with-arduinojson) +* [Responses](#responses) + * [Redirect to another URL](#redirect-to-another-url) + * [Basic response with HTTP Code](#basic-response-with-http-code) + * [Basic response with HTTP Code and extra headers](#basic-response-with-http-code-and-extra-headers) + * [Basic response with string content](#basic-response-with-string-content) + * [Basic response with string content and extra headers](#basic-response-with-string-content-and-extra-headers) + * [Respond with content coming from a Stream](#respond-with-content-coming-from-a-stream) + * [Respond with content coming from a Stream and extra headers](#respond-with-content-coming-from-a-stream-and-extra-headers) + * [Respond with content coming from a Stream containing templates](#respond-with-content-coming-from-a-stream-containing-templates) + * [Respond with content coming from a Stream containing templates and extra headers](#respond-with-content-coming-from-a-stream-containing-templates-and-extra-headers) + * [Respond with content using a callback](#respond-with-content-using-a-callback) + * [Respond with content using a callback and extra headers](#respond-with-content-using-a-callback-and-extra-headers) + * [Respond with content using a callback containing templates](#respond-with-content-using-a-callback-containing-templates) + * [Respond with content using a callback containing templates and extra headers](#respond-with-content-using-a-callback-containing-templates-and-extra-headers) + * [Chunked Response](#chunked-response) + * [Chunked Response containing templates](#chunked-response-containing-templates) + * [Print to response](#print-to-response) + * [ArduinoJson Basic Response](#arduinojson-basic-response) + * [ArduinoJson Advanced Response](#arduinojson-advanced-response) +* [Param Rewrite With Matching](#param-rewrite-with-matching) +* [Using filters](#using-filters) +* [Bad Responses](#bad-responses) + * [Respond with content using a callback without content length to HTTP/1.0 clients](#respond-with-content-using-a-callback-without-content-length-to-http10-clients) +* [Async WebSocket Plugin](#async-websocket-plugin) + * [Async WebSocket Event](#async-websocket-event) + * [Methods for sending data to a socket client](#methods-for-sending-data-to-a-socket-client) + * [Direct access to web socket message buffer](#direct-access-to-web-socket-message-buffer) + * [Limiting the number of web socket clients](#limiting-the-number-of-web-socket-clients) +* [Async Event Source Plugin](#async-event-source-plugin) + * [Setup Event Source on the server](#setup-event-source-on-the-server) + * [Setup Event Source in the browser](#setup-event-source-in-the-browser) +* [Remove handlers and rewrites](#remove-handlers-and-rewrites) +* [Setting up the server](#setting-up-the-server) + * [Setup global and class functions as request handlers](#setup-global-and-class-functions-as-request-handlers) + * [Methods for controlling websocket connections](#methods-for-controlling-websocket-connections) + * [Adding Default Headers](#adding-default-headers) + * [Path variable](#path-variable) +* [Examples](#examples) + * [ 1. Async_AdvancedWebServer](examples/Async_AdvancedWebServer) + * [ 2. Async_HelloServer](examples/Async_HelloServer) + * [ 3. Async_HelloServer2](examples/Async_HelloServer2) + * [ 4. AsyncMultiWebServer_ESP32_ENC](examples/AsyncMultiWebServer_ESP32_ENC) + * [ 5. Async_PostServer](examples/Async_PostServer) + * [ 6. Async_RegexPatterns_ESP32_ENC](examples/Async_RegexPatterns_ESP32_ENC) + * [ 7. AsyncSimpleServer_ESP32_ENC](examples/AsyncSimpleServer_ESP32_ENC) + * [ 8. Async_AdvancedWebServer_MemoryIssues_SendArduinoString](examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString) + * [ 9. Async_AdvancedWebServer_MemoryIssues_Send_CString](examples/Async_AdvancedWebServer_MemoryIssues_Send_CString) + * [10. Async_AdvancedWebServer_SendChunked](examples/Async_AdvancedWebServer_SendChunked) + * [11. AsyncWebServer_SendChunked](examples/AsyncWebServer_SendChunked) +* [Example Async_AdvancedWebServer](#Example-Async_AdvancedWebServer) +* [Debug Terminal Output Samples](#debug-terminal-output-samples) + * [1. AsyncMultiWebServer_ESP32_ENC on ESP32_DEV with ESP32_ENC28J60](#1-AsyncMultiWebServer_ESP32_ENC-on-ESP32_DEV-with-ESP32_ENC28J60) + * [2. Async_AdvancedWebServer_MemoryIssues_Send_CString on ESP32_DEV with ESP32_ENC28J60](#2-Async_AdvancedWebServer_MemoryIssues_Send_CString-on-ESP32_DEV-with-ESP32_ENC28J60) + * [3. Async_AdvancedWebServer_SendChunked on ESP32_DEV with ESP32_ENC28J60](#3-Async_AdvancedWebServer_SendChunked-on-ESP32_DEV-with-ESP32_ENC28J60) + * [4. AsyncWebServer_SendChunked on ESP32_DEV with ESP32_ENC28J60](#4-AsyncWebServer_SendChunked-on-ESP32_DEV-with-ESP32_ENC28J60) +* [Debug](#debug) +* [Troubleshooting](#troubleshooting) +* [Issues](#issues) +* [TO DO](#to-do) +* [DONE](#done) +* [Contributions and Thanks](#contributions-and-thanks) +* [Contributing](#contributing) +* [License](#license) +* [Copyright](#copyright) + +--- +--- + +### Important Note from v1.6.2 + +The new `v1.6.2+` has added a new and powerful feature to permit using `CString` to save heap to send `very large data`. + +Check the `marvelleous` PRs of **@salasidis** in [Portenta_H7_AsyncWebServer library](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer) +- [request->send(200, textPlainStr, jsonChartDataCharStr); - Without using String Class - to save heap #8](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/pull/8) +- [All memmove() removed - string no longer destroyed #11](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/pull/11) + +and these new examples + +1. [Async_AdvancedWebServer_MemoryIssues_Send_CString](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/tree/main/examples/Async_AdvancedWebServer_MemoryIssues_Send_CString) +2. [Async_AdvancedWebServer_MemoryIssues_SendArduinoString](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/tree/main/examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString) + +If using Arduino String, to send a buffer around 30 KBytes, the used `Max Heap` is around **152,136 bytes** + +If using CString in regular memory, with the same 30 KBytes, the used `Max Heap` is around **120,880 bytes, saving around a buffer size (30 KBytes)** + +This is very critical in use-cases where sending `very large data` is necessary, without `heap-allocation-error`. + + +1. The traditional function used to send `Arduino String` is + +https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/blob/6c499f1d3e91b1e33f86f3d9c6a36fa60470a38f/src/AsyncWebServer_ESP32_ENC.h#L518 + +```cpp +void send(int code, const String& contentType = String(), const String& content = String()); +``` + +such as + +```cpp +request->send(200, textPlainStr, ArduinoStr); +``` +The required additional HEAP is about **3 times of the String size** + + +2. To use `CString` with copying while sending. Use function + +https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/blob/6c499f1d3e91b1e33f86f3d9c6a36fa60470a38f/src/AsyncWebServer_ESP32_ENC.h#L520 + +```cpp +void send(int code, const String& contentType, const char *content, bool nonDetructiveSend = true); // RSMOD +``` + +such as + +```cpp +request->send(200, textPlainStr, cStr); +``` + +The required additional HEAP is also about **2 times of the CString size** because of `unnecessary copies` of the CString in HEAP. Avoid this `unefficient` way. + + +3. To use `CString` without copying while sending. Use function + +https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/blob/6c499f1d3e91b1e33f86f3d9c6a36fa60470a38f/src/AsyncWebServer_ESP32_ENC.h#L520 + +```cpp +void send(int code, const String& contentType, const char *content, bool nonDetructiveSend = true); // RSMOD +``` + +such as + +```cpp +request->send(200, textPlainStr, cStr, false); +``` + +The required additional HEAP is about **1 times of the CString size**. This way is the best and **most efficient way** to use by avoiding of `unnecessary copies` of the CString in HEAP + + +--- +--- + +### Why do we need this [AsyncWebServer_ESP32_ENC library](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC) + + +#### Features + +This library is based on, modified from: + +1. [Hristo Gochkov's ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) + +to apply the better and faster **asynchronous** feature of the **powerful** [ESPAsyncWebServer Library](https://github.com/me-no-dev/ESPAsyncWebServer) into **(ESP32 + ENC28J60)**. + + +#### Why Async is better + +- Using asynchronous network means that you can handle **more than one connection at the same time** +- **You are called once the request is ready and parsed** +- When you send the response, you are **immediately ready** to handle other connections while the server is taking care of sending the response in the background +- **Speed is OMG** +- **Easy to use API, HTTP Basic and Digest MD5 Authentication (default), ChunkedResponse** +- Easily extensible to handle **any type of content** +- Supports Continue 100 +- **Async WebSocket plugin offering different locations without extra servers or ports** +- Async EventSource (Server-Sent Events) plugin to send events to the browser +- URL Rewrite plugin for conditional and permanent url rewrites +- ServeStatic plugin that supports cache, Last-Modified, default index and more +- Simple template processing engine to handle templates + + +--- + +#### Currently supported Boards + +1. **(ESP32 + ENC28J60 Ethernet) boards** + +--- +--- + + +## Prerequisites + + 1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest) + 2. [`ESP32 Core 2.0.5+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. ESP32 Latest Core [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) + 3. [`AsyncTCP library v1.1.1+`](https://github.com/me-no-dev/AsyncTCP). + +--- + +## Installation + +### Use Arduino Library Manager + +The best and easiest way is to use `Arduino Library Manager`. Search for `AsyncWebServer_ESP32_ENC`, then select / install the latest version. You can also use this link [![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_ENC.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_ENC) for more detailed instructions. + +### Manual Install + +1. Navigate to [AsyncWebServer_ESP32_ENC](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC) page. +2. Download the latest release `AsyncWebServer_ESP32_ENC-main.zip`. +3. Extract the zip file to `AsyncWebServer_ESP32_ENC-main` directory +4. Copy the whole `AsyncWebServer_ESP32_ENC-main` folder to Arduino libraries' directory such as `~/Arduino/libraries/`. + +### VS Code & PlatformIO: + +1. Install [VS Code](https://code.visualstudio.com/) +2. Install [PlatformIO](https://platformio.org/platformio-ide) +3. Install [**AsyncWebServer_ESP32_ENC** library](https://registry.platformio.org/libraries/khoih-prog/AsyncWebServer_ESP32_ENC) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/AsyncWebServer_ESP32_ENC/installation). Search for **AsyncWebServer_ESP32_ENC** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22) +4. Use included [platformio.ini](platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html) + + +--- +--- + +## Important things to remember + +- This is **fully asynchronous server** and as such does not run on the `loop()` thread. +- You can not use `yield()` or `delay()` or any function that uses them inside the callbacks +- The server is smart enough to know when to close the connection and free resources +- You can not send more than one response to a single request + +--- + +## Principles of operation + +### The Async Web server + +- Listens for connections +- Wraps the new clients into `Request` +- Keeps track of clients and cleans memory +- Manages `Rewrites` and apply them on the request url +- Manages `Handlers` and attaches them to Requests + +### Request Life Cycle + +- TCP connection is received by the server +- The connection is wrapped inside `Request` object +- When the request head is received (type, url, get params, http version and host), + the server goes through all `Rewrites` (in the order they were added) to rewrite the url and inject query parameters, + next, it goes through all attached `Handlers` (in the order they were added) trying to find one + that `canHandle` the given request. If none are found, the default(catch-all) handler is attached. +- The rest of the request is received, calling the `handleUpload` or `handleBody` methods of the `Handler` if they are needed (POST+File/Body) +- When the whole request is parsed, the result is given to the `handleRequest` method of the `Handler` and is ready to be responded to +- In the `handleRequest` method, to the `Request` is attached a `Response` object (see below) that will serve the response data back to the client +- When the `Response` is sent, the client is closed and freed from the memory + +### Rewrites and how do they work + +- The `Rewrites` are used to rewrite the request url and/or inject get parameters for a specific request url path. +- All `Rewrites` are evaluated on the request in the order they have been added to the server. +- The `Rewrite` will change the request url only if the request url (excluding get parameters) is fully match + the rewrite url, and when the optional `Filter` callback return true. +- Setting a `Filter` to the `Rewrite` enables to control when to apply the rewrite, decision can be based on + request url, http version, request host/port/target host, get parameters or the request client's localIP or remoteIP. +- The `Rewrite` can specify a target url with optional get parameters, e.g. `/to-url?with=params` + +### Handlers and how do they work + +- The `Handlers` are used for executing specific actions to particular requests +- One `Handler` instance can be attached to any request and lives together with the server +- Setting a `Filter` to the `Handler` enables to control when to apply the handler, decision can be based on + request url, http version, request host/port/target host, get parameters or the request client's localIP or remoteIP. +- The `canHandle` method is used for handler specific control on whether the requests can be handled + and for declaring any interesting headers that the `Request` should parse. Decision can be based on request + method, request url, http version, request host/port/target host and get parameters +- Once a `Handler` is attached to given `Request` (`canHandle` returned true) + that `Handler` takes care to receive any file/data upload and attach a `Response` + once the `Request` has been fully parsed +- `Handlers` are evaluated in the order they are attached to the server. The `canHandle` is called only + if the `Filter` that was set to the `Handler` return true. +- The first `Handler` that can handle the request is selected, not further `Filter` and `canHandle` are called. + +### Responses and how do they work + +- The `Response` objects are used to send the response data back to the client +- The `Response` object lives with the `Request` and is freed on end or disconnect +- Different techniques are used depending on the response type to send the data in packets + returning back almost immediately and sending the next packet when this one is received. + Any time in between is spent to run the user loop and handle other network packets +- Responding asynchronously is probably the most difficult thing for most to understand +- Many different options exist for the user to make responding a background task + +### Template processing + +- `AsyncWebServer_ESP32_ENC` contains simple template processing engine. +- Template processing can be added to most response types. +- Currently it supports only replacing template placeholders with actual values. No conditional processing, cycles, etc. +- Placeholders are delimited with `%` symbols. Like this: `%TEMPLATE_PLACEHOLDER%`. +- It works by extracting placeholder name from response text and passing it to user provided function which should return actual value to be used instead of placeholder. +- Since it's user provided function, it is possible for library users to implement conditional processing and cycles themselves. +- Since it's impossible to know the actual response size after template processing step in advance (and, therefore, to include it in response headers), the response becomes [chunked](#chunked-response). + +--- + +## Request Variables + +### Common Variables + +```cpp +request->version(); // uint8_t: 0 = HTTP/1.0, 1 = HTTP/1.1 +request->method(); // enum: HTTP_GET, HTTP_POST, HTTP_DELETE, HTTP_PUT, HTTP_PATCH, HTTP_HEAD, HTTP_OPTIONS +request->url(); // String: URL of the request (not including host, port or GET parameters) +request->host(); // String: The requested host (can be used for virtual hosting) +request->contentType(); // String: ContentType of the request (not avaiable in Handler::canHandle) +request->contentLength(); // size_t: ContentLength of the request (not avaiable in Handler::canHandle) +request->multipart(); // bool: True if the request has content type "multipart" +``` + +### Headers + +```cpp +//List all collected headers +int headers = request->headers(); +int i; + +for (i=0;igetHeader(i); + Serial.printf("HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str()); +} + +//get specific header by name +if (request->hasHeader("MyHeader")) +{ + AsyncWebHeader* h = request->getHeader("MyHeader"); + Serial.printf("MyHeader: %s\n", h->value().c_str()); +} + +//List all collected headers (Compatibility) +int headers = request->headers(); +int i; + +for (i=0;iheaderName(i).c_str(), request->header(i).c_str()); +} + +//get specific header by name (Compatibility) +if (request->hasHeader("MyHeader")) +{ + Serial.printf("MyHeader: %s\n", request->header("MyHeader").c_str()); +} +``` + +### GET, POST and FILE parameters + +```cpp +//List all parameters +int params = request->params(); + +for (int i=0;igetParam(i); + + if (p->isFile()) + { + //p->isPost() is also true + Serial.printf("FILE[%s]: %s, size: %u\n", p->name().c_str(), p->value().c_str(), p->size()); + } + else if (p->isPost()) + { + Serial.printf("POST[%s]: %s\n", p->name().c_str(), p->value().c_str()); + } + else + { + Serial.printf("GET[%s]: %s\n", p->name().c_str(), p->value().c_str()); + } +} + +//Check if GET parameter exists +if (request->hasParam("download")) + AsyncWebParameter* p = request->getParam("download"); + +//Check if POST (but not File) parameter exists +if (request->hasParam("download", true)) + AsyncWebParameter* p = request->getParam("download", true); + +//Check if FILE was uploaded +if (request->hasParam("download", true, true)) + AsyncWebParameter* p = request->getParam("download", true, true); + +//List all parameters (Compatibility) +int args = request->args(); + +for (int i=0;iargName(i).c_str(), request->arg(i).c_str()); +} + +//Check if parameter exists (Compatibility) +if (request->hasArg("download")) + String arg = request->arg("download"); +``` + +### JSON body handling with ArduinoJson + +Endpoints which consume JSON can use a special handler to get ready to use JSON data in the request callback: + +```cpp +#include "AsyncJson.h" +#include "ArduinoJson.h" + +AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/rest/endpoint", [](AsyncWebServerRequest *request, JsonVariant &json) +{ + JsonObject& jsonObj = json.as(); + // ... +}); + +server.addHandler(handler); +``` +--- + +## Responses + +### Redirect to another URL + +```cpp +//to local url +request->redirect("/login"); + +//to external url +request->redirect("http://esp8266.com"); +``` + +### Basic response with HTTP Code + +```cpp +request->send(404); //Sends 404 File Not Found +``` + +### Basic response with HTTP Code and extra headers + +```cpp +AsyncWebServerResponse *response = request->beginResponse(404); //Sends 404 File Not Found +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Basic response with string content + +```cpp +request->send(200, "text/plain", "Hello World!"); +``` + +### Basic response with string content and extra headers + +```cpp +AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", "Hello World!"); +response->addHeader("Server","AsyncWebServer"); +request->send(response); +``` + +### Respond with content coming from a Stream + +```cpp +//read 12 bytes from Serial and send them as Content Type text/plain +request->send(Serial, "text/plain", 12); +``` + +### Respond with content coming from a Stream and extra headers + +```cpp +//read 12 bytes from Serial and send them as Content Type text/plain +AsyncWebServerResponse *response = request->beginResponse(Serial, "text/plain", 12); +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Respond with content coming from a Stream containing templates + +```cpp +String processor(const String& var) +{ + if (var == "HELLO_FROM_TEMPLATE") + return F("Hello world!"); + + return String(); +} + +// ... + +//read 12 bytes from Serial and send them as Content Type text/plain +request->send(Serial, "text/plain", 12, processor); +``` + +### Respond with content coming from a Stream containing templates and extra headers + +```cpp +String processor(const String& var) +{ + if (var == "HELLO_FROM_TEMPLATE") + return F("Hello world!"); + return String(); +} + +// ... + +//read 12 bytes from Serial and send them as Content Type text/plain +AsyncWebServerResponse *response = request->beginResponse(Serial, "text/plain", 12, processor); +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Respond with content using a callback + +```cpp +//send 128 bytes as plain text +request->send("text/plain", 128, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will not be asked for more bytes once the content length has been reached. + //Keep in mind that you can not delay or yield waiting for more data! + //Send what you currently have and you will be asked for more again + return mySource.read(buffer, maxLen); +}); +``` + +### Respond with content using a callback and extra headers + +```cpp +//send 128 bytes as plain text +AsyncWebServerResponse *response = request->beginResponse("text/plain", 128, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will not be asked for more bytes once the content length has been reached. + //Keep in mind that you can not delay or yield waiting for more data! + //Send what you currently have and you will be asked for more again + return mySource.read(buffer, maxLen); +}); + +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Respond with content using a callback containing templates + +```cpp +String processor(const String& var) +{ + if (var == "HELLO_FROM_TEMPLATE") + return F("Hello world!"); + + return String(); +} + +// ... + +//send 128 bytes as plain text +request->send("text/plain", 128, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will not be asked for more bytes once the content length has been reached. + //Keep in mind that you can not delay or yield waiting for more data! + //Send what you currently have and you will be asked for more again + return mySource.read(buffer, maxLen); +}, processor); +``` + +### Respond with content using a callback containing templates and extra headers + +```cpp +String processor(const String& var) +{ + if (var == "HELLO_FROM_TEMPLATE") + return F("Hello world!"); + return String(); +} + +// ... + +//send 128 bytes as plain text +AsyncWebServerResponse *response = request->beginResponse("text/plain", 128, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will not be asked for more bytes once the content length has been reached. + //Keep in mind that you can not delay or yield waiting for more data! + //Send what you currently have and you will be asked for more again + return mySource.read(buffer, maxLen); +}, processor); + +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Chunked Response + +Used when content length is unknown. Works best if the client supports HTTP/1.1 + +```cpp +AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will be asked for more data until 0 is returned + //Keep in mind that you can not delay or yield waiting for more data! + return mySource.read(buffer, maxLen); +}); + +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Chunked Response containing templates + +Used when content length is unknown. Works best if the client supports HTTP/1.1 + +```cpp +String processor(const String& var) +{ + if (var == "HELLO_FROM_TEMPLATE") + return F("Hello world!"); + + return String(); +} + +// ... + +AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will be asked for more data until 0 is returned + //Keep in mind that you can not delay or yield waiting for more data! + return mySource.read(buffer, maxLen); +}, processor); + +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +request->send(response); +``` + +### Print to response + +```cpp +AsyncResponseStream *response = request->beginResponseStream("text/html"); +response->addHeader("Server","AsyncWebServer_ESP32_ENC"); +response->printf("Webpage at %s", request->url().c_str()); + +response->print("

Hello "); +response->print(request->client()->remoteIP()); +response->print("

"); + +response->print("

General

"); +response->print("
    "); +response->printf("
  • Version: HTTP/1.%u
  • ", request->version()); +response->printf("
  • Method: %s
  • ", request->methodToString()); +response->printf("
  • URL: %s
  • ", request->url().c_str()); +response->printf("
  • Host: %s
  • ", request->host().c_str()); +response->printf("
  • ContentType: %s
  • ", request->contentType().c_str()); +response->printf("
  • ContentLength: %u
  • ", request->contentLength()); +response->printf("
  • Multipart: %s
  • ", request->multipart()?"true":"false"); +response->print("
"); + +response->print("

Headers

"); +response->print("
    "); +int headers = request->headers(); + +for (int i=0;igetHeader(i); + response->printf("
  • %s: %s
  • ", h->name().c_str(), h->value().c_str()); +} + +response->print("
"); + +response->print("

Parameters

"); +response->print("
    "); + +int params = request->params(); + +for (int i=0;igetParam(i); + + if (p->isFile()) + { + response->printf("
  • FILE[%s]: %s, size: %u
  • ", p->name().c_str(), p->value().c_str(), p->size()); + } + else if (p->isPost()) + { + response->printf("
  • POST[%s]: %s
  • ", p->name().c_str(), p->value().c_str()); + } + else + { + response->printf("
  • GET[%s]: %s
  • ", p->name().c_str(), p->value().c_str()); + } +} + +response->print("
"); + +response->print(""); +//send the response last +request->send(response); +``` + +### ArduinoJson Basic Response + +This way of sending Json is great for when the result is **below 4KB** + +```cpp +#include "AsyncJson.h" +#include "ArduinoJson.h" + + +AsyncResponseStream *response = request->beginResponseStream("application/json"); +DynamicJsonBuffer jsonBuffer; +JsonObject &root = jsonBuffer.createObject(); +root["heap"] = ESP.getFreeHeap(); +root["ssid"] = WiFi.SSID(); +root.printTo(*response); + +request->send(response); +``` + +### ArduinoJson Advanced Response + +This response can handle really **large Json objects (tested to 40KB)** + +There isn't any noticeable speed decrease for small results with the method above + +Since ArduinoJson does not allow reading parts of the string, the whole Json has to be passed every time a +chunks needs to be sent, which shows speed decrease proportional to the resulting json packets + +```cpp +#include "AsyncJson.h" +#include "ArduinoJson.h" + +AsyncJsonResponse * response = new AsyncJsonResponse(); +response->addHeader("Server","AsyncWebServer"); +JsonObject& root = response->getRoot(); +root["IP"] = Ethernet.localIP(); +response->setLength(); + +request->send(response); +``` +--- + +## Param Rewrite With Matching + +It is possible to rewrite the request url with parameter matchg. Here is an example with one parameter: +Rewrite for example "/radio/{frequence}" -> "/radio?f={frequence}" + +```cpp +class OneParamRewrite : public AsyncWebRewrite +{ + protected: + String _urlPrefix; + int _paramIndex; + String _paramsBackup; + + public: + OneParamRewrite(const char* from, const char* to) + : AsyncWebRewrite(from, to) + { + + _paramIndex = _from.indexOf('{'); + + if ( _paramIndex >=0 && _from.endsWith("}")) + { + _urlPrefix = _from.substring(0, _paramIndex); + int index = _params.indexOf('{'); + + if (index >= 0) + { + _params = _params.substring(0, index); + } + } + else + { + _urlPrefix = _from; + } + + _paramsBackup = _params; + } + + bool match(AsyncWebServerRequest *request) override + { + if (request->url().startsWith(_urlPrefix)) + { + if (_paramIndex >= 0) + { + _params = _paramsBackup + request->url().substring(_paramIndex); + } + else + { + _params = _paramsBackup; + } + + return true; + + } + else + { + return false; + } + } +}; +``` + +Usage: + +```cpp + server.addRewrite( new OneParamRewrite("/radio/{frequence}", "/radio?f={frequence}") ); +``` +--- + +## Using filters + +Filters can be set to `Rewrite` or `Handler` in order to control when to apply the rewrite and consider the handler. +A filter is a callback function that evaluates the request and return a boolean `true` to include the item +or `false` to exclude it. + +--- + +## Bad Responses + +Some responses are implemented, but you should not use them, because they do not conform to HTTP. +The following example will lead to unclean close of the connection and more time wasted +than providing the length of the content + +### Respond with content using a callback without content length to HTTP/1.0 clients + +```cpp +//This is used as fallback for chunked responses to HTTP/1.0 Clients +request->send("text/plain", 0, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t +{ + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //You will be asked for more data until 0 is returned + //Keep in mind that you can not delay or yield waiting for more data! + return mySource.read(buffer, maxLen); +}); +``` + +--- + +## Async WebSocket Plugin + +The server includes a web socket plugin which lets you define different WebSocket locations to connect to +without starting another listening service or using different port + +### Async WebSocket Event + +```cpp + +void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) +{ + if (type == WS_EVT_CONNECT) + { + //client connected + Serial.printf("ws[%s][%u] connect\n", server->url(), client->id()); + client->printf("Hello Client %u :)", client->id()); + client->ping(); + } + else if (type == WS_EVT_DISCONNECT) + { + //client disconnected + Serial.printf("ws[%s][%u] disconnect: %u\n", server->url(), client->id()); + } + else if (type == WS_EVT_ERROR) + { + //error was received from the other end + Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data); + } + else if (type == WS_EVT_PONG) + { + //pong message was received (in response to a ping request maybe) + Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:""); + } + else if (type == WS_EVT_DATA) + { + //data packet + AwsFrameInfo * info = (AwsFrameInfo*)arg; + + if (info->final && info->index == 0 && info->len == len) + { + //the whole message is in a single frame and we got all of it's data + Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len); + + if (info->opcode == WS_TEXT) + { + data[len] = 0; + Serial.printf("%s\n", (char*)data); + } + else + { + for (size_t i=0; i < info->len; i++) + { + Serial.printf("%02x ", data[i]); + } + + Serial.printf("\n"); + } + + if (info->opcode == WS_TEXT) + client->text("I got your text message"); + else + client->binary("I got your binary message"); + } + else + { + //message is comprised of multiple frames or the frame is split into multiple packets + if (info->index == 0) + { + if (info->num == 0) + Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary"); + + Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len); + } + + Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len); + + if (info->message_opcode == WS_TEXT) + { + data[len] = 0; + Serial.printf("%s\n", (char*)data); + } + else + { + for (size_t i=0; i < len; i++){ + Serial.printf("%02x ", data[i]); + } + Serial.printf("\n"); + } + + if ((info->index + len) == info->len) + { + Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len); + + if (info->final) + { + Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary"); + + if (info->message_opcode == WS_TEXT) + client->text("I got your text message"); + else + client->binary("I got your binary message"); + } + } + } + } +} +``` + +### Methods for sending data to a socket client + +```cpp +//Server methods +AsyncWebSocket ws("/ws"); +//printf to a client +ws.printf((uint32_t)client_id, arguments...); +//printf to all clients +ws.printfAll(arguments...); +//send text to a client +ws.text((uint32_t)client_id, (char*)text); +ws.text((uint32_t)client_id, (uint8_t*)text, (size_t)len); +//send text to all clients +ws.textAll((char*)text); +ws.textAll((uint8_t*)text, (size_t)len); +//send binary to a client +ws.binary((uint32_t)client_id, (char*)binary); +ws.binary((uint32_t)client_id, (uint8_t*)binary, (size_t)len); +ws.binary((uint32_t)client_id, flash_binary, 4); +//send binary to all clients +ws.binaryAll((char*)binary); +ws.binaryAll((uint8_t*)binary, (size_t)len); +//HTTP Authenticate before switch to Websocket protocol +ws.setAuthentication("user", "pass"); + +//client methods +AsyncWebSocketClient * client; +//printf +client->printf(arguments...); +//send text +client->text((char*)text); +client->text((uint8_t*)text, (size_t)len); +//send binary +client->binary((char*)binary); +client->binary((uint8_t*)binary, (size_t)len); +``` + +### Direct access to web socket message buffer + +When sending a web socket message using the above methods a buffer is created. Under certain circumstances you might want to manipulate or populate this buffer directly from your application, for example to prevent unnecessary duplications of the data. This example below shows how to create a buffer and print data to it from an ArduinoJson object then send it. + +```cpp +void sendDataWs(AsyncWebSocketClient * client) +{ + DynamicJsonBuffer jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + root["a"] = "abc"; + root["b"] = "abcd"; + root["c"] = "abcde"; + root["d"] = "abcdef"; + root["e"] = "abcdefg"; + size_t len = root.measureLength(); + AsyncWebSocketMessageBuffer * buffer = ws.makeBuffer(len); // creates a buffer (len + 1) for you. + + if (buffer) + { + root.printTo((char *)buffer->get(), len + 1); + + if (client) + { + client->text(buffer); + } + else + { + ws.textAll(buffer); + } + } +} +``` + +### Limiting the number of web socket clients + +Browsers sometimes do not correctly close the websocket connection, even when the `close()` function is called in javascript. This will eventually exhaust the web server's resources and will cause the server to crash. Periodically calling the `cleanClients()` function from the main `loop()` function limits the number of clients by closing the oldest client when the maximum number of clients has been exceeded. This can called be every cycle, however, if you wish to use less power, then calling as infrequently as once per second is sufficient. + +```cpp +void loop() +{ + ws.cleanupClients(); +} +``` + +--- + +## Async Event Source Plugin + +The server includes `EventSource` (Server-Sent Events) plugin which can be used to send short text events to the browser. +Difference between `EventSource` and `WebSockets` is that `EventSource` is single direction, text-only protocol. + +### Setup Event Source on the server + +```cpp +AsyncWebServer server(80); +AsyncEventSource events("/events"); + +void setup() +{ + // setup ...... + events.onConnect([](AsyncEventSourceClient *client) + { + if (client->lastId()) + { + Serial.printf("Client reconnected! Last message ID that it got is: %u\n", client->lastId()); + } + + //send event with message "hello!", id current millis + // and set reconnect delay to 1 second + client->send("hello!",NULL,millis(),1000); + }); + + //HTTP Basic authentication + events.setAuthentication("user", "pass"); + server.addHandler(&events); + // setup ...... +} + +void loop() +{ + if (eventTriggered) + { + // your logic here + //send event "myevent" + events.send("my event content","myevent",millis()); + } +} +``` + +### Setup Event Source in the browser + +```javascript +if (!!window.EventSource) +{ + var source = new EventSource('/events'); + + source.addEventListener('open', function(e) + { + console.log("Events Connected"); + }, false); + + source.addEventListener('error', function(e) + { + if (e.target.readyState != EventSource.OPEN) + { + console.log("Events Disconnected"); + } + }, false); + + source.addEventListener('message', function(e) + { + console.log("message", e.data); + }, false); + + source.addEventListener('myevent', function(e) + { + console.log("myevent", e.data); + }, false); +} +``` +--- + +## Remove handlers and rewrites + +Server goes through handlers in same order as they were added. You can't simple add handler with same path to override them. +To remove handler: + +```cpp +// save callback for particular URL path +auto handler = server.on("/some/path", [](AsyncWebServerRequest *request) +{ + //do something useful +}); + +// when you don't need handler anymore remove it +server.removeHandler(&handler); + +// same with rewrites +server.removeRewrite(&someRewrite); + +server.onNotFound([](AsyncWebServerRequest *request) +{ + request->send(404); +}); + +// remove server.onNotFound handler +server.onNotFound(NULL); + +// remove all rewrites, handlers and onNotFound/onFileUpload/onRequestBody callbacks +server.reset(); +``` +--- + +## Setting up the server + +```cpp +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +void handleRoot(AsyncWebServerRequest *request) +{ + request->send(200, "text/plain", String("Hello from Async_HelloServer on ") + BOARD_NAME ); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + //message += server.uri(); + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart Async_HelloServer on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("HTTP EthernetWebServer is @ IP : ")); + Serial.println(ETH.localIP()); +} + +void loop() +{ +} +``` +--- + +### Setup global and class functions as request handlers + +```cpp +#include + +#include + +... + +void handleRequest(AsyncWebServerRequest *request){} + +class WebClass +{ +public : + AsyncWebServer classWebServer = AsyncWebServer(81); + + WebClass(){}; + + void classRequest (AsyncWebServerRequest *request){} + + void begin() + { + // attach global request handler + classWebServer.on("/example", HTTP_ANY, handleRequest); + + // attach class request handler + classWebServer.on("/example", HTTP_ANY, std::bind(&WebClass::classRequest, this, std::placeholders::_1)); + } +}; + +AsyncWebServer globalWebServer(80); +WebClass webClassInstance; + +void setup() +{ + // attach global request handler + globalWebServer.on("/example", HTTP_ANY, handleRequest); + + // attach class request handler + globalWebServer.on("/example", HTTP_ANY, std::bind(&WebClass::classRequest, webClassInstance, std::placeholders::_1)); +} + +void loop() +{ + +} +``` + +### Methods for controlling websocket connections + +```cpp + // Disable client connections if it was activated + if ( ws.enabled() ) + ws.enable(false); + + // enable client connections if it was disabled + if ( !ws.enabled() ) + ws.enable(true); +``` + + +### Adding Default Headers + +In some cases, such as when working with CORS, or with some sort of custom authentication system, +you might need to define a header that should get added to all responses (including static, websocket and EventSource). +The DefaultHeaders singleton allows you to do this. + +Example: + +```cpp +DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*"); +webServer.begin(); +``` + +*NOTE*: You will still need to respond to the OPTIONS method for CORS pre-flight in most cases. (unless you are only using GET) + +This is one option: + +```cpp +webServer.onNotFound([](AsyncWebServerRequest *request) +{ + if (request->method() == HTTP_OPTIONS) { + request->send(200); + } else { + request->send(404); + } +}); +``` + +--- + +### Path variable + +With path variable you can create a custom regex rule for a specific parameter in a route. +For example we want a `sensorId` parameter in a route rule to match only a integer. + +```cpp + server.on("^\\/sensor\\/([0-9]+)$", HTTP_GET, [] (AsyncWebServerRequest *request) + { + String sensorId = request->pathArg(0); + }); +``` + +*NOTE*: All regex patterns starts with `^` and ends with `$` + +To enable the `Path variable` support, you have to define the buildflag `-DASYNCWEBSERVER_REGEX`. + + +For Arduino IDE create/update `platform.local.txt`: + +`Windows`: C:\Users\(username)\AppData\Local\Arduino15\packages\\`{espxxxx}`\hardware\\`espxxxx`\\`{version}`\platform.local.txt + +`Linux`: ~/.arduino15/packages/`{espxxxx}`/hardware/`{espxxxx}`/`{version}`/platform.local.txt + +Add/Update the following line: + +``` + compiler.cpp.extra_flags=-DDASYNCWEBSERVER_REGEX +``` + +For platformio modify `platformio.ini`: + +```ini +[env:myboard] +build_flags = + -DASYNCWEBSERVER_REGEX +``` + +*NOTE*: By enabling `ASYNCWEBSERVER_REGEX`, `` will be included. This will add an 100k to your binary. + + +--- +--- + +### Examples + + 1. [Async_AdvancedWebServer](examples/Async_AdvancedWebServer) + 2. [Async_HelloServer](examples/Async_HelloServer) + 3. [Async_HelloServer2](examples/Async_HelloServer2) + 4. [AsyncMultiWebServer_ESP32_ENC](examples/AsyncMultiWebServer_ESP32_ENC) + 5. [Async_PostServer](examples/Async_PostServer) + 6. [Async_RegexPatterns_ESP32_ENC](examples/Async_RegexPatterns_ESP32_ENC) + 7. [AsyncSimpleServer_ESP32_ENC](examples/AsyncSimpleServer_ESP32_ENC) + 8. [Async_AdvancedWebServer_MemoryIssues_SendArduinoString](examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString) + 9. [Async_AdvancedWebServer_MemoryIssues_Send_CString](examples/Async_AdvancedWebServer_MemoryIssues_Send_CString) +10. [Async_AdvancedWebServer_SendChunked](examples/Async_AdvancedWebServer_SendChunked) +11. [AsyncWebServer_SendChunked](examples/AsyncWebServer_SendChunked) + +--- +--- + +### Example [Async_AdvancedWebServer](examples/Async_AdvancedWebServer) + +https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/blob/b24816d562013bb868e450863c1ab8bbb77fb8ee/examples/Async_AdvancedWebServer/Async_AdvancedWebServer.ino#L41-L194 + + +You can access the Async Advanced WebServer @ the server IP + +

+ +

+ +--- +--- + +### Debug Terminal Output Samples + +#### 1. AsyncMultiWebServer_ESP32_ENC on ESP32_DEV with ESP32_ENC28J60 + +Following are debug terminal output and screen shots when running example [AsyncMultiWebServer_ESP32_ENC](examples/AsyncMultiWebServer_ESP32_ENC) on `ESP32_DEV with ESP32_ENC28J60`, using ESP32 core `v2.0.0+`, to demonstrate the operation of 3 independent AsyncWebServers on 3 different ports and how to handle the complicated AsyncMultiWebServers. + + +```cpp +Start AsyncMultiWebServer_ESP32_ENC on ESP32_DEV with ESP32_ENC28J60 +AsyncWebServer_ESP32_ENC v1.6.2 for core v2.0.0+ +[AWS] Default SPI pinout: +[AWS] MOSI: 23 +[AWS] MISO: 19 +[AWS] SCK: 18 +[AWS] CS: 5 +[AWS] INT: 4 +[AWS] SPI Clock (MHz): 8 +[AWS] ========================= + +ETH Started +ETH Connected +ETH MAC: DE:AD:BE:EF:FE:13, IPv4: 192.168.2.232 +FULL_DUPLEX, 10Mbps + +Connected to network. IP = 192.168.2.232 +Initialize multiServer OK, serverIndex = 0, port = 8080 +HTTP server started at ports 8080 +Initialize multiServer OK, serverIndex = 1, port = 8081 +HTTP server started at ports 8081 +Initialize multiServer OK, serverIndex = 2, port = 8082 +HTTP server started at ports 8082 +``` + +You can access the Async Advanced WebServers @ the server IP and corresponding ports (8080, 8081 and 8082) + +

+ +

+ +

+ +

+ +

+ +

+ +--- + +#### 2. Async_AdvancedWebServer_MemoryIssues_Send_CString on ESP32_DEV with ESP32_ENC28J60 + +Following is the debug terminal and screen shot when running example [Async_AdvancedWebServer_MemoryIssues_Send_CString](examples/Async_AdvancedWebServer_MemoryIssues_Send_CString), on `ESP32_DEV with ESP32_ENC28J60`, to demonstrate the new and powerful `HEAP-saving` feature + + +##### Using CString ===> smaller heap (120,880 bytes) + +```cpp +Start Async_AdvancedWebServer_MemoryIssues_Send_CString on ESP32_DEV with ESP32_ENC28J60 +AsyncWebServer_ESP32_ENC v1.6.2 for core v2.0.0+ +[AWS] Default SPI pinout: +[AWS] MOSI: 23 +[AWS] MISO: 19 +[AWS] SCK: 18 +[AWS] CS: 5 +[AWS] INT: 4 +[AWS] SPI Clock (MHz): 8 +[AWS] ========================= + +ETH Started +ETH Connected +ETH MAC: DE:AD:BE:EF:FE:13, IPv4: 192.168.2.232 +FULL_DUPLEX, 10Mbps +HTTP EthernetWebServer is @ IP : 192.168.2.232 + +HEAP DATA - Pre Create Arduino String Max heap: 322992 Free heap: 222252 Used heap: 100740 +.... +HEAP DATA - Pre Send Max heap: 322992 Free heap: 218356 Used heap: 104636 + +HEAP DATA - Post Send Max heap: 322992 Free heap: 210204 Used heap: 112716 +... +HEAP DATA - Post Send Max heap: 322992 Free heap: 210148 Used heap: 112772 +``` + +While using `Arduino String`, the HEAP usage is very large + + +#### Async_AdvancedWebServer_MemoryIssues_SendArduinoString ===> very large heap (152,136 bytes) + +```cpp +Start Async_AdvancedWebServer_MemoryIssues_SendArduinoString on ESP32_DEV with ESP32_ENC28J60 +AsyncWebServer_ESP32_ENC v1.6.2 for core v2.0.0+ +[AWS] Default SPI pinout: +[AWS] MOSI: 23 +[AWS] MISO: 19 +[AWS] SCK: 18 +[AWS] CS: 5 +[AWS] INT: 4 +[AWS] SPI Clock (MHz): 8 +[AWS] ========================= + +ETH Started +ETH Connected +ETH MAC: DE:AD:BE:EF:BE:14, IPv4: 192.168.2.232 +FULL_DUPLEX, 10Mbps +HTTP EthernetWebServer is @ IP : 192.168.2.232 + +HEAP DATA - Pre Create Arduino String Max heap: 323272 Free heap: 262532 Used heap: 60740 +.. +HEAP DATA - Pre Send Max heap: 323272 Free heap: 218656 Used heap: 104616 + +HEAP DATA - Post Send Max heap: 323272 Free heap: 179284 Used heap: 143988 +.... +``` + + +You can access the Async Advanced WebServers at the displayed server IP, e.g. `192.168.2.232` + +

+ +

+ +--- + +#### 3. Async_AdvancedWebServer_SendChunked on ESP32_DEV with ESP32_ENC28J60 + +Following is debug terminal output when running example [Async_AdvancedWebServer_SendChunked](examples/Async_AdvancedWebServer_SendChunked) on `ESP32_DEV with ESP32_ENC28J60`, using ESP32 core `v2.0.0+`, to demo how to use `beginChunkedResponse()` to send large `html` in chunks + +```cpp +Start Async_AdvancedWebServer_SendChunked on ESP32_DEV with ESP32_ENC28J60 +AsyncWebServer_ESP32_ENC v1.6.2 for core v2.0.0+ +[AWS] Default SPI pinout: +[AWS] MOSI: 23 +[AWS] MISO: 19 +[AWS] SCK: 18 +[AWS] CS: 5 +[AWS] INT: 4 +[AWS] SPI Clock (MHz): 8 +[AWS] ========================= + +ETH Started +ETH Connected +ETH MAC: DE:AD:BE:EF:FE:13, IPv4: 192.168.2.93 +FULL_DUPLEX, 10Mbps +AsyncWebServer is @ IP : 192.168.2.93 +.[AWS] Total length to send in chunks = 31259 +[AWS] Bytes sent in chunk = 5620 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2727 +[AWS] Bytes sent in chunk = 0 +.[AWS] Total length to send in chunks = 31279 +[AWS] Bytes sent in chunk = 5620 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 1428 +[AWS] Bytes sent in chunk = 1428 +[AWS] Bytes sent in chunk = 2755 +[AWS] Bytes sent in chunk = 0 + +``` + +You can access the Async Advanced WebServers @ the server IP + +

+ +

+ + +--- + +#### 4. AsyncWebServer_SendChunked on ESP32_DEV with ESP32_ENC28J60 + +Following is debug terminal output when running example [AsyncWebServer_SendChunked](examples/AsyncWebServer_SendChunked) on `ESP32_DEV with ESP32_ENC28J60`, using ESP32 core `v2.0.0+`, to demo how to use `beginChunkedResponse()` to send large `html` in chunks + + +```cpp +Start AsyncWebServer_SendChunked on ESP32_DEV with ESP32_ENC28J60 +AsyncWebServer_ESP32_ENC v1.6.2 for core v2.0.0+ +[AWS] Default SPI pinout: +[AWS] MOSI: 23 +[AWS] MISO: 19 +[AWS] SCK: 18 +[AWS] CS: 5 +[AWS] INT: 4 +[AWS] SPI Clock (MHz): 8 +[AWS] ========================= + +ETH Started +ETH Connected +ETH MAC: DE:AD:BE:EF:BE:14, IPv4: 192.168.2.232 +FULL_DUPLEX, 10Mbps +AsyncWebServer is @ IP : 192.168.2.232 +.[AWS] Total length to send in chunks = 46800 +[AWS] Bytes sent in chunk = 5624 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 1428 +[AWS] Bytes sent in chunk = 1428 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 1088 +[AWS] Bytes sent in chunk = 0 +[AWS] Total length to send in chunks = 46800 +[AWS] Bytes sent in chunk = 5624 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 2864 +[AWS] Bytes sent in chunk = 1080 +[AWS] Bytes sent in chunk = 0 + +``` + +--- +--- + +### Debug + +Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the _ETHERNET_WEBSERVER_LOGLEVEL_ to 0 + +```cpp +// Use this to output debug msgs to Serial +#define DEBUG_ASYNC_WEBSERVER_PORT Serial +// Use this to disable all output debug msgs +// Debug Level from 0 to 4 +#define _ASYNC_WEBSERVER_LOGLEVEL_ 0 +``` + +--- + +### Troubleshooting + +If you get compilation errors, more often than not, you may need to install a newer version of Arduino IDE, the Arduino `ESP32` core or depending libraries. + +Sometimes, the library will only work if you update the `ESP32` core to the latest version because I'm always using the latest cores /libraries. + +--- + +### Issues ### + +Submit issues to: [AsyncWebServer_ESP32_ENC issues](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/issues) + +--- +--- + +## TO DO + + 1. Fix bug. Add enhancement + 2. Add support to more Ethernet shields, such as **W5x00, DP83848, TLK110, IP101, RTL8201, DM9051, KSZ8041, KSZ8081, etc.** + +--- + +## DONE + + 1. Initial port to `ESP32` boards using `ENC28J60` Ethernet. + 2. Add more examples. + 3. Add debugging features. + 4. Add Table-of-Contents and Version String + 5. Display compiler `#warning` only when `DEBUG_LEVEL` is 3+ + 6. Fix AsyncWebSocket bug + 7. 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) + 8. Add examples [Async_AdvancedWebServer_SendChunked](https://github.com/khoih-prog/AsyncWebServer_RP2040W/tree/main/examples/Async_AdvancedWebServer_SendChunked) and [AsyncWebServer_SendChunked](https://github.com/khoih-prog/AsyncWebServer_RP2040W/tree/main/examples/AsyncWebServer_SendChunked) to demo how to use `beginChunkedResponse()` to send large `html` in chunks + 9. Use `allman astyle` and add `utils` + + +--- +--- + + +### Contributions and Thanks + +1. Based on and modified from [Hristo Gochkov's ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer). Many thanks to [Hristo Gochkov](https://github.com/me-no-dev) for great [ESPAsyncWebServer Library](https://github.com/me-no-dev/ESPAsyncWebServer) +2. Thanks to [tobozo](https://github.com/tobozo) to make the library [ESP32-ENC28J60](https://github.com/tobozo/ESP32-ENC28J60) from which this library uses some ideas and codes + + + + + + + +
me-no-dev
⭐️⭐️ Hristo Gochkov

tobozo
tobozo

+ +--- + +### Contributing + +If you want to contribute to this project: +- Report bugs and errors +- Ask for enhancements +- Create issues and pull requests +- Tell other people about this library + +--- + +### License + +- The library is licensed under [GPLv3](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/blob/main/LICENSE) + +--- + +## Copyright + +- Copyright (c) 2016- Hristo Gochkov + +- Copyright (c) 2021- Khoi Hoang + + + diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..91d45f8 --- /dev/null +++ b/changelog.md @@ -0,0 +1,33 @@ +# AsyncWebServer_ESP32_ENC + +[![arduino-library-badge](https://www.ardu-badge.com/badge/AsyncWebServer_ESP32_ENC.svg?)](https://www.ardu-badge.com/AsyncWebServer_ESP32_ENC) +[![GitHub release](https://img.shields.io/github/release/khoih-prog/AsyncWebServer_ESP32_ENC.svg)](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/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_ENC.svg)](http://github.com/khoih-prog/AsyncWebServer_ESP32_ENC/issues) + +Donate to my libraries using BuyMeACoffee + + + + +--- +--- + +## Table of contents + +* [Changelog](#changelog) + * [Releases v1.6.2](#releases-v162) + + + +--- +--- + +## Changelog + +#### Releases v1.6.2 + +1. Initial coding to port [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to ESP32 boards using ENC28J60 Ethernet. +2. Bump up to `v1.6.2` to sync with [AsyncWebServer_ESP32_ENC v1.6.2](https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC). +3. Use `allman astyle` + diff --git a/examples/AsyncMultiWebServer_ESP32_ENC/AsyncMultiWebServer_ESP32_ENC.ino b/examples/AsyncMultiWebServer_ESP32_ENC/AsyncMultiWebServer_ESP32_ENC.ino new file mode 100644 index 0000000..ed7c89c --- /dev/null +++ b/examples/AsyncMultiWebServer_ESP32_ENC/AsyncMultiWebServer_ESP32_ENC.ino @@ -0,0 +1,250 @@ +/**************************************************************************************************************************** + AsyncMultiWebServer_ESP32_ENC.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +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, + "\ +\ +\ +%s\ +\ +\ +\ +

Hello from %s

\ +

running AsyncMultiWebServer_ESP32_ENC

\ +

on %s

\ +

Uptime: %d d %02d:%02d:%02d

\ +\ +", BOARD_NAME, BOARD_NAME, 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_ENC on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_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_ENC using ENC28J60 Ethernet, running on "); + message += BOARD_NAME; + + 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() +{ +} diff --git a/examples/AsyncSimpleServer_ESP32_ENC/AsyncSimpleServer_ESP32_ENC.ino b/examples/AsyncSimpleServer_ESP32_ENC/AsyncSimpleServer_ESP32_ENC.ino new file mode 100644 index 0000000..a9f4d51 --- /dev/null +++ b/examples/AsyncSimpleServer_ESP32_ENC/AsyncSimpleServer_ESP32_ENC.ino @@ -0,0 +1,171 @@ +/**************************************************************************************************************************** + AsyncSimpleServer_ESP32_ENC.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for ESP32_ENC to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +const char* PARAM_MESSAGE = "message"; + +void notFound(AsyncWebServerRequest *request) +{ + request->send(404, "text/plain", "Not found"); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + Serial.print(F("\nStart AsyncSimpleServer_ESP32_ENC on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "Hello, world from AsyncSimpleServer_ESP32_ENC"); + }); + + // Send a GET request to /get?message= + server.on("/get", HTTP_GET, [] (AsyncWebServerRequest * request) + { + String message; + + if (request->hasParam(PARAM_MESSAGE)) + { + message = request->getParam(PARAM_MESSAGE)->value(); + } + else + { + message = "No message sent"; + } + + request->send(200, "text/plain", "Hello, GET: " + message); + }); + + // Send a POST request to /post with a form field message set to + server.on("/post", HTTP_POST, [](AsyncWebServerRequest * request) + { + String message; + + if (request->hasParam(PARAM_MESSAGE, true)) + { + message = request->getParam(PARAM_MESSAGE, true)->value(); + } + else + { + message = "No message sent"; + } + + request->send(200, "text/plain", "Hello, POST: " + message); + }); + + server.onNotFound(notFound); + + server.begin(); +} + +void loop() +{ +} diff --git a/examples/AsyncWebServer_SendChunked/AsyncWebServer_SendChunked.ino b/examples/AsyncWebServer_SendChunked/AsyncWebServer_SendChunked.ino new file mode 100644 index 0000000..5963249 --- /dev/null +++ b/examples/AsyncWebServer_SendChunked/AsyncWebServer_SendChunked.ino @@ -0,0 +1,266 @@ +/**************************************************************************************************************************** + AsyncWebServer_SendChunked.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for ESP32_ENC to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#define _ASYNC_WEBSERVER_LOGLEVEL_ 4 + +// 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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +// In bytes +#define STRING_SIZE 50000 + +AsyncWebServer server(80); + +int reqCount = 0; // number of requests received + +#define BUFFER_SIZE 512 +char temp[BUFFER_SIZE]; + +void createPage(String &pageInput) +{ + int sec = millis() / 1000; + int min = sec / 60; + int hr = min / 60; + int day = hr / 24; + + snprintf(temp, BUFFER_SIZE - 1, + "\ +\ +\ +AsyncWebServer-%s\ +\ +\ +\ +

AsyncWebServer_SendChunked_ESP32_ENC!

\ +

running on %s

\ +

Uptime: %d d %02d:%02d:%02d

\ +\ +", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60); + + pageInput = temp; +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +String out; + +void handleRoot(AsyncWebServerRequest *request) +{ + out.reserve(STRING_SIZE); + char temp[70]; + + // clear the String to start over + out = String(); + + createPage(out); + + out += "\r\n"; + + for (uint16_t lineIndex = 0; lineIndex < 500; lineIndex++) + { + out += ""; + } + + out += "
INDEXDATA
"; + out += String(lineIndex); + out += ""; + out += "ESP32_ENC_AsyncWebServer_SendChunked_ABCDEFGHIJKLMNOPQRSTUVWXYZ
\r\n"; + + AWS_LOGDEBUG1("Total length to send in chunks =", out.length()); + + AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [](uint8_t *buffer, size_t maxLen, + size_t filledLength) -> size_t + { + size_t len = min(maxLen, out.length() - filledLength); + memcpy(buffer, out.c_str() + filledLength, len); + + AWS_LOGDEBUG1("Bytes sent in chunk =", len); + + return len; + }); + + request->send(response); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print("\nStart AsyncWebServer_SendChunked on "); + Serial.print(BOARD_NAME); + Serial.print(" with "); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("AsyncWebServer is @ IP : ")); + Serial.println(ETH.localIP()); +} + +void heartBeatPrint() +{ + static int num = 1; + + Serial.print(F(".")); + + if (num == 80) + { + Serial.println(); + num = 1; + } + else if (num++ % 10 == 0) + { + Serial.print(F(" ")); + } +} + +void check_status() +{ + static unsigned long checkstatus_timeout = 0; + +#define STATUS_CHECK_INTERVAL 10000L + + // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. + if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) + { + heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; + } +} + +void loop() +{ + check_status(); +} diff --git a/examples/Async_AdvancedWebServer/Async_AdvancedWebServer.ino b/examples/Async_AdvancedWebServer/Async_AdvancedWebServer.ino new file mode 100644 index 0000000..14fe02e --- /dev/null +++ b/examples/Async_AdvancedWebServer/Async_AdvancedWebServer.ino @@ -0,0 +1,252 @@ +/**************************************************************************************************************************** + Async_AdvancedWebServer.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Copyright (c) 2015, Majenko Technologies + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + Neither the name of Majenko Technologies nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +int reqCount = 0; // number of requests received + +void handleRoot(AsyncWebServerRequest *request) +{ +#define BUFFER_SIZE 400 + + char temp[BUFFER_SIZE]; + int sec = millis() / 1000; + int min = sec / 60; + int hr = min / 60; + int day = hr / 24; + + snprintf(temp, BUFFER_SIZE - 1, + "\ +\ +\ +AsyncWebServer-%s\ +\ +\ +\ +

AsyncWebServer_ESP32_ENC!

\ +

running on %s

\ +

Uptime: %d d %02d:%02d:%02d

\ +\ +\ +", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60); + + request->send(200, "text/html", temp); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +void drawGraph(AsyncWebServerRequest *request) +{ + String out; + + out.reserve(3000); + char temp[70]; + + out += "\n"; + out += "\n"; + out += "\n"; + int y = rand() % 130; + + for (int x = 10; x < 300; x += 10) + { + int y2 = rand() % 130; + sprintf(temp, "\n", x, 140 - y, x + 10, 140 - y2); + out += temp; + y = y2; + } + + out += "\n\n"; + + request->send(200, "image/svg+xml", out); +} + + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart AsyncSimpleServer_ESP32_ENC on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/test.svg", HTTP_GET, [](AsyncWebServerRequest * request) + { + drawGraph(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("HTTP EthernetWebServer is @ IP : ")); + Serial.println(ETH.localIP()); +} + +void loop() +{ +} diff --git a/examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString/Async_AdvancedWebServer_MemoryIssues_SendArduinoString.ino b/examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString/Async_AdvancedWebServer_MemoryIssues_SendArduinoString.ino new file mode 100644 index 0000000..ac7a6a4 --- /dev/null +++ b/examples/Async_AdvancedWebServer_MemoryIssues_SendArduinoString/Async_AdvancedWebServer_MemoryIssues_SendArduinoString.ino @@ -0,0 +1,334 @@ +/**************************************************************************************************************************** + Async_AdvancedWebServer_MemoryIssues_SendArduinoString.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Copyright (c) 2015, Majenko Technologies + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + Neither the name of Majenko Technologies nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +// In bytes +#define STRING_SIZE 40000 + +AsyncWebServer server(80); + +int reqCount = 0; // number of requests received + +#define BUFFER_SIZE 512 +char temp[BUFFER_SIZE]; + +void handleRoot(AsyncWebServerRequest *request) +{ + int sec = millis() / 1000; + int min = sec / 60; + int hr = min / 60; + int day = hr / 24; + + snprintf(temp, BUFFER_SIZE - 1, + "\ +\ +\ +AsyncWebServer-%s\ +\ +\ +\ +

AsyncWebServer_ESP32_ENC!

\ +

running on %s

\ +

Uptime: %d d %02d:%02d:%02d

\ +\ +\ +", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60); + + request->send(200, "text/html", temp); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +void PrintHeapData(String hIn) +{ + static uint32_t maxFreeHeap = 0xFFFFFFFF; + static uint32_t totalHeap = ESP.getHeapSize(); + + uint32_t freeHeap = ESP.getFreeHeap(); + + // Print and update only when larger heap + if (maxFreeHeap > freeHeap) + { + maxFreeHeap = freeHeap; + + Serial.print("\nHEAP DATA - "); + Serial.print(hIn); + + Serial.print(" Max heap: "); + Serial.print(totalHeap); + Serial.print(" Free heap: "); + Serial.print(ESP.getFreeHeap()); + Serial.print(" Used heap: "); + Serial.println(totalHeap - freeHeap); + } +} + +void PrintStringSize(String & out) +{ + static uint32_t count = 0; + + // Print only when cStr length too large and corrupting memory or every (20 * 5) s + if ( (out.length() >= STRING_SIZE) || (++count > 20) ) + { + Serial.print("\nOut String Length="); + Serial.println(out.length()); + + count = 0; + } +} + +void drawGraph(AsyncWebServerRequest *request) +{ + String out; + + out.reserve(STRING_SIZE); + char temp[70]; + + out += "\n"; + out += "\n"; + out += "\n"; + int y = rand() % 130; + + for (int x = 10; x < 5000; x += 10) + { + int y2 = rand() % 130; + sprintf(temp, "\n", x, 140 - y, x + 10, 140 - y2); + out += temp; + y = y2; + } + + out += "\n\n"; + + PrintHeapData("Pre Send"); + + PrintStringSize(out); + + request->send(200, "image/svg+xml", out); + + PrintHeapData("Post Send"); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print("\nStart Async_AdvancedWebServer_MemoryIssues_SendArduinoString on "); + Serial.print(BOARD_NAME); + Serial.print(" with "); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/test.svg", HTTP_GET, [](AsyncWebServerRequest * request) + { + drawGraph(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("HTTP EthernetWebServer is @ IP : ")); + Serial.println(ETH.localIP()); + + PrintHeapData("Pre Create Arduino String"); +} + +void heartBeatPrint() +{ + static int num = 1; + + Serial.print(F(".")); + + if (num == 80) + { + Serial.println(); + num = 1; + } + else if (num++ % 10 == 0) + { + Serial.print(F(" ")); + } +} + +void check_status() +{ + static unsigned long checkstatus_timeout = 0; + +#define STATUS_CHECK_INTERVAL 10000L + + // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. + if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) + { + heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; + } +} + +void loop() +{ + check_status(); +} diff --git a/examples/Async_AdvancedWebServer_MemoryIssues_Send_CString/Async_AdvancedWebServer_MemoryIssues_Send_CString.ino b/examples/Async_AdvancedWebServer_MemoryIssues_Send_CString/Async_AdvancedWebServer_MemoryIssues_Send_CString.ino new file mode 100644 index 0000000..a950052 --- /dev/null +++ b/examples/Async_AdvancedWebServer_MemoryIssues_Send_CString/Async_AdvancedWebServer_MemoryIssues_Send_CString.ino @@ -0,0 +1,344 @@ +/**************************************************************************************************************************** + Async_AdvancedWebServer_MemoryIssues_Send_CString.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Copyright (c) 2015, Majenko Technologies + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + Neither the name of Majenko Technologies nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +char *cStr; + +// In bytes +#define CSTRING_SIZE 40000 + +AsyncWebServer server(80); + +int reqCount = 0; // number of requests received + +#define BUFFER_SIZE 768 // a little larger in case required for header shift (destructive send) +char temp[BUFFER_SIZE]; + +void handleRoot(AsyncWebServerRequest *request) +{ + int sec = millis() / 1000; + int min = sec / 60; + int hr = min / 60; + int day = hr / 24; + + snprintf(temp, BUFFER_SIZE - 1, + "\ +\ +\ +AsyncWebServer-%s\ +\ +\ +\ +

AsyncWebServer_ESP32_ENC!

\ +

running on %s

\ +

Uptime: %d d %02d:%02d:%02d

\ +\ +\ +", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60); + + request->send(200, "text/html", temp); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +void PrintHeapData(String hIn) +{ + static uint32_t maxFreeHeap = 0xFFFFFFFF; + static uint32_t totalHeap = ESP.getHeapSize(); + + uint32_t freeHeap = ESP.getFreeHeap(); + + // Print and update only when larger heap + if (maxFreeHeap > freeHeap) + { + maxFreeHeap = freeHeap; + + Serial.print("\nHEAP DATA - "); + Serial.print(hIn); + + Serial.print(" Max heap: "); + Serial.print(totalHeap); + Serial.print(" Free heap: "); + Serial.print(ESP.getFreeHeap()); + Serial.print(" Used heap: "); + Serial.println(totalHeap - freeHeap); + } +} + +void PrintStringSize(const char* cStr) +{ + Serial.print("\nOut String Length="); + Serial.println(strlen(cStr)); +} + +void drawGraph(AsyncWebServerRequest *request) +{ + char temp[80]; + + cStr[0] = '\0'; + + strcat(cStr, "\n"); + strcat(cStr, + "\n"); + strcat(cStr, "\n"); + int y = rand() % 130; + + for (int x = 10; x < 5000; x += 10) + { + int y2 = rand() % 130; + sprintf(temp, "\n", x, 140 - y, x + 10, 140 - y2); + strcat(cStr, temp); + y = y2; + } + + strcat(cStr, "\n\n"); + + PrintHeapData("Pre Send"); + + // Print only when cStr length too large and corrupting memory + if ( (strlen(cStr) >= CSTRING_SIZE)) + { + PrintStringSize(cStr); + } + + request->send(200, "image/svg+xml", cStr, false); + + PrintHeapData("Post Send"); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print("\nStart Async_AdvancedWebServer_MemoryIssues_Send_CString on "); + Serial.print(BOARD_NAME); + Serial.print(" with "); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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("=========================")); + + /////////////////////////////////// + + cStr = (char *) malloc(CSTRING_SIZE); // make a little larger than required + + if (cStr == NULL) + { + Serial.println("Unable top Allocate RAM"); + + for (;;); + } + + /////////////////////////////////// + + // To be called before ETH.begin() + ESP32_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/test.svg", HTTP_GET, [](AsyncWebServerRequest * request) + { + drawGraph(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("HTTP EthernetWebServer is @ IP : ")); + Serial.println(ETH.localIP()); + + PrintHeapData("Pre Create Arduino String"); +} + +void heartBeatPrint() +{ + static int num = 1; + + Serial.print(F(".")); + + if (num == 80) + { + //Serial.println(); + PrintStringSize(cStr); + num = 1; + } + else if (num++ % 10 == 0) + { + Serial.print(F(" ")); + } +} + +void check_status() +{ + static unsigned long checkstatus_timeout = 0; + +#define STATUS_CHECK_INTERVAL 10000L + + // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. + if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) + { + heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; + } +} + +void loop() +{ + check_status(); +} diff --git a/examples/Async_AdvancedWebServer_SendChunked/Async_AdvancedWebServer_SendChunked.ino b/examples/Async_AdvancedWebServer_SendChunked/Async_AdvancedWebServer_SendChunked.ino new file mode 100644 index 0000000..c35e05f --- /dev/null +++ b/examples/Async_AdvancedWebServer_SendChunked/Async_AdvancedWebServer_SendChunked.ino @@ -0,0 +1,301 @@ +/**************************************************************************************************************************** + Async_AdvancedWebServer_SendChunked.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Copyright (c) 2015, Majenko Technologies + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + Neither the name of Majenko Technologies nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#define _ASYNC_WEBSERVER_LOGLEVEL_ 4 + +// 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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +// In bytes +#define STRING_SIZE 40000 + +AsyncWebServer server(80); + +int reqCount = 0; // number of requests received + +#define BUFFER_SIZE 512 +char temp[BUFFER_SIZE]; + +void handleRoot(AsyncWebServerRequest *request) +{ + int sec = millis() / 1000; + int min = sec / 60; + int hr = min / 60; + int day = hr / 24; + + snprintf(temp, BUFFER_SIZE - 1, + "\ +\ +\ +AsyncWebServer-%s\ +\ +\ +\ +

Async_AdvancedWebServer_SendChunked!

\ +

running on %s

\ +

Uptime: %d d %02d:%02d:%02d

\ +\ +\ +", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60); + + request->send(200, "text/html", temp); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +String out; + +void drawGraph(AsyncWebServerRequest *request) +{ + out.reserve(STRING_SIZE); + char temp[70]; + + out = String(); + + out += "\n"; + out += "\n"; + out += "\n"; + int y = rand() % 130; + + for (int x = 10; x < 5000; x += 10) + { + int y2 = rand() % 130; + sprintf(temp, "\n", x, 140 - y, x + 10, 140 - y2); + out += temp; + y = y2; + } + + out += "\n\n"; + + AWS_LOGDEBUG1("Total length to send in chunks =", out.length()); + + AsyncWebServerResponse *response = request->beginChunkedResponse("image/svg+xml", [](uint8_t *buffer, size_t maxLen, + size_t filledLength) -> size_t + { + size_t len = min(maxLen, out.length() - filledLength); + memcpy(buffer, out.c_str() + filledLength, len); + + AWS_LOGDEBUG1("Bytes sent in chunk =", len); + + return len; + }); + + request->send(response); +} + + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print("\nStart Async_AdvancedWebServer_SendChunked on "); + Serial.print(BOARD_NAME); + Serial.print(" with "); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/test.svg", HTTP_GET, [](AsyncWebServerRequest * request) + { + drawGraph(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("AsyncWebServer is @ IP : ")); + Serial.println(ETH.localIP()); +} + +void heartBeatPrint() +{ + static int num = 1; + + Serial.print(F(".")); + + if (num == 80) + { + Serial.println(); + num = 1; + } + else if (num++ % 10 == 0) + { + Serial.print(F(" ")); + } +} + +void check_status() +{ + static unsigned long checkstatus_timeout = 0; + +#define STATUS_CHECK_INTERVAL 10000L + + // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. + if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) + { + heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; + } +} + +void loop() +{ + check_status(); +} diff --git a/examples/Async_HelloServer/Async_HelloServer.ino b/examples/Async_HelloServer/Async_HelloServer.ino new file mode 100644 index 0000000..2ba8cc4 --- /dev/null +++ b/examples/Async_HelloServer/Async_HelloServer.ino @@ -0,0 +1,167 @@ +/**************************************************************************************************************************** + Async_HelloServer.h + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +void handleRoot(AsyncWebServerRequest *request) +{ + request->send(200, "text/plain", String("Hello from Async_HelloServer on ") + BOARD_NAME ); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + //message += server.uri(); + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart Async_HelloServer on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("HTTP EthernetWebServer is @ IP : ")); + Serial.println(ETH.localIP()); +} + +void loop() +{ +} diff --git a/examples/Async_HelloServer2/Async_HelloServer2.ino b/examples/Async_HelloServer2/Async_HelloServer2.ino new file mode 100644 index 0000000..3dd03aa --- /dev/null +++ b/examples/Async_HelloServer2/Async_HelloServer2.ino @@ -0,0 +1,190 @@ +/**************************************************************************************************************************** + Async_HelloServer2.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +void handleRoot(AsyncWebServerRequest *request) +{ + request->send(200, "text/plain", String("Hello from Async_HelloServer2 on ") + BOARD_NAME ); +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + String message = "File Not Found\n\n"; + + message += "URI: "; + //message += server.uri(); + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart Async_HelloServer2 on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + server.on("/inline", [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "This works as well"); + }); + + server.on("/gif", [](AsyncWebServerRequest * request) + { + static const uint8_t gif[] = + { + 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80, 0x01, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x10, 0x00, 0x00, 0x02, 0x19, 0x8c, 0x8f, 0xa9, 0xcb, 0x9d, + 0x00, 0x5f, 0x74, 0xb4, 0x56, 0xb0, 0xb0, 0xd2, 0xf2, 0x35, 0x1e, 0x4c, + 0x0c, 0x24, 0x5a, 0xe6, 0x89, 0xa6, 0x4d, 0x01, 0x00, 0x3b + }; + + char gif_colored[sizeof(gif)]; + + memcpy(gif_colored, gif, sizeof(gif)); + + // Set the background to a random set of colors + gif_colored[16] = millis() % 256; + gif_colored[17] = millis() % 256; + gif_colored[18] = millis() % 256; + + request->send(200, (char *) "image/gif", gif_colored); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print("HTTP EthernetWebServer started @ IP : "); + Serial.println(ETH.localIP()); +} + +void loop() +{ +} diff --git a/examples/Async_PostServer/Async_PostServer.ino b/examples/Async_PostServer/Async_PostServer.ino new file mode 100644 index 0000000..26d6d81 --- /dev/null +++ b/examples/Async_PostServer/Async_PostServer.ino @@ -0,0 +1,242 @@ +/**************************************************************************************************************************** + Async_PostServer.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#if !( defined(ESP32) ) + #error This code is designed for (ESP32 + ENC28J60) to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +const int led = 2; + +const String postForms = + "\ +\ +AsyncWebServer POST handling\ +\ +\ +\ +

POST plain text to /postplain/


\ +
\ +
\ +\ +
\ +

POST form data to /postform/


\ +
\ +
\ +\ +
\ +\ +"; + +void handleRoot(AsyncWebServerRequest *request) +{ + digitalWrite(led, 1); + request->send(200, "text/html", postForms); + digitalWrite(led, 0); +} + +void handlePlain(AsyncWebServerRequest *request) +{ + if (request->method() != HTTP_POST) + { + digitalWrite(led, 1); + request->send(405, "text/plain", "Method Not Allowed"); + digitalWrite(led, 0); + } + else + { + digitalWrite(led, 1); + request->send(200, "text/plain", "POST body was:\n" + request->arg("plain")); + digitalWrite(led, 0); + } +} + +void handleForm(AsyncWebServerRequest *request) +{ + if (request->method() != HTTP_POST) + { + digitalWrite(led, 1); + request->send(405, "text/plain", "Method Not Allowed"); + digitalWrite(led, 0); + } + else + { + digitalWrite(led, 1); + String message = "POST form was:\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(200, "text/plain", message); + digitalWrite(led, 0); + } +} + +void handleNotFound(AsyncWebServerRequest *request) +{ + digitalWrite(led, 1); + String message = "File Not Found\n\n"; + message += "URI: "; + message += request->url(); + message += "\nMethod: "; + message += (request->method() == HTTP_GET) ? "GET" : "POST"; + message += "\nArguments: "; + message += request->args(); + message += "\n"; + + for (uint8_t i = 0; i < request->args(); i++) + { + message += " " + request->argName(i) + ": " + request->arg(i) + "\n"; + } + + request->send(404, "text/plain", message); + digitalWrite(led, 0); +} + +void setup() +{ + pinMode(led, OUTPUT); + digitalWrite(led, 0); + + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(200); + + Serial.print(F("\nStart Async_PostServer on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + handleRoot(request); + }); + + //server.on("/postplain/", handlePlain); + server.on("/postplain/", HTTP_POST, [](AsyncWebServerRequest * request) + { + handlePlain(request); + }); + + //server.on("/postform/", handleForm); + server.on("/postform/", HTTP_POST, [](AsyncWebServerRequest * request) + { + handleForm(request); + }); + + server.onNotFound(handleNotFound); + + server.begin(); + + Serial.print(F("HTTP EthernetWebServer started @ IP : ")); + Serial.println(ETH.localIP()); +} + +void loop() +{ +} diff --git a/examples/Async_RegexPatterns_ESP32_ENC/Async_RegexPatterns_ESP32_ENC.ino b/examples/Async_RegexPatterns_ESP32_ENC/Async_RegexPatterns_ESP32_ENC.ino new file mode 100644 index 0000000..90b6392 --- /dev/null +++ b/examples/Async_RegexPatterns_ESP32_ENC/Async_RegexPatterns_ESP32_ENC.ino @@ -0,0 +1,174 @@ +/**************************************************************************************************************************** + Async_RegexPatterns_ESP32_ENC.ino + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ +// +// A simple server implementation with regex routes: +// * serve static messages +// * read GET and POST parameters +// * handle missing pages / 404s +// +// Add buildflag ASYNCWEBSERVER_REGEX to enable the regex support +// +// For platformio: platformio.ini: +// build_flags = +// -DASYNCWEBSERVER_REGEX +// +// For arduino IDE: create/update platform.local.txt +// Windows: C:\Users\(username)\AppData\Local\Arduino15\packages\espxxxx\hardware\espxxxx\{version}\platform.local.txt +// Linux: ~/.arduino15/packages/espxxxx/hardware/espxxxx/{version}/platform.local.txt +// +// compiler.cpp.extra_flags=-DASYNCWEBSERVER_REGEX=1 + +#define ASYNCWEBSERVER_REGEX true + +#if !( defined(ESP32) ) + #error This code is designed for ESP32_ENC to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +#include + +#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); + +#include + +#include + +// Optional values to override default settings +//#define SPI_HOST 1 +//#define SPI_CLOCK_MHZ 8 + +// 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 +// Optional values to override default settings + +AsyncWebServer server(80); + +const char* PARAM_MESSAGE = "message"; + +void notFound(AsyncWebServerRequest *request) +{ + request->send(404, "text/plain", "Not found"); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + Serial.print(F("\nStart Async_RegexPatterns_ESP32_ENC on ")); + Serial.print(BOARD_NAME); + Serial.print(F(" with ")); + Serial.println(SHIELD_TYPE); + Serial.println(ASYNC_WEBSERVER_ESP32_ENC_VERSION); + + AWS_LOGWARN(F("Default SPI pinout:")); + 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_ENC_onEvent(); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_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 *ENC28J60_Mac = ENC28J60_Default_Mac); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + + // 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_ENC_waitForConnect(); + + /////////////////////////////////// + + server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) + { + request->send(200, "text/plain", "Hello, world from Async_RegexPatterns_ESP32_ENC on " + String(BOARD_NAME)); + }); + + // Send a GET request to /sensor/ + server.on("^\\/sensor\\/([0-9]+)$", HTTP_GET, [] (AsyncWebServerRequest * request) + { + String sensorNumber = request->pathArg(0); + request->send(200, "text/plain", "Hello, sensor: " + sensorNumber); + }); + + // Send a GET request to /sensor//action/ + server.on("^\\/sensor\\/([0-9]+)\\/action\\/([a-zA-Z0-9]+)$", HTTP_GET, [] (AsyncWebServerRequest * request) + { + String sensorNumber = request->pathArg(0); + String action = request->pathArg(1); + request->send(200, "text/plain", "Hello, sensor: " + sensorNumber + ", with action: " + action); + }); + + server.onNotFound(notFound); + + server.begin(); + + Serial.print("Server started @ "); + Serial.println(ETH.localIP()); +} + +void loop() +{ +} diff --git a/keywords.txt b/keywords.txt new file mode 100644 index 0000000..7bb5dd4 --- /dev/null +++ b/keywords.txt @@ -0,0 +1,530 @@ +############################################### +# Syntax Coloring Map For AsyncWebServer_STM32 +############################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +ESP32_ENC KEYWORD1 + +AsyncWebServer KEYWORD1 +AsyncWebServerRequest KEYWORD1 +AsyncWebServerResponse KEYWORD1 +AsyncWebHeader KEYWORD1 +AsyncWebParameter KEYWORD1 +AsyncWebRewrite KEYWORD1 +AsyncWebHandler KEYWORD1 +AsyncStaticWebHandler KEYWORD1 +AsyncCallbackWebHandler KEYWORD1 +AsyncResponseStream KEYWORD1 + +AsyncWebSocketMessageBuffer +AsyncWebSocketMessage +AsyncWebSocketBasicMessage +AsyncWebSocketMultiMessage +AsyncWebSocket KEYWORD1 +AsyncWebSocketResponse KEYWORD1 +AsyncWebSocketClient KEYWORD1 +AsyncWebSocketControl KEYWORD1 + +AsyncEventSourceMessage KEYWORD1 +AsyncEventSourceClient KEYWORD1 +AsyncEventSource KEYWORD1 +AsyncEventSourceResponse KEYWORD1 +ChunkPrint KEYWORD1 + +AsyncJsonResponse KEYWORD1 +PrettyAsyncJsonResponse KEYWORD1 +AsyncCallbackJsonWebHandler KEYWORD1 + +AsyncBasicResponse KEYWORD1 +AsyncAbstractResponse KEYWORD1 +AsyncStreamResponse KEYWORD1 +AsyncCallbackResponse KEYWORD1 +AsyncChunkedResponse KEYWORD1 +AsyncResponseStream KEYWORD1 + +AsyncWebLock KEYWORD1 +AsyncWebLockGuard KEYWORD1 + +LinkedListNode KEYWORD1 +LinkedList KEYWORD1 +StringArray KEYWORD1 + +WebRequestMethod KEYWORD1 +WebRequestMethodComposite KEYWORD1 +ArDisconnectHandler KEYWORD1 + +RequestedConnectionType KEYWORD1 +AwsResponseFiller KEYWORD1 +AwsTemplateProcessor KEYWORD1 +ArRequestFilterFunction KEYWORD1 + +WebResponseState KEYWORD1 +ArRequestHandlerFunction KEYWORD1 +ArUploadHandlerFunction KEYWORD1 +ArBodyHandlerFunction KEYWORD1 + +ArJsonRequestHandlerFunction KEYWORD1 + +AwsFrameInfo KEYWORD1 +AwsClientStatus KEYWORD1 +AwsFrameType KEYWORD1 +AwsMessageStatus KEYWORD1 +AwsEventType KEYWORD1 +AwsEventHandler KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +################### +# AsyncWebParameter +################### + +name KEYWORD2 +value KEYWORD2 +size KEYWORD2 +isPost KEYWORD2 +isFile KEYWORD2 + +################### +# AsyncWebHeader +################### + +name KEYWORD2 +value KEYWORD2 +toString KEYWORD2 + +######################## +# AsyncWebServerRequest +######################## + +client KEYWORD2 +version KEYWORD2 +method KEYWORD2 +url KEYWORD2 +host KEYWORD2 +contentType KEYWORD2 +contentLength KEYWORD2 +multipart KEYWORD2 +methodToString KEYWORD2 +requestedConnType KEYWORD2 +isExpectedRequestedConnType KEYWORD2 +onDisconnect KEYWORD2 +authenticate KEYWORD2 +requestAuthentication KEYWORD2 +setHandler KEYWORD2 +addInterestingHeader KEYWORD2 +redirect KEYWORD2 +send KEYWORD2 +sendChunked KEYWORD2 +beginResponse KEYWORD2 +beginChunkedResponse KEYWORD2 +beginResponseStream KEYWORD2 +headers KEYWORD2 +hasHeader KEYWORD2 +getHeader KEYWORD2 +params KEYWORD2 +hasParam KEYWORD2 +getParam KEYWORD2 +arg KEYWORD2 +argName KEYWORD2 +hasArg KEYWORD2 +header KEYWORD2 +headerName KEYWORD2 +urlDecode KEYWORD2 + +################### +# AsyncWebRewrite +################### + +filter KEYWORD2 +from KEYWORD2 +toUrl KEYWORD2 +params KEYWORD2 +match KEYWORD2 + +######################## +# AsyncWebHandler +######################## + +setFilter KEYWORD2 +setAuthentication KEYWORD2 +filter KEYWORD2 +canHandle KEYWORD2 +handleRequest KEYWORD2 +handleUpload KEYWORD2 +handleBody KEYWORD2 +isRequestHandlerTrivial KEYWORD2 + +######################### +# AsyncWebServerResponse +######################### + +setCode KEYWORD2 +setContentLength KEYWORD2 +setContentType KEYWORD2 +addHeader KEYWORD2 +_assembleHead KEYWORD2 +_started KEYWORD2 +_finished KEYWORD2 +_failed KEYWORD2 +_sourceValid KEYWORD2 +_respond KEYWORD2 +_ack KEYWORD2 + +######################### +# AsyncWebServer +######################### + +begin KEYWORD2 +end KEYWORD2 +addRewrite KEYWORD2 +removeRewrite KEYWORD2 +addHandler KEYWORD2 +removeHandler KEYWORD2 +on KEYWORD2 +onNotFound KEYWORD2 +onRequestBody KEYWORD2 +reset KEYWORD2 +_handleDisconnect KEYWORD2 +_attachHandler KEYWORD2 +_rewriteRequest KEYWORD2 + +######################### +# DefaultHeaders +######################### + +addHeader KEYWORD2 +end KEYWORD2 +begin KEYWORD2 +Instance KEYWORD2 + +######################### +# AsyncEventSourceMessage +######################### + +ack KEYWORD2 +send KEYWORD2 +finished KEYWORD2 +sent KEYWORD2 + +######################### +# AsyncEventSourceClient +######################### + +client KEYWORD2 +close KEYWORD2 +write KEYWORD2 +send KEYWORD2 +connected KEYWORD2 +lastId KEYWORD2 +packetsWaiting KEYWORD2 +_onAck KEYWORD2 +_onPoll KEYWORD2 +_onTimeout KEYWORD2 +_onDisconnect KEYWORD2 + +########################### +# AsyncEventSource +########################### + +url KEYWORD2 +close KEYWORD2 +onConnect KEYWORD2 +send KEYWORD2 +count KEYWORD2 +avgPacketsWaiting KEYWORD2 +_addClient KEYWORD2 +_handleDisconnect KEYWORD2 +canHandle KEYWORD2 +handleRequest KEYWORD2 + +########################### +# AsyncEventSourceResponse +########################### + +_respond KEYWORD2 +_ack KEYWORD2 +_sourceValid KEYWORD2 + +########################### +# ChunkPrint +########################### + +write KEYWORD2 + +########################### +# AsyncJsonResponse +########################### + +getRoot KEYWORD2 +_sourceValid KEYWORD2 +setLength KEYWORD2 +getSize KEYWORD2 +_fillBuffer KEYWORD2 + +########################### +# PrettyAsyncJsonResponse +########################### + +setLength KEYWORD2 +_fillBuffer KEYWORD2 + +############################## +# AsyncCallbackJsonWebHandler +############################## + +setMethod KEYWORD2 +setMaxContentLength KEYWORD2 + +onRequest KEYWORD2 +canHandle KEYWORD2 +handleRequest KEYWORD2 +handleUpload KEYWORD2 +handleBody KEYWORD2 +isRequestHandlerTrivial KEYWORD2 + +########################### +# AsyncStaticWebHandler +########################### + +canHandle KEYWORD2 +handleRequest KEYWORD2 +setIsDir KEYWORD2 +setCacheControl KEYWORD2 +setLastModified KEYWORD2 +setTemplateProcessor KEYWORD2 + +############################## +# AsyncCallbackWebHandler +############################## + +setUri KEYWORD2 +setMethod KEYWORD2 +onRequest KEYWORD2 +onUpload KEYWORD2 +onBody KEYWORD2 +canHandle KEYWORD2 +handleRequest KEYWORD2 +handleBody KEYWORD2 +isRequestHandlerTrivial KEYWORD2 + +############################## +# AsyncBasicResponse +############################## + +_respond KEYWORD2 +_ack KEYWORD2 +_sourceValid KEYWORD2 + +############################## +# AsyncAbstractResponse +############################## + +_respond KEYWORD2 +_ack KEYWORD2 +_sourceValid KEYWORD2 +_fillBuffer KEYWORD2 + +############################## +# AsyncStreamResponse +############################## + +_sourceValid KEYWORD2 +_fillBuffer KEYWORD2 + +############################## +# AsyncCallbackResponse +############################## + +_sourceValid KEYWORD2 +_fillBuffer KEYWORD2 + +############################## +# AsyncChunkedResponse +############################## + +_sourceValid KEYWORD2 +_fillBuffer KEYWORD2 + +############################## +# AsyncResponseStream +############################## + +_sourceValid KEYWORD2 +_fillBuffer KEYWORD2 +write KEYWORD2 + +############################## +# AsyncWebSocketMessage +############################## + +ack KEYWORD2 +send KEYWORD2 +finished KEYWORD2 +betweenFrames KEYWORD2 + +############################## +# AsyncWebSocketBasicMessage +############################## + +ack KEYWORD2 +send KEYWORD2 +betweenFrames KEYWORD2 + +############################## +# AsyncWebSocketMultiMessage +############################## + +ack KEYWORD2 +send KEYWORD2 +betweenFrames KEYWORD2 + +############################## +# AsyncWebSocketClient +############################## + +id KEYWORD2 +status KEYWORD2 +client KEYWORD2 +server KEYWORD2 +pinfo KEYWORD2 +remoteIP KEYWORD2 +remotePort KEYWORD2 +close KEYWORD2 +ping KEYWORD2 +keepAlivePeriod KEYWORD2 +message KEYWORD2 +queueIsFull KEYWORD2 +printf KEYWORD2 +text KEYWORD2 +binary KEYWORD2 +canSend KEYWORD2 +_onAck KEYWORD2 +_onError KEYWORD2 +_onPoll KEYWORD2 +_onTimeout KEYWORD2 +_onDisconnect KEYWORD2 +_onData KEYWORD2 + +############################## +# AsyncWebSocket +############################## + +url KEYWORD2 +enable KEYWORD2 +enabled KEYWORD2 +availableForWriteAll KEYWORD2 +availableForWrite KEYWORD2 +count KEYWORD2 +client KEYWORD2 +hasClient KEYWORD2 +close KEYWORD2 +closeAll KEYWORD2 +cleanupClients KEYWORD2 + +ping KEYWORD2 +pingAll KEYWORD2 +text KEYWORD2 +textAll KEYWORD2 +binary KEYWORD2 +binaryAll KEYWORD2 +message KEYWORD2 +messageAll KEYWORD2 +printf KEYWORD2 +printfAll KEYWORD2 +onEvent KEYWORD2 +_getNextId KEYWORD2 +_addClient KEYWORD2 +_handleDisconnect KEYWORD2 +_handleEvent KEYWORD2 +canHandle KEYWORD2 +handleRequest KEYWORD2 +makeBuffer KEYWORD2 +_cleanBuffers KEYWORD2 +getClients KEYWORD2 + +############################## +# AsyncWebSocketResponse +############################## + +_respond KEYWORD2 +_ack KEYWORD2 +_sourceValid KEYWORD2 + +############################## +# AsyncWebLock +############################## + +lock KEYWORD2 +unlock KEYWORD2 + +############################## +# LinkedListNode +############################## + +value KEYWORD2 + +############################## +# LinkedList +############################## + +begin KEYWORD2 +end KEYWORD2 +add KEYWORD2 +front KEYWORD2 +isEmpty KEYWORD2 +length KEYWORD2 +count_if KEYWORD2 +nth KEYWORD2 +remove KEYWORD2 +remove_first KEYWORD2 +free KEYWORD2 + +############################## +# StringArray +############################## + +containsIgnoreCase KEYWORD2 + +############################## +# General +############################## + +memchr KEYWORD2 +webSocketSendFrameWindow KEYWORD2 +webSocketSendFrame KEYWORD2 +generateEventMessage KEYWORD2 + +############################## +# ESP32_ENC +############################## + +begin KEYWORD2 +config KEYWORD2 +getHostname KEYWORD2 +setHostname KEYWORD2 +fullDuplex KEYWORD2 +linkUp KEYWORD2 +linkSpeed KEYWORD2 +enableIpV6 KEYWORD2 +localIPv6 KEYWORD2 +localIP KEYWORD2 +subnetMask KEYWORD2 +gatewayIP KEYWORD2 +dnsIP KEYWORD2 +broadcastIP KEYWORD2 +networkID KEYWORD2 +subnetCIDR KEYWORD2 +macAddress KEYWORD2 +macAddress KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + +# LITERAL1 +ENC28J60_Default_Mac LITERAL1 diff --git a/library.json b/library.json new file mode 100644 index 0000000..af928c6 --- /dev/null +++ b/library.json @@ -0,0 +1,38 @@ +{ + "name":"AsyncWebServer_ESP32_ENC", + "version": "1.6.2", + "description":"Asynchronous HTTP and WebSocket Server Library for (ESP32 + ENC28J60). Now supporting using CString to save heap to send very large data and with examples to demo how to use beginChunkedResponse() to send large html in chunks", + "keywords":"http, async, async-webserver, websocket, webserver, esp32, enc28j60", + "authors": + [ + { + "name": "Hristo Gochkov", + "url": "https://github.com/me-no-dev" + }, + { + "name": "Khoi Hoang", + "url": "https://github.com/khoih-prog", + "email": "khoih.prog@gmail.com", + "maintainer": true + } + ], + "repository": + { + "type": "git", + "url": "https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC" + }, + "license": "LGPL-3.0", + "frameworks": "arduino", + "dependencies": + [ + { + "owner": "me-no-dev", + "name": "AsyncTCP", + "version": "^1.1.1", + "platforms": "espressif32" + } + ], + "platforms": ["espressif32"], + "examples": "examples/*/*/*.ino", + "headers": "AsyncWebServer_ESP32_ENC.h" +} diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..12a9ed6 --- /dev/null +++ b/library.properties @@ -0,0 +1,12 @@ +name=AsyncWebServer_ESP32_ENC +version=1.6.2 +author=Hristo Gochkov,Khoi Hoang +maintainer=Khoi Hoang +license=GPLv3 +sentence=AsyncWebServer for (ESP32 + ENC28J60) +paragraph=This is Asynchronous HTTP and WebSocket Server Library for (ESP32 + ENC28J60). Now supporting using CString to save heap to send very large data and with examples to demo how to use beginChunkedResponse() to send large html in chunks +category=Communication +url=https://github.com/khoih-prog/AsyncWebServer_ESP32_ENC +architectures=esp32 +depends=AsyncTCP +includes=AsyncWebServer_ESP32_ENC.h diff --git a/pics/AsyncMultiWebServer_ESP32_ENC_SVR1.png b/pics/AsyncMultiWebServer_ESP32_ENC_SVR1.png new file mode 100644 index 0000000000000000000000000000000000000000..8e5d3179a9ffbaefde31377a96e4a0df5e50e64b GIT binary patch literal 31808 zcmbTdbx<5_@GiQzCTOr=!3hL+hakb--QC^YEx3DdcXxMp4X#UYhdbY|>fEYZbx+l) zGykx&?7lN^PxsT^&(j+&CnNR=5f2dr0(}zyC9D7fK|+B*5Pa~Ez&kmOL15qyl%tTi z5^&a*tVFjSvE zh=hJYl4(gLl934K`fKEyH9%f0l~^}?q5ZNBV};aNx*5?J&>pdw(^5Ioq*vK?r_gNB z4s&lQPqSiB!PbDNlP)1`@hvhn7adiB4&k?y(Bm5;Duq`6Pp+Q6XyX_?U zO=ej!;c@>a|L;@&%8(161&C3@;PBCzARzq(h{=I7cxVMk;KKquJ-^}JpZ=Q9XQM}Y zd;NE8Y;4ALqCU`0N=qv%D_b-^HwY`-uiK6g!w0=_OnAOtz595+MYAV&|AVYU+wI!x z=Hv|JdqG}>@W&}d_v-L;)ssVILfz#ntf;WkHXx~kg49Qe;UUV|^4!Bf7e>M&J|hO} zs?lO`aA>_9U>hMq8^}E$Gx~&0$7K zsSn8n3CW26KRX_Pf^pv$XJKO}8haKh>wc64+E6aEkM z+gOjPShtIvof_WN?R;dmgPon+`{i>?>;uTJwezjKKo_bf*TC-IPOoKC`M^Xv>)GHJ z8c=Rg(c!vncW0ggZnUT@N^Gf*4?WLEM_^!oTy;7i??(WWrX?1*@#tFR9>UeaY0+%rA zbh=PVQ&?D8S*bgSIpP||yXInRn{vOa@wLN3<3b3_Y%xF6!GsxF6wgqUPa_4Y!5 z((%4hN~dFXTBQ{h{48I5ms4uE*^6E7zL^>b$6ze5pE_UF(a`~R216+em~i0rY1*Wo z^YVDse7@*MD*wkrNJ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MU9T=1uERNxCI zrqq~NLq*uX33+gVG)Oz${jE*g?2J>pCr9kW^?bL7MGcNXrDKDV^%|Z{Q@Wz+X)FLiJt``ycwy-}8^@X%zLcHeT~b-2 zhR@LslsAv&8+gaVpg2OW!n2X1jZ)c z4j!t@Xty7}b1AlH35MxNa(PV%t!Z!OyGUr%B#_$le`SrbR~W{v>C!*K`>1{tN_EDU z&8$b}D~;97Lv^bZGTP^b35C%FXnteroYKT+IR|E@l{kN&t3rt+6rhbC<3 z6c^Xd9qNEu)wVhXM_5Of`d$r{txaFx7(FxTy1R9e`yvp@E3^wX;FZ*KafG|0+(}#q z7A{8nGb7#MYy5qClxA#ZStqS4Tz%iX`b{JxpcGz3HYD6$1B_B*aCgboc)JE6UtY7_R3E9|HtOr zF}?i$!EC?J68|?){U3AqzoGj73f=!3=m+uMz1ZL^2Ip))y&m}m0AfPYg5^JS{Qd_V C#ccHe literal 0 HcmV?d00001 diff --git a/pics/AsyncWebServer_SendChunked.png b/pics/AsyncWebServer_SendChunked.png new file mode 100644 index 0000000000000000000000000000000000000000..4150b657b2c668ceb1ec9ddbe3e1fa74ddaef3ff GIT binary patch literal 63916 zcmdSAbx>T(*Dg##5)vQ~AOweGu;9TRk}$#DodkD>!6$?e1`j$o!F>qMFt|HG2AAOO zF2j7B_ne&HeZQ(t>i%)--d($DrnmI&Uj6LuwV(B@U}Z(Ar`Y7!7#J8&Wu$?s7#LWL z7#R27JidQ-B-(Jx{q6_T<-Lsh76+RWeTlE@tXx=XB?9%CXIkH(=JyyB@>4#R{^yVI!C1D*K8fV z`Ky6eQ%s!%+aFs@2dy3^L4%p#T=CZcoq=c6(i72G zxuekO2X*STW?|FsPg%$AADUB0DROZyD0zOW(w)mwqFFhDjy4@T7=cl|_wE||_x3iN z^w+~b1q=+{uVcjjmVU&4uluXBe{W-is#<^kV|>+ylp=05yzE591iU#l0e}j0$;GdX&As-j=L7`He!D|iT}5>V zPPONuESa}ogs&0F0U8c3{K&6H&s72;-SZ&xx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MbrQXazAu5C{{JV$LY1;61$F#K}Vp&bzAFe^LjOE*cNbt{{7PS;c={H~{DvP)9 zBNvytvaBx+I$=f=WO)f2IJxsc6luSeEu5%5_B@8ve;FUbuyg+*Ytp+l1g_Al%f&|-0{d|h}UdYp22OxkFB-@BUh{@_4HrJ>wtuAl|t zR|Z;Mijm#PN(qp?vrww69pM}ohD-|bzt;kYQzbdJEedLeM{nXW;s!Z<$dVEzmL`>v zFuk$HxI>|WS^r~6^!aD_q=_u;?@1-~-q-S^m~tMIh|$-&GWs48x>_IGy`HGS@N!C% zEzy!WGSC8E*BvDPNtg!ZY`2q&u_Fpu9`Jx$oRHDC23HM9gr@{ z=)$AOjnuxqyRi<&bx@gZSdn5H{ME%&9}$tt8ugiP5-_~mHytRp9HuD@EoN`Jz?3Eh zpAfX=$D>lacP96~#e7=I8XG6qS#9mF&uqvMj4g}d6~sSXnDm;SW0k9CsGz7 z<`LV#p%=z7yL8LlB846T*Dt4usqcEQ1A-1x;?n>8?tKTfgv#BdXT#~D?X}WzT+HBH zg!B_oeT!$2>mhk>YRcY$u7Uv>SYvwUVE;%PiPxJCu8S1AGiwAA12 zg&Xt$;K09c>p$OnApleS`>2fAP4Me~J=A}`+wOp_@b9BMo)&|X{OhP!FI<`abE3b0 zaUq=LL=wtjRe*Z>??a6Uktqg#@>+raK64Po@?)ugANhZMYCM4Q|9ydC_a~D6*ZElf gA3u-(-!JO&hQYNT@qqu4CItM+%PPyjpBe`J4`p%JVgLXD literal 0 HcmV?d00001 diff --git a/pics/Async_AdvancedWebServer.png b/pics/Async_AdvancedWebServer.png new file mode 100644 index 0000000000000000000000000000000000000000..ff221d22df67ef659a5d3d48d4cba3616a03bad0 GIT binary patch literal 20711 zcmbTe1#BHb(=9m0nC+OE9WygyjIkXvGcz+?L(I&~5HmAl9AnJPF*CEX_xs;ISUtU! zc3Zl-n$f7IyJosh)v41H@m)a*837*w003keX$fTjfba$XzQ93(&s@ZJA%Xv(T*PEl z;o#ubb`-b4h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VtIZb!pam6nSFJ^Cy}WUoS?FEpB4LkkLA?^-UkF4nvIx&*2@7R(jHNQjGB%F z=0Qi+C^s?ZZzM&QgSYRxJq4%?*nv$s5a{mOBxu}IaP&sd+fQXioR--Yz%jG;E$VM= z7!cijF&>`e_Es;gSDcX(dRYeT*33@k#b?l#{?+madx%Z2N&-qZeH@ejz>=GJQS_5g zO-0Nvuz9Pvd;qe4o5!BdNYHbENA@q9m^Opwe(u6DrW;p*yvI9$(^Su5f?7|q?*AqT z(WcApYLd}2f$5Zourx-?w84{zDL}Rq6<+Q?j0&BktDbvBA?k_ zY$^we0OYJodxQ?S*=Vp5OOK5wc*yQBszzzgZ3B`-naLkB2v@MO1_4W-*&bWR z*(ccJWm9=}`+$wro>k^OEEljDU)KF*b-Wu9QE*JUGbGQQU8g>i+(^R*8qN%D)-bvO z5t6@QI^f{lUG4qZHhf}p<~a_gVHe)D$X#@a1LB)~$mgsnnpaG`86e6un&VIOxL@G( z+lcy^H&ITI4SKvPd#BQh{^#pNY;iIS5;@WscKU~gu4|{EchA>X$wtJskK=u*PZ6@S6n3hr=cIrc zw`jHgz4;Bsy0cw`dH5Ur8l!4ysBC_lJyaj|iP)?e*%}d}eGGg}A%9dQ=&paz-25S@ zdd)C6>>%{OGOupr6{6)K@#efM^3cIYaYTvS8J@)@g+<(pO3P=}sr`fMA-V+}v^a7}pLXn%^zmA!{l-$#_^x)^F z(GT?B54F+pa-&JBoX`%D5n?RHLa%hLeh;i4iqLzbGxJzbWx`y!M4m&@lv|$wVH`LD z`}fa?`v@$u_Q87b-~(0trf@Zx^$=XsD(^oAM*q)z-ws^-$2_7Qa>m%olUQgK2?0Md MV@sn_1J~&P0DlOK6951J literal 0 HcmV?d00001 diff --git a/pics/Async_AdvancedWebServer_MemoryIssues_Send_CString.png b/pics/Async_AdvancedWebServer_MemoryIssues_Send_CString.png new file mode 100644 index 0000000000000000000000000000000000000000..70783965e82db2024f13ba16d710c16ca10d1e99 GIT binary patch literal 56382 zcmd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;Xv===OB^H4qgE~~dHw@nJj5uli?0x+a-)vN?GG) z_Fj)}TvcdouR##Y(7DtYN?BWZLuMoBkzYQJP#}+~<;gq}l_B_$9X#@6w!YZEa^`OB zSIgSUCHw&FrD-4ya2eqp#DapTsQ zc`&)n1#3wo>y;VrQ1KUMlpQXlDWOv0$=@X$2ZcDVMoXKe#exaVHHDs{S{Ym zg!4L}!5KDN#y?P^Jj}|`fOyewr!ZPUWZ|tATuG*L-^l65wx%X20x*6s*~`1IhargI zv@-S+F0TNr95|GgY{Jhb0}bDiwsF?kATq>7>^+Ot4-xa6@VwmY4Yb9h2*E;EEt*ae?Iz zr9Ot@e6GttrTg)QZ10|Zq+-wocWlf+BEz3=hTpP0FhF8aYK=;5AV)}+! zgx^)sQ(YBzmygZ~A_u9_j zk7bz12ADy6N~|02H3PDYTB6)AcJn;2mM{^rM`LA;3wB*mX-b^0v$i_^ z51-2*&Jvlo9#re&Bq}tE6fivi-_7Nzn!AV7U?x$I=n|PhGkhmc=gc-K+_@4q%nd

bs7By7f>S_5M%x!Jm>wL5v9<02n`& zxL4utPHBxjDoy!xYGO)}^`8p#cf$v&GzH^P9OwCVHRu^$>(V1}fsx^-`>`%PID|6e ze&M_KEk*?W^fKln#bpH$Af5B|UkKMgazOeCBBm@p)NdO|Nzj{~xnsNoo*&>505$D@ zCO0w8%qGYT>DZ^o%8FQLT;E_7(>EITl<6f?2|^k{VE3)6ZV}^=C)}$)Q%v zY@oI@F!TDAvV)3dbi`FL67`?I?tTzFu#J0yaRh1kzZF80AR*-M=P8E21pli{N9AO8no{%39evx3PV Yd-P{uvEI2O_+7z`F{WsWo@?|!0845(i~s-t literal 0 HcmV?d00001 diff --git a/platformio/platformio.ini b/platformio/platformio.ini new file mode 100644 index 0000000..ec74c99 --- /dev/null +++ b/platformio/platformio.ini @@ -0,0 +1,88 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +; ============================================================ +; chose environment: +; ESP8266 +; ESP32 +; SAMD +; NRF52 +; STM32 +; ============================================================ +default_envs = ESP32 + +[env] +; ============================================================ +; Serial configuration +; choose upload speed, serial-monitor speed +; ============================================================ +upload_speed = 921600 +;upload_port = COM11 +;monitor_speed = 9600 +;monitor_port = COM11 + +; Checks for the compatibility with frameworks and dev/platforms +lib_compat_mode = strict + +lib_deps = +; PlatformIO 4.x +; AsyncTCP@~1.1.1 + +; PlatformIO 5.x + me-no-dev/AsyncTCP@~1.1.1 + +build_flags = +; set your build_flags + +[env:ESP32] +platform = espressif32 +framework = arduino +; ============================================================ +; Board configuration +; choose your board by uncommenting one of the following lines +; ============================================================ +;board = esp32cam +;board = alksesp32 +;board = featheresp32 +;board = espea32 +;board = bpi-bit +;board = d-duino-32 +board = esp32doit-devkit-v1 +;board = pocket_32 +;board = fm-devkit +;board = pico32 +;board = esp32-evb +;board = esp32-gateway +;board = esp32-pro +;board = esp32-poe +;board = oroca_edubot +;board = onehorse32dev +;board = lopy +;board = lopy4 +;board = wesp32 +;board = esp32thing +;board = sparkfun_lora_gateway_1-channel +;board = ttgo-lora32-v1 +;board = ttgo-t-beam +;board = turta_iot_node +;board = lolin_d32 +;board = lolin_d32_pro +;board = lolin32 +;board = wemosbat +;board = widora-air +;board = xinabox_cw02 +;board = iotbusio +;board = iotbusproteus +;board = nina_w10 + +; ============================================================ +; Board configuration Many more Boards to be filled +; ============================================================ diff --git a/src/AsyncEventSource.cpp b/src/AsyncEventSource.cpp new file mode 100644 index 0000000..5f32dbb --- /dev/null +++ b/src/AsyncEventSource.cpp @@ -0,0 +1,564 @@ +/**************************************************************************************************************************** + AsyncEventSource.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "Arduino.h" +#include "AsyncEventSource.h" + +///////////////////////////////////////////////// + +static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect) +{ + String ev = ""; + + if (reconnect) + { + ev += "retry: "; + ev += String(reconnect); + ev += "\r\n"; + } + + if (id) + { + ev += "id: "; + ev += String(id); + ev += "\r\n"; + } + + if (event != NULL) + { + ev += "event: "; + ev += String(event); + ev += "\r\n"; + } + + if (message != NULL) + { + size_t messageLen = strlen(message); + char * lineStart = (char *)message; + char * lineEnd; + + do + { + char * nextN = strchr(lineStart, '\n'); + char * nextR = strchr(lineStart, '\r'); + + if (nextN == NULL && nextR == NULL) + { + size_t llen = ((char *)message + messageLen) - lineStart; + char * ldata = (char *)malloc(llen + 1); + + if (ldata != NULL) + { + memcpy(ldata, lineStart, llen); + ldata[llen] = 0; + ev += "data: "; + ev += ldata; + ev += "\r\n\r\n"; + free(ldata); + } + + lineStart = (char *)message + messageLen; + } + else + { + char * nextLine = NULL; + + if (nextN != NULL && nextR != NULL) + { + if (nextR < nextN) + { + lineEnd = nextR; + + if (nextN == (nextR + 1)) + nextLine = nextN + 1; + else + nextLine = nextR + 1; + } + else + { + lineEnd = nextN; + + if (nextR == (nextN + 1)) + nextLine = nextR + 1; + else + nextLine = nextN + 1; + } + } + else if (nextN != NULL) + { + lineEnd = nextN; + nextLine = nextN + 1; + } + else + { + lineEnd = nextR; + nextLine = nextR + 1; + } + + size_t llen = lineEnd - lineStart; + char * ldata = (char *)malloc(llen + 1); + + if (ldata != NULL) + { + memcpy(ldata, lineStart, llen); + ldata[llen] = 0; + ev += "data: "; + ev += ldata; + ev += "\r\n"; + free(ldata); + } + + lineStart = nextLine; + + if (lineStart == ((char *)message + messageLen)) + ev += "\r\n"; + } + } while (lineStart < ((char *)message + messageLen)); + } + + return ev; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +// Message + +AsyncEventSourceMessage::AsyncEventSourceMessage(const char * data, size_t len) + : _data(nullptr), _len(len), _sent(0), _acked(0) +{ + _data = (uint8_t*)malloc(_len + 1); + + if (_data == nullptr) + { + _len = 0; + } + else + { + memcpy(_data, data, len); + _data[_len] = 0; + } +} + +///////////////////////////////////////////////// + +AsyncEventSourceMessage::~AsyncEventSourceMessage() +{ + if (_data != NULL) + free(_data); +} + +///////////////////////////////////////////////// + +size_t AsyncEventSourceMessage::ack(size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + // If the whole message is now acked... + if (_acked + len > _len) + { + // Return the number of extra bytes acked (they will be carried on to the next message) + const size_t extra = _acked + len - _len; + _acked = _len; + return extra; + } + + // Return that no extra bytes left. + _acked += len; + + return 0; +} + +///////////////////////////////////////////////// + +size_t AsyncEventSourceMessage::send(AsyncClient *client) +{ + const size_t len = _len - _sent; + + if (client->space() < len) + { + return 0; + } + + size_t sent = client->add((const char *)_data, len); + + if (client->canSend()) + client->send(); + + _sent += sent; + + return sent; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +// Client + +AsyncEventSourceClient::AsyncEventSourceClient(AsyncWebServerRequest *request, AsyncEventSource *server) + : _messageQueue(LinkedList([](AsyncEventSourceMessage * m) +{ + delete m; +})) +{ + _client = request->client(); + _server = server; + _lastId = 0; + + if (request->hasHeader("Last-Event-ID")) + _lastId = atoi(request->getHeader("Last-Event-ID")->value().c_str()); + + _client->setRxTimeout(0); + _client->onError(NULL, NULL); + + _client->onAck([](void *r, AsyncClient * c, size_t len, uint32_t time) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncEventSourceClient*)(r))->_onAck(len, time); + }, this); + + _client->onPoll([](void *r, AsyncClient * c) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncEventSourceClient*)(r))->_onPoll(); + }, this); + + _client->onData(NULL, NULL); + + _client->onTimeout([this](void *r, AsyncClient * c __attribute__((unused)), uint32_t time) + { + ((AsyncEventSourceClient*)(r))->_onTimeout(time); + }, this); + + _client->onDisconnect([this](void *r, AsyncClient * c) + { + ((AsyncEventSourceClient*)(r))->_onDisconnect(); + delete c; + }, this); + + _server->_addClient(this); + + delete request; +} + +///////////////////////////////////////////////// + +AsyncEventSourceClient::~AsyncEventSourceClient() +{ + _messageQueue.free(); + close(); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::_queueMessage(AsyncEventSourceMessage *dataMessage) +{ + if (dataMessage == NULL) + return; + + if (!connected()) + { + delete dataMessage; + + return; + } + + if (_messageQueue.length() >= SSE_MAX_QUEUED_MESSAGES) + { + AWS_LOGERROR(F("[AsyncEventSourceClient::_queueMessage] ERROR: Too many messages queued")); + + delete dataMessage; + } + else + { + _messageQueue.add(dataMessage); + } + + if (_client->canSend()) + _runQueue(); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::_onAck(size_t len, uint32_t time) +{ + while (len && !_messageQueue.isEmpty()) + { + len = _messageQueue.front()->ack(len, time); + + if (_messageQueue.front()->finished()) + _messageQueue.remove(_messageQueue.front()); + } + + _runQueue(); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::_onPoll() +{ + if (!_messageQueue.isEmpty()) + { + _runQueue(); + } +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::_onTimeout(uint32_t time __attribute__((unused))) +{ + _client->close(true); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::_onDisconnect() +{ + _client = NULL; + _server->_handleDisconnect(this); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::close() +{ + if (_client != NULL) + _client->close(); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::write(const char * message, size_t len) +{ + _queueMessage(new AsyncEventSourceMessage(message, len)); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::send(const char *message, const char *event, uint32_t id, uint32_t reconnect) +{ + String ev = generateEventMessage(message, event, id, reconnect); + _queueMessage(new AsyncEventSourceMessage(ev.c_str(), ev.length())); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceClient::_runQueue() +{ + while (!_messageQueue.isEmpty() && _messageQueue.front()->finished()) + { + _messageQueue.remove(_messageQueue.front()); + } + + for (auto i = _messageQueue.begin(); i != _messageQueue.end(); ++i) + { + if (!(*i)->sent()) + (*i)->send(_client); + } +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +// Handler + +AsyncEventSource::AsyncEventSource(const String& url) + : _url(url) + , _clients(LinkedList([](AsyncEventSourceClient * c) +{ + delete c; +})) +, _connectcb(NULL) +{} + +///////////////////////////////////////////////// + +AsyncEventSource::~AsyncEventSource() +{ + close(); +} + +///////////////////////////////////////////////// + +void AsyncEventSource::onConnect(ArEventHandlerFunction cb) +{ + _connectcb = cb; +} + +///////////////////////////////////////////////// + +void AsyncEventSource::_addClient(AsyncEventSourceClient * client) +{ + /*char * temp = (char *)malloc(2054); + if(temp != NULL){ + memset(temp+1,' ',2048); + temp[0] = ':'; + temp[2049] = '\r'; + temp[2050] = '\n'; + temp[2051] = '\r'; + temp[2052] = '\n'; + temp[2053] = 0; + client->write((const char *)temp, 2053); + free(temp); + }*/ + + _clients.add(client); + + if (_connectcb) + _connectcb(client); +} + +///////////////////////////////////////////////// + +void AsyncEventSource::_handleDisconnect(AsyncEventSourceClient * client) +{ + _clients.remove(client); +} + +///////////////////////////////////////////////// + +void AsyncEventSource::close() +{ + for (const auto &c : _clients) + { + if (c->connected()) + c->close(); + } +} + +///////////////////////////////////////////////// + +// pmb fix +size_t AsyncEventSource::avgPacketsWaiting() const +{ + if (_clients.isEmpty()) + return 0; + + size_t aql = 0; + uint32_t nConnectedClients = 0; + + for (const auto &c : _clients) + { + if (c->connected()) + { + aql += c->packetsWaiting(); + ++nConnectedClients; + } + } + + // return aql / nConnectedClients; + return ((aql) + (nConnectedClients / 2)) / (nConnectedClients); // round up +} + +///////////////////////////////////////////////// + +void AsyncEventSource::send(const char *message, const char *event, uint32_t id, uint32_t reconnect) +{ + String ev = generateEventMessage(message, event, id, reconnect); + + for (const auto &c : _clients) + { + if (c->connected()) + { + c->write(ev.c_str(), ev.length()); + } + } +} + +///////////////////////////////////////////////// + +size_t AsyncEventSource::count() const +{ + return _clients.count_if([](AsyncEventSourceClient * c) + { + return c->connected(); + }); +} + +///////////////////////////////////////////////// + +bool AsyncEventSource::canHandle(AsyncWebServerRequest *request) +{ + if (request->method() != HTTP_GET || !request->url().equals(_url)) + { + return false; + } + + request->addInterestingHeader("Last-Event-ID"); + + return true; +} + +///////////////////////////////////////////////// + +void AsyncEventSource::handleRequest(AsyncWebServerRequest *request) +{ + if ((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str())) + return request->requestAuthentication(); + + request->send(new AsyncEventSourceResponse(this)); +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +// Response + +AsyncEventSourceResponse::AsyncEventSourceResponse(AsyncEventSource *server) +{ + _server = server; + _code = 200; + _contentType = "text/event-stream"; + _sendContentLength = false; + addHeader("Cache-Control", "no-cache"); + addHeader("Connection", "keep-alive"); +} + +///////////////////////////////////////////////// + +void AsyncEventSourceResponse::_respond(AsyncWebServerRequest *request) +{ + String out = _assembleHead(request->version()); + request->client()->write(out.c_str(), _headLength); + _state = RESPONSE_WAIT_ACK; +} + +///////////////////////////////////////////////// + +size_t AsyncEventSourceResponse::_ack(AsyncWebServerRequest *request, size_t len, uint32_t time __attribute__((unused))) +{ + if (len) + { + new AsyncEventSourceClient(request, _server); + } + + return 0; +} diff --git a/src/AsyncEventSource.h b/src/AsyncEventSource.h new file mode 100644 index 0000000..d39b250 --- /dev/null +++ b/src/AsyncEventSource.h @@ -0,0 +1,206 @@ +/**************************************************************************************************************************** + AsyncEventSource.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef ASYNCEVENTSOURCE_H_ +#define ASYNCEVENTSOURCE_H_ + +#include + +#include +#define SSE_MAX_QUEUED_MESSAGES 32 + +#include "AsyncWebServer_ESP32_ENC.h" + +#include "AsyncWebSynchronization.h" + +///////////////////////////////////////////////// + +#define DEFAULT_MAX_SSE_CLIENTS 8 + +class AsyncEventSource; +class AsyncEventSourceResponse; +class AsyncEventSourceClient; + +///////////////////////////////////////////////// + +typedef std::function ArEventHandlerFunction; + +///////////////////////////////////////////////// + +class AsyncEventSourceMessage +{ + private: + uint8_t * _data; + size_t _len; + size_t _sent; + size_t _acked; + + public: + AsyncEventSourceMessage(const char * data, size_t len); + ~AsyncEventSourceMessage(); + size_t ack(size_t len, uint32_t time __attribute__((unused))); + size_t send(AsyncClient *client); + + ///////////////////////////////////////////////// + + inline bool finished() + { + return _acked == _len; + } + + ///////////////////////////////////////////////// + + inline bool sent() + { + return _sent == _len; + } +}; + +///////////////////////////////////////////////// + +class AsyncEventSourceClient +{ + private: + AsyncClient *_client; + AsyncEventSource *_server; + uint32_t _lastId; + LinkedList _messageQueue; + void _queueMessage(AsyncEventSourceMessage *dataMessage); + void _runQueue(); + + public: + + AsyncEventSourceClient(AsyncWebServerRequest *request, AsyncEventSource *server); + ~AsyncEventSourceClient(); + + ///////////////////////////////////////////////// + + inline AsyncClient* client() + { + return _client; + } + + ///////////////////////////////////////////////// + + void close(); + void write(const char * message, size_t len); + void send(const char *message, const char *event = NULL, uint32_t id = 0, uint32_t reconnect = 0); + + ///////////////////////////////////////////////// + + inline bool connected() const + { + return (_client != NULL) && _client->connected(); + } + + ///////////////////////////////////////////////// + + inline uint32_t lastId() const + { + return _lastId; + } + + ///////////////////////////////////////////////// + + inline size_t packetsWaiting() const + { + return _messageQueue.length(); + } + + ///////////////////////////////////////////////// + + //system callbacks (do not call) + void _onAck(size_t len, uint32_t time); + void _onPoll(); + void _onTimeout(uint32_t time); + void _onDisconnect(); +}; + +///////////////////////////////////////////////// + +class AsyncEventSource: public AsyncWebHandler +{ + private: + String _url; + LinkedList _clients; + ArEventHandlerFunction _connectcb; + + public: + AsyncEventSource(const String& url); + ~AsyncEventSource(); + + ///////////////////////////////////////////////// + + inline const char * url() const + { + return _url.c_str(); + } + + ///////////////////////////////////////////////// + + void close(); + void onConnect(ArEventHandlerFunction cb); + void send(const char *message, const char *event = NULL, uint32_t id = 0, uint32_t reconnect = 0); + size_t count() const; //number clinets connected + size_t avgPacketsWaiting() const; + + //system callbacks (do not call) + void _addClient(AsyncEventSourceClient * client); + void _handleDisconnect(AsyncEventSourceClient * client); + virtual bool canHandle(AsyncWebServerRequest *request) override final; + virtual void handleRequest(AsyncWebServerRequest *request) override final; +}; + +///////////////////////////////////////////////// + +class AsyncEventSourceResponse: public AsyncWebServerResponse +{ + private: + String _content; + AsyncEventSource *_server; + + public: + AsyncEventSourceResponse(AsyncEventSource *server); + void _respond(AsyncWebServerRequest *request); + size_t _ack(AsyncWebServerRequest *request, size_t len, uint32_t time); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return true; + } +}; + +///////////////////////////////////////////////// + +#endif /* ASYNCEVENTSOURCE_H_ */ + diff --git a/src/AsyncJson.h b/src/AsyncJson.h new file mode 100644 index 0000000..1b2ae04 --- /dev/null +++ b/src/AsyncJson.h @@ -0,0 +1,445 @@ +/**************************************************************************************************************************** + AsyncJson.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ +/* + Async Response to use with ArduinoJson and AsyncWebServer + Written by Andrew Melvin (SticilFace) with help from me-no-dev and BBlanchon. + + Example of callback in use + + server.on("/json", HTTP_ANY, [](AsyncWebServerRequest * request) { + + AsyncJsonResponse * response = new AsyncJsonResponse(); + JsonObject& root = response->getRoot(); + root["key1"] = "key number one"; + JsonObject& nested = root.createNestedObject("nested"); + nested["key1"] = "key number one"; + + response->setLength(); + request->send(response); + }); + + -------------------- + + Async Request to use with ArduinoJson and AsyncWebServer + Written by Arsène von Wyss (avonwyss) + + Example + + AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/rest/endpoint"); + handler->onRequest([](AsyncWebServerRequest *request, JsonVariant &json) { + JsonObject& jsonObj = json.as(); + // ... + }); + server.addHandler(handler); + +*/ + +#ifndef ASYNC_JSON_H_ +#define ASYNC_JSON_H_ + +#include + +#include "AsyncWebServer_ESP32_ENC.h" + +#include + +///////////////////////////////////////////////// + +#if ARDUINOJSON_VERSION_MAJOR == 5 + #define ARDUINOJSON_5_COMPATIBILITY +#else + #ifndef DYNAMIC_JSON_DOCUMENT_SIZE + #define DYNAMIC_JSON_DOCUMENT_SIZE 1024 + #endif +#endif + +///////////////////////////////////////////////// + +constexpr const char* JSON_MIMETYPE = "application/json"; + +///////////////////////////////////////////////// + +/* + Json Response + * */ + +class ChunkPrint : public Print +{ + private: + uint8_t* _destination; + size_t _to_skip; + size_t _to_write; + size_t _pos; + + public: + ChunkPrint(uint8_t* destination, size_t from, size_t len) + : _destination(destination), _to_skip(from), _to_write(len), _pos{0} {} + + virtual ~ChunkPrint() {} + + ///////////////////////////////////////////////// + + size_t write(uint8_t c) + { + if (_to_skip > 0) + { + _to_skip--; + + return 1; + } + else if (_to_write > 0) + { + _to_write--; + _destination[_pos++] = c; + + return 1; + } + + return 0; + } + + ///////////////////////////////////////////////// + + inline size_t write(const uint8_t *buffer, size_t size) + { + return this->Print::write(buffer, size); + } +}; + +///////////////////////////////////////////////// + +///////////////////////////////////////////////// + +class AsyncJsonResponse: public AsyncAbstractResponse +{ + protected: + +#ifdef ARDUINOJSON_5_COMPATIBILITY + DynamicJsonBuffer _jsonBuffer; +#else + DynamicJsonDocument _jsonBuffer; +#endif + + JsonVariant _root; + bool _isValid; + + public: + + ///////////////////////////////////////////////// + +#ifdef ARDUINOJSON_5_COMPATIBILITY + AsyncJsonResponse(bool isArray = false): _isValid {false} + { + _code = 200; + _contentType = JSON_MIMETYPE; + + if (isArray) + _root = _jsonBuffer.createArray(); + else + _root = _jsonBuffer.createObject(); + } +#else + AsyncJsonResponse(bool isArray = false, + size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) : _jsonBuffer(maxJsonBufferSize), _isValid {false} + { + _code = 200; + _contentType = JSON_MIMETYPE; + + if (isArray) + _root = _jsonBuffer.createNestedArray(); + else + _root = _jsonBuffer.createNestedObject(); + } +#endif + + ///////////////////////////////////////////////// + + ~AsyncJsonResponse() {} + + ///////////////////////////////////////////////// + + inline JsonVariant & getRoot() + { + return _root; + } + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return _isValid; + } + + ///////////////////////////////////////////////// + + size_t setLength() + { + +#ifdef ARDUINOJSON_5_COMPATIBILITY + _contentLength = _root.measureLength(); +#else + _contentLength = measureJson(_root); +#endif + + if (_contentLength) + { + _isValid = true; + } + + return _contentLength; + } + + ///////////////////////////////////////////////// + + inline size_t getSize() + { + return _jsonBuffer.size(); + } + + ///////////////////////////////////////////////// + + size_t _fillBuffer(uint8_t *data, size_t len) + { + ChunkPrint dest(data, _sentLength, len); + +#ifdef ARDUINOJSON_5_COMPATIBILITY + _root.printTo( dest ) ; +#else + serializeJson(_root, dest); +#endif + return len; + } + + ///////////////////////////////////////////////// + +}; + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +class PrettyAsyncJsonResponse: public AsyncJsonResponse +{ + public: +#ifdef ARDUINOJSON_5_COMPATIBILITY + PrettyAsyncJsonResponse (bool isArray = false) : AsyncJsonResponse {isArray} {} +#else + PrettyAsyncJsonResponse (bool isArray = false, + size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) : AsyncJsonResponse {isArray, maxJsonBufferSize} {} +#endif + + ///////////////////////////////////////////////// + + size_t setLength () + { +#ifdef ARDUINOJSON_5_COMPATIBILITY + _contentLength = _root.measurePrettyLength (); +#else + _contentLength = measureJsonPretty(_root); +#endif + + if (_contentLength) + { + _isValid = true; + } + + return _contentLength; + } + + ///////////////////////////////////////////////// + + size_t _fillBuffer (uint8_t *data, size_t len) + { + ChunkPrint dest (data, _sentLength, len); + +#ifdef ARDUINOJSON_5_COMPATIBILITY + _root.prettyPrintTo (dest); +#else + serializeJsonPretty(_root, dest); +#endif + + return len; + } +}; + +///////////////////////////////////////////////// + +typedef std::function ArJsonRequestHandlerFunction; + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +class AsyncCallbackJsonWebHandler: public AsyncWebHandler +{ + private: + protected: + const String _uri; + WebRequestMethodComposite _method; + ArJsonRequestHandlerFunction _onRequest; + size_t _contentLength; + +#ifndef ARDUINOJSON_5_COMPATIBILITY + const size_t maxJsonBufferSize; +#endif + + size_t _maxContentLength; + + public: + + ///////////////////////////////////////////////// + +#ifdef ARDUINOJSON_5_COMPATIBILITY + AsyncCallbackJsonWebHandler(const String& uri, ArJsonRequestHandlerFunction onRequest) + : _uri(uri), _method(HTTP_POST | HTTP_PUT | HTTP_PATCH), _onRequest(onRequest), _maxContentLength(16384) {} +#else + AsyncCallbackJsonWebHandler(const String& uri, ArJsonRequestHandlerFunction onRequest, + size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE) + : _uri(uri), _method(HTTP_POST | HTTP_PUT | HTTP_PATCH), _onRequest(onRequest), maxJsonBufferSize(maxJsonBufferSize), + _maxContentLength(16384) {} +#endif + + ///////////////////////////////////////////////// + + inline void setMethod(WebRequestMethodComposite method) + { + _method = method; + } + + ///////////////////////////////////////////////// + + inline void setMaxContentLength(int maxContentLength) + { + _maxContentLength = maxContentLength; + } + + ///////////////////////////////////////////////// + + inline void onRequest(ArJsonRequestHandlerFunction fn) + { + _onRequest = fn; + } + + ///////////////////////////////////////////////// + + virtual bool canHandle(AsyncWebServerRequest *request) override final + { + if (!_onRequest) + return false; + + if (!(_method & request->method())) + return false; + + if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/"))) + return false; + + if ( !request->contentType().equalsIgnoreCase(JSON_MIMETYPE) ) + return false; + + request->addInterestingHeader("ANY"); + + return true; + } + + ///////////////////////////////////////////////// + + virtual void handleRequest(AsyncWebServerRequest *request) override final + { + if (_onRequest) + { + if (request->_tempObject != NULL) + { + +#ifdef ARDUINOJSON_5_COMPATIBILITY + DynamicJsonBuffer jsonBuffer; + JsonVariant json = jsonBuffer.parse((uint8_t*)(request->_tempObject)); + + if (json.success()) + { +#else + DynamicJsonDocument jsonBuffer(this->maxJsonBufferSize); + DeserializationError error = deserializeJson(jsonBuffer, (uint8_t*)(request->_tempObject)); + + if (!error) + { + JsonVariant json = jsonBuffer.as(); +#endif + + _onRequest(request, json); + + return; + } + } + + request->send(_contentLength > _maxContentLength ? 413 : 400); + } + else + { + request->send(500); + } + } + + ///////////////////////////////////////////////// + + virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, + size_t len, bool final) override final + { + } + + ///////////////////////////////////////////////// + + virtual void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, + size_t total) override final + { + if (_onRequest) + { + _contentLength = total; + + if (total > 0 && request->_tempObject == NULL && total < _maxContentLength) + { + request->_tempObject = malloc(total); + } + + if (request->_tempObject != NULL) + { + memcpy((uint8_t*)(request->_tempObject) + index, data, len); + } + } + } + + ///////////////////////////////////////////////// + + virtual bool isRequestHandlerTrivial() override final + { + return _onRequest ? false : true; + } +}; + +#endif + diff --git a/src/AsyncWebServer_ESP32_ENC.cpp b/src/AsyncWebServer_ESP32_ENC.cpp new file mode 100644 index 0000000..0f215c6 --- /dev/null +++ b/src/AsyncWebServer_ESP32_ENC.cpp @@ -0,0 +1,165 @@ +/**************************************************************************************************************************** + AsyncWebServer_ESP32_ENC.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "AsyncWebServer_ESP32_ENC.h" + +bool ESP32_ENC_eth_connected = false; + +///////////////////////////////////////////////// + +void ESP32_ENC_onEvent() +{ + WiFi.onEvent(ESP32_ENC_event); +} + +///////////////////////////////////////////////// + +void ESP32_ENC_waitForConnect() +{ + while (!ESP32_ENC_eth_connected) + delay(100); +} + +///////////////////////////////////////////////// + +bool ESP32_ENC_isConnected() +{ + return ESP32_ENC_eth_connected; +} + +///////////////////////////////////////////////// + +void ESP32_ENC_event(WiFiEvent_t event) +{ + switch (event) + { +#if ( ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) && ( ARDUINO_ESP32_GIT_VER != 0x46d5afb1 ) ) + + // For breaking core v2.0.0 + // Why so strange to define a breaking enum arduino_event_id_t in WiFiGeneric.h + // compared to the old system_event_id_t, now in tools/sdk/esp32/include/esp_event/include/esp_event_legacy.h + // You can preserve the old enum order and just adding new items to do no harm + case ARDUINO_EVENT_ETH_START: + AWS_LOG(F("\nETH Started")); + //set eth hostname here + ETH.setHostname("ESP32-ENC"); + break; + + case ARDUINO_EVENT_ETH_CONNECTED: + AWS_LOG(F("ETH Connected")); + break; + + case ARDUINO_EVENT_ETH_GOT_IP: + if (!ESP32_ENC_eth_connected) + { + AWS_LOG3(F("ETH MAC: "), ETH.macAddress(), F(", IPv4: "), ETH.localIP()); + + if (ETH.fullDuplex()) + { + AWS_LOG0(F("FULL_DUPLEX, ")); + } + else + { + AWS_LOG0(F("HALF_DUPLEX, ")); + } + + AWS_LOG1(ETH.linkSpeed(), F("Mbps")); + + ESP32_ENC_eth_connected = true; + } + + break; + + case ARDUINO_EVENT_ETH_DISCONNECTED: + AWS_LOG("ETH Disconnected"); + ESP32_ENC_eth_connected = false; + break; + + case ARDUINO_EVENT_ETH_STOP: + AWS_LOG("\nETH Stopped"); + ESP32_ENC_eth_connected = false; + break; + +#else + + // For old core v1.0.6- + // Core v2.0.0 defines a stupid enum arduino_event_id_t, breaking any code for ESP32_ENC written for previous core + // Why so strange to define a breaking enum arduino_event_id_t in WiFiGeneric.h + // compared to the old system_event_id_t, now in tools/sdk/esp32/include/esp_event/include/esp_event_legacy.h + // You can preserve the old enum order and just adding new items to do no harm + case SYSTEM_EVENT_ETH_START: + AWS_LOG(F("\nETH Started")); + //set eth hostname here + ETH.setHostname("ESP32-ENC28J60"); + break; + + case SYSTEM_EVENT_ETH_CONNECTED: + AWS_LOG(F("ETH Connected")); + break; + + case SYSTEM_EVENT_ETH_GOT_IP: + if (!ESP32_ENC_eth_connected) + { + AWS_LOG3(F("ETH MAC: "), ETH.macAddress(), F(", IPv4: "), ETH.localIP()); + + if (ETH.fullDuplex()) + { + AWS_LOG0(F("FULL_DUPLEX, ")); + } + else + { + AWS_LOG0(F("HALF_DUPLEX, ")); + } + + AWS_LOG1(ETH.linkSpeed(), F("Mbps")); + + ESP32_ENC_eth_connected = true; + } + + break; + + case SYSTEM_EVENT_ETH_DISCONNECTED: + AWS_LOG("ETH Disconnected"); + ESP32_ENC_eth_connected = false; + break; + + case SYSTEM_EVENT_ETH_STOP: + AWS_LOG("\nETH Stopped"); + ESP32_ENC_eth_connected = false; + break; +#endif + + default: + break; + } +} + + diff --git a/src/AsyncWebServer_ESP32_ENC.h b/src/AsyncWebServer_ESP32_ENC.h new file mode 100644 index 0000000..6fa7068 --- /dev/null +++ b/src/AsyncWebServer_ESP32_ENC.h @@ -0,0 +1,921 @@ +/**************************************************************************************************************************** + AsyncWebServer_ESP32_ENC.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef _AsyncWebServer_ESP32_ENC_H_ +#define _AsyncWebServer_ESP32_ENC_H_ + +///////////////////////////////////////////////// + +#if ESP32 + + #if (_ASYNC_WEBSERVER_LOGLEVEL_ > 2 ) + #warning Using ESP32 architecture for WebServer_ESP32_ENC + #endif + + #define BOARD_NAME ARDUINO_BOARD +#else + #error This code is designed for ESP32_ENC to run on ESP32 platform! Please check your Tools->Board setting. +#endif + +///////////////////////////////////////////////// + +#if ( ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) && ( ARDUINO_ESP32_GIT_VER != 0x46d5afb1 ) ) + #define USING_CORE_ESP32_CORE_V200_PLUS true + + #if (_ASYNC_WEBSERVER_LOGLEVEL_ > 2 ) + #warning Using code for ESP32 core v2.0.0+ in AsyncWebServer_ESP32_ENC.h + #endif + + #define ASYNC_WEBSERVER_ESP32_ENC_VERSION "AsyncWebServer_ESP32_ENC v1.6.2 for core v2.0.0+" +#else + + #if (_ASYNC_WEBSERVER_LOGLEVEL_ > 2 ) + #warning Using code for ESP32 core v1.0.6- in AsyncWebServer_ESP32_ENC.h + #endif + + #define ASYNC_WEBSERVER_ESP32_ENC_VERSION "AsyncWebServer_ESP32_ENC v1.6.2 for core v1.0.6-" +#endif + +#define ASYNC_WEBSERVER_ESP32_ENC_VERSION_MAJOR 1 +#define ASYNC_WEBSERVER_ESP32_ENC_VERSION_MINOR 6 +#define ASYNC_WEBSERVER_ESP32_ENC_VERSION_PATCH 2 + +#define ASYNC_WEBSERVER_ESP32_ENC_VERSION_INT 1006002 + +///////////////////////////////////////////////// + +#ifndef ESP32_ENC_AWS_UNUSED + #define ESP32_ENC_AWS_UNUSED(x) (void)(x) +#endif + +///////////////////////////////////////////////// + +#include "Arduino.h" + +#include +#include "FS.h" + +#include "StringArray.h" + +////////////////////////////////////////////////////////////// +// ESP32_ENC related code + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +//#include +#include "enc28j60/esp32_enc28j60.h" + +#if !defined(SPI_HOST) + #define SPI_HOST 1 +#endif + +#if !defined(SPI_CLOCK_MHZ) + #define SPI_CLOCK_MHZ 8 +#endif + +#if !defined(INT_GPIO) + #define INT_GPIO 4 +#endif + +#if !defined(MISO_GPIO) + #define MISO_GPIO 19 +#endif + +#if !defined(MOSI_GPIO) + #define MOSI_GPIO 23 +#endif + +#if !defined(SCK_GPIO) + #define SCK_GPIO 18 +#endif + +#if !defined(CS_GPIO) + #define CS_GPIO 5 +#endif + +#ifndef SHIELD_TYPE + #define SHIELD_TYPE "ESP32_ENC28J60" +#endif + +extern bool ESP32_ENC_eth_connected; + +extern void ESP32_ENC_onEvent(); + +extern void ESP32_ENC_waitForConnect(); + +extern bool ESP32_ENC_isConnected(); + +extern void ESP32_ENC_event(WiFiEvent_t event); + +////////////////////////////////////////////////////////////// + +#include + +#ifdef ASYNCWEBSERVER_REGEX + #define ASYNCWEBSERVER_REGEX_ATTRIBUTE +#else + #define ASYNCWEBSERVER_REGEX_ATTRIBUTE __attribute__((warning("ASYNCWEBSERVER_REGEX not defined"))) +#endif + +#define DEBUGF(...) //Serial.printf(__VA_ARGS__) + +class AsyncWebServer; +class AsyncWebServerRequest; +class AsyncWebServerResponse; +class AsyncWebHeader; +class AsyncWebParameter; +class AsyncWebRewrite; +class AsyncWebHandler; +class AsyncStaticWebHandler; +class AsyncCallbackWebHandler; +class AsyncResponseStream; + +///////////////////////////////////////////////// + +#ifndef WEBSERVER_H + +typedef enum +{ + HTTP_GET = 0b00000001, + HTTP_POST = 0b00000010, + HTTP_DELETE = 0b00000100, + HTTP_PUT = 0b00001000, + HTTP_PATCH = 0b00010000, + HTTP_HEAD = 0b00100000, + HTTP_OPTIONS = 0b01000000, + HTTP_ANY = 0b01111111, +} WebRequestMethod; + +#endif + +//if this value is returned when asked for data, packet will not be sent and you will be asked for data again +#define RESPONSE_TRY_AGAIN 0xFFFFFFFF + +typedef uint8_t WebRequestMethodComposite; +typedef std::function ArDisconnectHandler; + +///////////////////////////////////////////////// + +/* + PARAMETER :: Chainable object to hold GET/POST and FILE parameters + * */ + +class AsyncWebParameter +{ + private: + String _name; + String _value; + size_t _size; + bool _isForm; + bool _isFile; + + public: + + AsyncWebParameter(const String& name, const String& value, bool form = false, bool file = false, + size_t size = 0): _name(name), _value(value), _size(size), _isForm(form), _isFile(file) {} + + ///////////////////////////////////////////////// + + inline const String& name() const + { + return _name; + } + + ///////////////////////////////////////////////// + + inline const String& value() const + { + return _value; + } + + ///////////////////////////////////////////////// + + inline size_t size() const + { + return _size; + } + + ///////////////////////////////////////////////// + + inline bool isPost() const + { + return _isForm; + } + + ///////////////////////////////////////////////// + + inline bool isFile() const + { + return _isFile; + } + + ///////////////////////////////////////////////// + +}; + +///////////////////////////////////////////////// + +/* + HEADER :: Chainable object to hold the headers + * */ + +class AsyncWebHeader +{ + private: + String _name; + String _value; + + public: + AsyncWebHeader(const String& name, const String& value): _name(name), _value(value) {} + + ///////////////////////////////////////////////// + + AsyncWebHeader(const String& data): _name(), _value() + { + if (!data) + return; + + int index = data.indexOf(':'); + + if (index < 0) + return; + + _name = data.substring(0, index); + _value = data.substring(index + 2); + } + + ///////////////////////////////////////////////// + + ~AsyncWebHeader() {} + + ///////////////////////////////////////////////// + + inline const String& name() const + { + return _name; + } + + ///////////////////////////////////////////////// + + inline const String& value() const + { + return _value; + } + + ///////////////////////////////////////////////// + + inline String toString() const + { + return String(_name + ": " + _value + "\r\n"); + } + + ///////////////////////////////////////////////// + +}; + +///////////////////////////////////////////////// + +/* + REQUEST :: Each incoming Client is wrapped inside a Request and both live together until disconnect + * */ + +typedef enum +{ + RCT_NOT_USED = -1, + RCT_DEFAULT = 0, + RCT_HTTP, + RCT_WS, + RCT_EVENT, + RCT_MAX +} RequestedConnectionType; + +typedef std::function AwsResponseFiller; +typedef std::function AwsTemplateProcessor; + +///////////////////////////////////////////////// + +class AsyncWebServerRequest +{ + using File = fs::File; + using FS = fs::FS; + friend class AsyncWebServer; + friend class AsyncCallbackWebHandler; + + private: + AsyncClient* _client; + AsyncWebServer* _server; + AsyncWebHandler* _handler; + AsyncWebServerResponse* _response; + StringArray _interestingHeaders; + ArDisconnectHandler _onDisconnectfn; + + String _temp; + uint8_t _parseState; + + uint8_t _version; + WebRequestMethodComposite _method; + String _url; + String _host; + String _contentType; + String _boundary; + String _authorization; + RequestedConnectionType _reqconntype; + void _removeNotInterestingHeaders(); + bool _isDigest; + bool _isMultipart; + bool _isPlainPost; + bool _expectingContinue; + size_t _contentLength; + size_t _parsedLength; + + LinkedList _headers; + LinkedList _params; + LinkedList _pathParams; + + uint8_t _multiParseState; + uint8_t _boundaryPosition; + size_t _itemStartIndex; + size_t _itemSize; + String _itemName; + String _itemFilename; + String _itemType; + String _itemValue; + uint8_t *_itemBuffer; + size_t _itemBufferIndex; + bool _itemIsFile; + + void _onPoll(); + void _onAck(size_t len, uint32_t time); + void _onError(int8_t error); + void _onTimeout(uint32_t time); + void _onDisconnect(); + void _onData(void *buf, size_t len); + + void _addParam(AsyncWebParameter*); + void _addPathParam(const char *param); + + bool _parseReqHead(); + bool _parseReqHeader(); + void _parseLine(); + void _parsePlainPostChar(uint8_t data); + void _parseMultipartPostByte(uint8_t data, bool last); + void _addGetParams(const String& params); + + void _handleUploadStart(); + void _handleUploadByte(uint8_t data, bool last); + void _handleUploadEnd(); + + public: + File _tempFile; + void *_tempObject; + + AsyncWebServerRequest(AsyncWebServer*, AsyncClient*); + ~AsyncWebServerRequest(); + + ///////////////////////////////////////////////// + + inline AsyncClient* client() + { + return _client; + } + + ///////////////////////////////////////////////// + + inline uint8_t version() const + { + return _version; + } + + ///////////////////////////////////////////////// + + inline WebRequestMethodComposite method() const + { + return _method; + } + + ///////////////////////////////////////////////// + + inline const String& url() const + { + return _url; + } + + ///////////////////////////////////////////////// + + inline const String& host() const + { + return _host; + } + + ///////////////////////////////////////////////// + + inline const String& contentType() const + { + return _contentType; + } + + ///////////////////////////////////////////////// + + inline size_t contentLength() const + { + return _contentLength; + } + + ///////////////////////////////////////////////// + + inline bool multipart() const + { + return _isMultipart; + } + + ///////////////////////////////////////////////// + + const char * methodToString() const; + const char * requestedConnTypeToString() const; + + ///////////////////////////////////////////////// + + inline RequestedConnectionType requestedConnType() const + { + return _reqconntype; + } + + ///////////////////////////////////////////////// + + bool isExpectedRequestedConnType(RequestedConnectionType erct1, RequestedConnectionType erct2 = RCT_NOT_USED, + RequestedConnectionType erct3 = RCT_NOT_USED); + void onDisconnect (ArDisconnectHandler fn); + + //hash is the string representation of: + // base64(user:pass) for basic or + // user:realm:md5(user:realm:pass) for digest + bool authenticate(const char * hash); + bool authenticate(const char * username, const char * password, const char * realm = NULL, bool passwordIsHash = false); + void requestAuthentication(const char * realm = NULL, bool isDigest = true); + + ///////////////////////////////////////////////// + + inline void setHandler(AsyncWebHandler *handler) + { + _handler = handler; + } + + ///////////////////////////////////////////////// + + void addInterestingHeader(const String& name); + + void redirect(const String& url); + + void send(AsyncWebServerResponse *response); + void send(int code, const String& contentType = String(), const String& content = String()); + + void send(int code, const String& contentType, const char *content, bool nonDetructiveSend = true); // RSMOD + + void send(FS &fs, const String& path, const String& contentType = String(), bool download = false, + AwsTemplateProcessor callback = nullptr); + void send(File content, const String& path, const String& contentType = String(), bool download = false, + AwsTemplateProcessor callback = nullptr); + void send(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr); + void send(const String& contentType, size_t len, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback = nullptr); + + void sendChunked(const String& contentType, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback = nullptr); + + void send_P(int code, const String& contentType, const uint8_t * content, size_t len, + AwsTemplateProcessor callback = nullptr); + void send_P(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback = nullptr); + + AsyncWebServerResponse *beginResponse(int code, const String& contentType = String(), const String& content = String()); + + AsyncWebServerResponse *beginResponse(int code, const String& contentType, const char * content = nullptr); // RSMOD + + // KH add + AsyncWebServerResponse *beginResponse(int code, const String& contentType, const uint8_t * content, size_t len, + AwsTemplateProcessor callback = nullptr); + ////// + + + AsyncWebServerResponse *beginResponse(FS &fs, const String& path, const String& contentType = String(), + bool download = false, + AwsTemplateProcessor callback = nullptr); + AsyncWebServerResponse *beginResponse(File content, const String& path, const String& contentType = String(), + bool download = false, + AwsTemplateProcessor callback = nullptr); + AsyncWebServerResponse *beginResponse(Stream &stream, const String& contentType, size_t len, + AwsTemplateProcessor callback = nullptr); + AsyncWebServerResponse *beginResponse(const String& contentType, size_t len, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback = nullptr); + + AsyncWebServerResponse *beginChunkedResponse(const String& contentType, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback = nullptr); + AsyncResponseStream *beginResponseStream(const String& contentType, size_t bufferSize = 1460); + + AsyncWebServerResponse *beginResponse_P(int code, const String& contentType, const uint8_t * content, size_t len, + AwsTemplateProcessor callback = nullptr); + AsyncWebServerResponse *beginResponse_P(int code, const String& contentType, PGM_P content, + AwsTemplateProcessor callback = nullptr); + + size_t headers() const; // get header count + bool hasHeader(const String& name) const; // check if header exists + bool hasHeader(const __FlashStringHelper * data) const; // check if header exists + + AsyncWebHeader* getHeader(const String& name) const; + AsyncWebHeader* getHeader(const __FlashStringHelper * data) const; + AsyncWebHeader* getHeader(size_t num) const; + + size_t params() const; // get arguments count + bool hasParam(const String& name, bool post = false, bool file = false) const; + bool hasParam(const __FlashStringHelper * data, bool post = false, bool file = false) const; + + AsyncWebParameter* getParam(const String& name, bool post = false, bool file = false) const; + AsyncWebParameter* getParam(const __FlashStringHelper * data, bool post, bool file) const; + AsyncWebParameter* getParam(size_t num) const; + + ///////////////////////////////////////////////// + + inline size_t args() const + { + return params(); // get arguments count + } + + ///////////////////////////////////////////////// + + const String& arg(const String& name) const; // get request argument value by name + const String& arg(const __FlashStringHelper * data) const; // get request argument value by F(name) + const String& arg(size_t i) const; // get request argument value by number + const String& argName(size_t i) const; // get request argument name by number + bool hasArg(const char* name) const; // check if argument exists + bool hasArg(const __FlashStringHelper * data) const; // check if F(argument) exists + + const String& ASYNCWEBSERVER_REGEX_ATTRIBUTE pathArg(size_t i) const; + + const String& header(const char* name) const;// get request header value by name + const String& header(const __FlashStringHelper * data) const;// get request header value by F(name) + const String& header(size_t i) const; // get request header value by number + const String& headerName(size_t i) const; // get request header name by number + String urlDecode(const String& text) const; +}; + +///////////////////////////////////////////////// + +/* + FILTER :: Callback to filter AsyncWebRewrite and AsyncWebHandler (done by the Server) + * */ + +typedef std::function ArRequestFilterFunction; + +bool ON_STA_FILTER(AsyncWebServerRequest *request); + +bool ON_AP_FILTER(AsyncWebServerRequest *request); + +///////////////////////////////////////////////// + +/* + REWRITE :: One instance can be handle any Request (done by the Server) + * */ + +class AsyncWebRewrite +{ + protected: + String _from; + String _toUrl; + String _params; + ArRequestFilterFunction _filter; + + public: + + ///////////////////////////////////////////////// + + AsyncWebRewrite(const char* from, const char* to): _from(from), _toUrl(to), _params(String()), _filter(NULL) + { + int index = _toUrl.indexOf('?'); + + if (index > 0) + { + _params = _toUrl.substring(index + 1); + _toUrl = _toUrl.substring(0, index); + } + } + + ///////////////////////////////////////////////// + + virtual ~AsyncWebRewrite() {} + + ///////////////////////////////////////////////// + + inline AsyncWebRewrite& setFilter(ArRequestFilterFunction fn) + { + _filter = fn; + return *this; + } + + ///////////////////////////////////////////////// + + inline bool filter(AsyncWebServerRequest *request) const + { + return _filter == NULL || _filter(request); + } + + ///////////////////////////////////////////////// + + inline const String& from() const + { + return _from; + } + + ///////////////////////////////////////////////// + + inline const String& toUrl() const + { + return _toUrl; + } + + ///////////////////////////////////////////////// + + inline const String& params() const + { + return _params; + } + + ///////////////////////////////////////////////// + + virtual bool match(AsyncWebServerRequest *request) + { + return from() == request->url() && filter(request); + } +}; + +///////////////////////////////////////////////// + +/* + HANDLER :: One instance can be attached to any Request (done by the Server) + * */ + +class AsyncWebHandler +{ + protected: + ArRequestFilterFunction _filter; + String _username; + String _password; + + public: + AsyncWebHandler(): _username(""), _password("") {} + + ///////////////////////////////////////////////// + + inline AsyncWebHandler& setFilter(ArRequestFilterFunction fn) + { + _filter = fn; + return *this; + } + + ///////////////////////////////////////////////// + + inline AsyncWebHandler& setAuthentication(const char *username, const char *password) + { + _username = String(username); + _password = String(password); + return *this; + }; + + ///////////////////////////////////////////////// + + inline bool filter(AsyncWebServerRequest *request) + { + return _filter == NULL || _filter(request); + } + + ///////////////////////////////////////////////// + + virtual ~AsyncWebHandler() {} + + ///////////////////////////////////////////////// + + virtual bool canHandle(AsyncWebServerRequest *request __attribute__((unused))) + { + return false; + } + + ///////////////////////////////////////////////// + + virtual void handleRequest(AsyncWebServerRequest *request __attribute__((unused))) {} + virtual void handleUpload(AsyncWebServerRequest *request __attribute__((unused)), + const String& filename __attribute__((unused)), + size_t index __attribute__((unused)), uint8_t *data __attribute__((unused)), size_t len __attribute__((unused)), + bool final __attribute__((unused))) {} + virtual void handleBody(AsyncWebServerRequest *request __attribute__((unused)), uint8_t *data __attribute__((unused)), + size_t len __attribute__((unused)), size_t index __attribute__((unused)), size_t total __attribute__((unused))) {} + + ///////////////////////////////////////////////// + + virtual bool isRequestHandlerTrivial() + { + return true; + } +}; + +///////////////////////////////////////////////// + +/* + RESPONSE :: One instance is created for each Request (attached by the Handler) + * */ + +typedef enum +{ + RESPONSE_SETUP, + RESPONSE_HEADERS, + RESPONSE_CONTENT, + RESPONSE_WAIT_ACK, + RESPONSE_END, + RESPONSE_FAILED +} WebResponseState; + +///////////////////////////////////////////////// + +class AsyncWebServerResponse +{ + protected: + int _code; + LinkedList _headers; + String _contentType; + size_t _contentLength; + bool _sendContentLength; + bool _chunked; + size_t _headLength; + size_t _sentLength; + size_t _ackedLength; + size_t _writtenLength; + WebResponseState _state; + const char* _responseCodeToString(int code); + + public: + AsyncWebServerResponse(); + virtual ~AsyncWebServerResponse(); + virtual void setCode(int code); + virtual void setContentLength(size_t len); + virtual void setContentType(const String& type); + virtual void addHeader(const String& name, const String& value); + virtual String _assembleHead(uint8_t version); + virtual bool _started() const; + virtual bool _finished() const; + virtual bool _failed() const; + virtual bool _sourceValid() const; + virtual void _respond(AsyncWebServerRequest *request); + virtual size_t _ack(AsyncWebServerRequest *request, size_t len, uint32_t time); +}; + +///////////////////////////////////////////////// + +/* + SERVER :: One instance + * */ + +typedef std::function ArRequestHandlerFunction; +typedef std::function +ArUploadHandlerFunction; +typedef std::function +ArBodyHandlerFunction; + +///////////////////////////////////////////////// + +class AsyncWebServer +{ + protected: + AsyncServer _server; + LinkedList _rewrites; + LinkedList _handlers; + AsyncCallbackWebHandler* _catchAllHandler; + + public: + AsyncWebServer(uint16_t port); + ~AsyncWebServer(); + + void begin(); + void end(); + +#if ASYNC_TCP_SSL_ENABLED + void onSslFileRequest(AcSSlFileHandler cb, void* arg); + void beginSecure(const char *cert, const char *private_key_file, const char *password); +#endif + + AsyncWebRewrite& addRewrite(AsyncWebRewrite* rewrite); + bool removeRewrite(AsyncWebRewrite* rewrite); + AsyncWebRewrite& rewrite(const char* from, const char* to); + + AsyncWebHandler& addHandler(AsyncWebHandler* handler); + bool removeHandler(AsyncWebHandler* handler); + + AsyncCallbackWebHandler& on(const char* uri, ArRequestHandlerFunction onRequest); + AsyncCallbackWebHandler& on(const char* uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest); + AsyncCallbackWebHandler& on(const char* uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest, + ArUploadHandlerFunction onUpload); + AsyncCallbackWebHandler& on(const char* uri, WebRequestMethodComposite method, ArRequestHandlerFunction onRequest, + ArUploadHandlerFunction onUpload, ArBodyHandlerFunction onBody); + + AsyncStaticWebHandler& serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_control = NULL); + + void onNotFound(ArRequestHandlerFunction fn); //called when handler is not assigned + void onFileUpload(ArUploadHandlerFunction fn); //handle file uploads + void onRequestBody(ArBodyHandlerFunction + fn); //handle posts with plain body content (JSON often transmitted this way as a request) + + void reset(); //remove all writers and handlers, with onNotFound/onFileUpload/onRequestBody + + void _handleDisconnect(AsyncWebServerRequest *request); + void _attachHandler(AsyncWebServerRequest *request); + void _rewriteRequest(AsyncWebServerRequest *request); +}; + +///////////////////////////////////////////////// + +class DefaultHeaders +{ + using headers_t = LinkedList; + headers_t _headers; + + ///////////////////////////////////////////////// + + DefaultHeaders() + : _headers(headers_t([](AsyncWebHeader * h) + { + delete h; + })) + {} + + ///////////////////////////////////////////////// + + public: + using ConstIterator = headers_t::ConstIterator; + + ///////////////////////////////////////////////// + + void addHeader(const String& name, const String& value) + { + _headers.add(new AsyncWebHeader(name, value)); + } + + ///////////////////////////////////////////////// + + inline ConstIterator begin() const + { + return _headers.begin(); + } + + ///////////////////////////////////////////////// + + inline ConstIterator end() const + { + return _headers.end(); + } + + ///////////////////////////////////////////////// + + DefaultHeaders(DefaultHeaders const &) = delete; + DefaultHeaders &operator=(DefaultHeaders const &) = delete; + + ///////////////////////////////////////////////// + + static DefaultHeaders &Instance() + { + static DefaultHeaders instance; + return instance; + } +}; + +///////////////////////////////////////////////// + +#include "WebResponseImpl.h" +#include "WebHandlerImpl.h" +#include "AsyncWebSocket.h" +#include "AsyncEventSource.h" + +#endif /* _AsyncWebServer_ESP32_ENC_H_ */ diff --git a/src/AsyncWebServer_ESP32_ENC_Debug.h b/src/AsyncWebServer_ESP32_ENC_Debug.h new file mode 100644 index 0000000..b9d888f --- /dev/null +++ b/src/AsyncWebServer_ESP32_ENC_Debug.h @@ -0,0 +1,113 @@ +/**************************************************************************************************************************** + AsyncWebServer_ESP32_ENC_Debug.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#pragma once + +#ifndef ASYNC_WEBSERVER_ESP32_ENC_DEBUG_H +#define ASYNC_WEBSERVER_ESP32_ENC_DEBUG_H + +#include + +#ifdef DEBUG_ASYNC_WEBSERVER_PORT + #define AWS_DEBUG_OUTPUT DEBUG_ASYNC_WEBSERVER_PORT +#else + #define AWS_DEBUG_OUTPUT Serial +#endif + +// Change _ASYNC_WEBSERVER_LOGLEVEL_ to set tracing and logging verbosity +// 0: DISABLED: no logging +// 1: ERROR: errors +// 2: WARN: errors and warnings +// 3: INFO: errors, warnings and informational (default) +// 4: DEBUG: errors, warnings, informational and debug + +#ifndef _ASYNC_WEBSERVER_LOGLEVEL_ + #define _ASYNC_WEBSERVER_LOGLEVEL_ 1 +#endif + +const char AWS_MARK[] = "[AWS] "; +const char AWS_SPACE[] = " "; +const char AWS_LINE[] = "========================================\n"; + +#define AWS_PRINT_MARK AWS_PRINT(AWS_MARK) +#define AWS_PRINT_SP AWS_PRINT(AWS_SPACE) +#define AWS_PRINT_LINE AWS_PRINT(AWS_LINE) + +#define AWS_PRINT AWS_DEBUG_OUTPUT.print +#define AWS_PRINTLN AWS_DEBUG_OUTPUT.println + +/////////////////////////////////////// + +#define AWS_LOG(x) { AWS_PRINTLN(x); } +#define AWS_LOG0(x) { AWS_PRINT(x); } +#define AWS_LOG1(x,y) { AWS_PRINT(x); AWS_PRINTLN(y); } +#define AWS_LOG2(x,y,z) { AWS_PRINT(x); AWS_PRINT(y); AWS_PRINTLN(z); } +#define AWS_LOG3(x,y,z,w) { AWS_PRINT(x); AWS_PRINT(y); AWS_PRINT(z); AWS_PRINTLN(w); } + +/////////////////////////////////////// + +#define AWS_LOGERROR(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>0) { AWS_PRINT_MARK; AWS_PRINTLN(x); } +#define AWS_LOGERROR_LINE(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>0) { AWS_PRINT_MARK; AWS_PRINTLN(x); AWS_PRINT_LINE; } +#define AWS_LOGERROR0(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>0) { AWS_PRINT(x); } +#define AWS_LOGERROR1(x,y) if(_ASYNC_WEBSERVER_LOGLEVEL_>0) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINTLN(y); } +#define AWS_LOGERROR2(x,y,z) if(_ASYNC_WEBSERVER_LOGLEVEL_>0) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINTLN(z); } +#define AWS_LOGERROR3(x,y,z,w) if(_ASYNC_WEBSERVER_LOGLEVEL_>0) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINT(z); AWS_PRINT_SP; AWS_PRINTLN(w); } + +/////////////////////////////////////// + +#define AWS_LOGWARN(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>1) { AWS_PRINT_MARK; AWS_PRINTLN(x); } +#define AWS_LOGWARN_LINE(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>1) { AWS_PRINT_MARK; AWS_PRINTLN(x); AWS_PRINT_LINE; } +#define AWS_LOGWARN0(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>1) { AWS_PRINT(x); } +#define AWS_LOGWARN1(x,y) if(_ASYNC_WEBSERVER_LOGLEVEL_>1) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINTLN(y); } +#define AWS_LOGWARN2(x,y,z) if(_ASYNC_WEBSERVER_LOGLEVEL_>1) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINTLN(z); } +#define AWS_LOGWARN3(x,y,z,w) if(_ASYNC_WEBSERVER_LOGLEVEL_>1) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINT(z); AWS_PRINT_SP; AWS_PRINTLN(w); } + +/////////////////////////////////////// + +#define AWS_LOGINFO(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>2) { AWS_PRINT_MARK; AWS_PRINTLN(x); } +#define AWS_LOGINFO_LINE(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>2) { AWS_PRINT_MARK; AWS_PRINTLN(x); AWS_PRINT_LINE; } +#define AWS_LOGINFO0(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>2) { AWS_PRINT(x); } +#define AWS_LOGINFO1(x,y) if(_ASYNC_WEBSERVER_LOGLEVEL_>2) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINTLN(y); } +#define AWS_LOGINFO2(x,y,z) if(_ASYNC_WEBSERVER_LOGLEVEL_>2) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINTLN(z); } +#define AWS_LOGINFO3(x,y,z,w) if(_ASYNC_WEBSERVER_LOGLEVEL_>2) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINT(z); AWS_PRINT_SP; AWS_PRINTLN(w); } + +/////////////////////////////////////// + +#define AWS_LOGDEBUG(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>3) { AWS_PRINT_MARK; AWS_PRINTLN(x); } +#define AWS_LOGDEBUG_LINE(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>3) { AWS_PRINT_MARK; AWS_PRINTLN(x); AWS_PRINT_LINE; } +#define AWS_LOGDEBUG0(x) if(_ASYNC_WEBSERVER_LOGLEVEL_>3) { AWS_PRINT(x); } +#define AWS_LOGDEBUG1(x,y) if(_ASYNC_WEBSERVER_LOGLEVEL_>3) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINTLN(y); } +#define AWS_LOGDEBUG2(x,y,z) if(_ASYNC_WEBSERVER_LOGLEVEL_>3) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINTLN(z); } +#define AWS_LOGDEBUG3(x,y,z,w) if(_ASYNC_WEBSERVER_LOGLEVEL_>3) { AWS_PRINT_MARK; AWS_PRINT(x); AWS_PRINT_SP; AWS_PRINT(y); AWS_PRINT_SP; AWS_PRINT(z); AWS_PRINT_SP; AWS_PRINTLN(w); } + +#endif // ASYNC_WEBSERVER_ESP32_ENC_DEBUG_H + + diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp new file mode 100644 index 0000000..98e1353 --- /dev/null +++ b/src/AsyncWebSocket.cpp @@ -0,0 +1,1928 @@ +/**************************************************************************************************************************** + AsyncWebSocket.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "Arduino.h" +#include "AsyncWebSocket.h" + +#include + +#include "Crypto/sha1.h" +#include "Crypto/Hash.h" + +///////////////////////////////////////////////// + +#define MAX_PRINTF_LEN 64 + +///////////////////////////////////////////////// + +size_t webSocketSendFrameWindow(AsyncClient *client) +{ + if (!client->canSend()) + return 0; + + size_t space = client->space(); + + if (space < 9) + return 0; + + return space - 8; +} + +///////////////////////////////////////////////// + +size_t webSocketSendFrame(AsyncClient *client, bool final, uint8_t opcode, bool mask, uint8_t *data, size_t len) +{ + if (!client->canSend()) + return 0; + + size_t space = client->space(); + + if (space < 2) + return 0; + + uint8_t mbuf[4] = {0, 0, 0, 0}; + uint8_t headLen = 2; + + if (len && mask) + { + headLen += 4; + mbuf[0] = rand() % 0xFF; + mbuf[1] = rand() % 0xFF; + mbuf[2] = rand() % 0xFF; + mbuf[3] = rand() % 0xFF; + } + + if (len > 125) + headLen += 2; + + if (space < headLen) + return 0; + + space -= headLen; + + if (len > space) + len = space; + + uint8_t *buf = (uint8_t*)malloc(headLen); + + if (buf == NULL) + { + AWS_LOGDEBUG1(F("Error malloc for frame header (bytes):"), headLen); + return 0; + } + + buf[0] = opcode & 0x0F; + + if (final) + buf[0] |= 0x80; + + if (len < 126) + buf[1] = len & 0x7F; + else + { + buf[1] = 126; + buf[2] = (uint8_t)((len >> 8) & 0xFF); + buf[3] = (uint8_t)(len & 0xFF); + } + + if (len && mask) + { + buf[1] |= 0x80; + memcpy(buf + (headLen - 4), mbuf, 4); + } + + if (client->add((const char *)buf, headLen) != headLen) + { + AWS_LOGDEBUG1(F("Error adding header (bytes):"), headLen); + free(buf); + + return 0; + } + + free(buf); + + if (len) + { + if (len && mask) + { + size_t i; + + for (i = 0; i < len; i++) + data[i] = data[i] ^ mbuf[i % 4]; + } + + if (client->add((const char *)data, len) != len) + { + AWS_LOGDEBUG1(F("Error adding data (bytes):"), len); + return 0; + } + } + + if (!client->send()) + { + AWS_LOGDEBUG1(F("Error sending frame (bytes):"), headLen + len); + return 0; + } + + return len; +} + +///////////////////////////////////////////////// + +/* + AsyncWebSocketMessageBuffer +*/ + +AsyncWebSocketMessageBuffer::AsyncWebSocketMessageBuffer() + : _data(nullptr) + , _len(0) + , _lock(false) + , _count(0) +{ +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer::AsyncWebSocketMessageBuffer(uint8_t * data, size_t size) + : _data(nullptr) + , _len(size) + , _lock(false) + , _count(0) +{ + + if (!data) + { + return; + } + + _data = new uint8_t[_len + 1]; + + if (_data) + { + memcpy(_data, data, _len); + _data[_len] = 0; + } +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer::AsyncWebSocketMessageBuffer(size_t size) + : _data(nullptr) + , _len(size) + , _lock(false) + , _count(0) +{ + _data = new uint8_t[_len + 1]; + + if (_data) + { + _data[_len] = 0; + } +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer::AsyncWebSocketMessageBuffer(const AsyncWebSocketMessageBuffer & copy) + : _data(nullptr) + , _len(0) + , _lock(false) + , _count(0) +{ + _len = copy._len; + _lock = copy._lock; + _count = 0; + + if (_len) + { + _data = new uint8_t[_len + 1]; + _data[_len] = 0; + } + + if (_data) + { + memcpy(_data, copy._data, _len); + _data[_len] = 0; + } +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer::AsyncWebSocketMessageBuffer(AsyncWebSocketMessageBuffer && copy) + : _data(nullptr) + , _len(0) + , _lock(false) + , _count(0) +{ + _len = copy._len; + _lock = copy._lock; + _count = 0; + + if (copy._data) + { + _data = copy._data; + copy._data = nullptr; + } +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer::~AsyncWebSocketMessageBuffer() +{ + if (_data) + { + delete[] _data; + } +} + +///////////////////////////////////////////////// + +bool AsyncWebSocketMessageBuffer::reserve(size_t size) +{ + _len = size; + + if (_data) + { + delete[] _data; + _data = nullptr; + } + + _data = new uint8_t[_len + 1]; + + if (_data) + { + _data[_len] = 0; + return true; + } + else + { + return false; + } +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Control Frame +*/ + +class AsyncWebSocketControl +{ + private: + uint8_t _opcode; + uint8_t *_data; + size_t _len; + bool _mask; + bool _finished; + + public: + AsyncWebSocketControl(uint8_t opcode, uint8_t *data = NULL, size_t len = 0, bool mask = false) + : _opcode(opcode) + , _len(len) + , _mask(len && mask) + , _finished(false) + { + if (data == NULL) + _len = 0; + + if (_len) + { + if (_len > 125) + _len = 125; + + _data = (uint8_t*)malloc(_len); + + if (_data == NULL) + _len = 0; + else + memcpy(_data, data, len); + } + else + _data = NULL; + } + + virtual ~AsyncWebSocketControl() + { + if (_data != NULL) + free(_data); + } + + virtual bool finished() const + { + return _finished; + } + + uint8_t opcode() + { + return _opcode; + } + + uint8_t len() + { + return _len + 2; + } + + size_t send(AsyncClient *client) + { + _finished = true; + + return webSocketSendFrame(client, true, _opcode & 0x0F, _mask, _data, _len); + } +}; + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Basic Buffered Message +*/ + + +AsyncWebSocketBasicMessage::AsyncWebSocketBasicMessage(const char * data, size_t len, uint8_t opcode, bool mask) + : _len(len) + , _sent(0) + , _ack(0) + , _acked(0) +{ + _opcode = opcode & 0x07; + _mask = mask; + _data = (uint8_t*)malloc(_len + 1); + + if (_data == NULL) + { + _len = 0; + _status = WS_MSG_ERROR; + } + else + { + _status = WS_MSG_SENDING; + memcpy(_data, data, _len); + _data[_len] = 0; + } +} + +///////////////////////////////////////////////// + +AsyncWebSocketBasicMessage::AsyncWebSocketBasicMessage(uint8_t opcode, bool mask) + : _len(0) + , _sent(0) + , _ack(0) + , _acked(0) + , _data(NULL) +{ + _opcode = opcode & 0x07; + _mask = mask; + +} + +///////////////////////////////////////////////// + +AsyncWebSocketBasicMessage::~AsyncWebSocketBasicMessage() +{ + if (_data != NULL) + free(_data); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketBasicMessage::ack(size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + _acked += len; + + if (_sent == _len && _acked == _ack) + { + _status = WS_MSG_SENT; + } +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocketBasicMessage::send(AsyncClient *client) +{ + if (_status != WS_MSG_SENDING) + return 0; + + if (_acked < _ack) + { + return 0; + } + + if (_sent == _len) + { + if (_acked == _ack) + _status = WS_MSG_SENT; + + return 0; + } + + if (_sent > _len) + { + _status = WS_MSG_ERROR; + + return 0; + } + + size_t toSend = _len - _sent; + size_t window = webSocketSendFrameWindow(client); + + if (window < toSend) + { + toSend = window; + } + + _sent += toSend; + _ack += toSend + ((toSend < 126) ? 2 : 4) + (_mask * 4); + + bool final = (_sent == _len); + uint8_t* dPtr = (uint8_t*)(_data + (_sent - toSend)); + uint8_t opCode = (toSend && _sent == toSend) ? _opcode : (uint8_t)WS_CONTINUATION; + + size_t sent = webSocketSendFrame(client, final, opCode, _mask, dPtr, toSend); + _status = WS_MSG_SENDING; + + if (toSend && sent != toSend) + { + _sent -= (toSend - sent); + _ack -= (toSend - sent); + } + + return sent; +} + +///////////////////////////////////////////////// + +// bool AsyncWebSocketBasicMessage::reserve(size_t size) +//{ +// if (size) { +// _data = (uint8_t*)malloc(size +1); +// if (_data) { +// memset(_data, 0, size); +// _len = size; +// _status = WS_MSG_SENDING; +// return true; +// } +// } +// return false; +// } + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + AsyncWebSocketMultiMessage Message +*/ + +AsyncWebSocketMultiMessage::AsyncWebSocketMultiMessage(AsyncWebSocketMessageBuffer * buffer, uint8_t opcode, bool mask) + : _len(0) + , _sent(0) + , _ack(0) + , _acked(0) + , _WSbuffer(nullptr) +{ + + _opcode = opcode & 0x07; + _mask = mask; + + if (buffer) + { + _WSbuffer = buffer; + + (*_WSbuffer)++; + _data = buffer->get(); + _len = buffer->length(); + _status = WS_MSG_SENDING; + + AWS_LOGDEBUG1("AWSMultiMessage: _len =", _len); + } + else + { + _status = WS_MSG_ERROR; + } +} + +///////////////////////////////////////////////// + +AsyncWebSocketMultiMessage::~AsyncWebSocketMultiMessage() +{ + if (_WSbuffer) + { + (*_WSbuffer)--; // decreases the counter. + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocketMultiMessage::ack(size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + _acked += len; + + if (_sent >= _len && _acked >= _ack) + { + _status = WS_MSG_SENT; + } + + AWS_LOGDEBUG1("AWSMultiMessage::ack: len =", len); +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocketMultiMessage::send(AsyncClient *client) +{ + if (_status != WS_MSG_SENDING) + return 0; + + if (_acked < _ack) + { + return 0; + } + + if (_sent == _len) + { + _status = WS_MSG_SENT; + + return 0; + } + + if (_sent > _len) + { + _status = WS_MSG_ERROR; + + AWS_LOGDEBUG3("AWSMultiMessage::send: Error _sent =", _sent, " > _len =", _len); + + return 0; + } + + size_t toSend = _len - _sent; + size_t window = webSocketSendFrameWindow(client); + + if (window < toSend) + { + toSend = window; + } + + _sent += toSend; + _ack += toSend + ((toSend < 126) ? 2 : 4) + (_mask * 4); + + AWS_LOGDEBUG3("AWSMultiMessage::send: Warning (_sent - toSend) =", _sent - toSend, " : toSend =", toSend); + + bool final = (_sent == _len); + uint8_t* dPtr = (uint8_t*)(_data + (_sent - toSend)); + uint8_t opCode = (toSend && _sent == toSend) ? _opcode : (uint8_t)WS_CONTINUATION; + + size_t sent = webSocketSendFrame(client, final, opCode, _mask, dPtr, toSend); + _status = WS_MSG_SENDING; + + if (toSend && sent != toSend) + { + AWS_LOGDEBUG3("AWSMultiMessage::send: Error toSend =", toSend, " != sent =", sent); + + _sent -= (toSend - sent); + _ack -= (toSend - sent); + } + + AWS_LOGDEBUG3("AWSMultiMessage::send: _sent =", _sent, " : sent =", sent); + + return sent; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Async WebSocket Client +*/ +const char * AWSC_PING_PAYLOAD = "AsyncWebServer_ESP32_ENC-PING"; +//const size_t AWSC_PING_PAYLOAD_LEN = 29; +const size_t AWSC_PING_PAYLOAD_LEN = String(AWSC_PING_PAYLOAD).length(); + +///////////////////////////////////////////////// + +AsyncWebSocketClient::AsyncWebSocketClient(AsyncWebServerRequest *request, AsyncWebSocket *server) + : _controlQueue(LinkedList([](AsyncWebSocketControl * c) +{ + delete c; +})) +, _messageQueue(LinkedList([](AsyncWebSocketMessage *m) +{ + delete m; +})) +, _tempObject(NULL) +{ + _client = request->client(); + _server = server; + _clientId = _server->_getNextId(); + _status = WS_CONNECTED; + _pstate = 0; + _lastMessageTime = millis(); + _keepAlivePeriod = 0; + _client->setRxTimeout(0); + + _client->onError([](void *r, AsyncClient * c, int8_t error) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncWebSocketClient*)(r))->_onError(error); + }, this); + + _client->onAck([](void *r, AsyncClient * c, size_t len, uint32_t time) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncWebSocketClient*)(r))->_onAck(len, time); + }, this); + + _client->onDisconnect([](void *r, AsyncClient * c) + { + ((AsyncWebSocketClient*)(r))->_onDisconnect(); + delete c; + }, this); + + _client->onTimeout([](void *r, AsyncClient * c, uint32_t time) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncWebSocketClient*)(r))->_onTimeout(time); + }, this); + + _client->onData([](void *r, AsyncClient * c, void *buf, size_t len) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncWebSocketClient*)(r))->_onData(buf, len); + }, this); + + _client->onPoll([](void *r, AsyncClient * c) + { + ESP32_ENC_AWS_UNUSED(c); + ((AsyncWebSocketClient*)(r))->_onPoll(); + }, this); + + _server->_addClient(this); + _server->_handleEvent(this, WS_EVT_CONNECT, request, NULL, 0); + delete request; +} + +///////////////////////////////////////////////// + +AsyncWebSocketClient::~AsyncWebSocketClient() +{ + _messageQueue.free(); + _controlQueue.free(); + _server->_handleEvent(this, WS_EVT_DISCONNECT, NULL, NULL, 0); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_onAck(size_t len, uint32_t time) +{ + _lastMessageTime = millis(); + + if (!_controlQueue.isEmpty()) + { + auto head = _controlQueue.front(); + + if (head->finished()) + { + len -= head->len(); + + if (_status == WS_DISCONNECTING && head->opcode() == WS_DISCONNECT) + { + _controlQueue.remove(head); + _status = WS_DISCONNECTED; + _client->close(true); + return; + } + + _controlQueue.remove(head); + } + } + + if (len && !_messageQueue.isEmpty()) + { + _messageQueue.front()->ack(len, time); + } + + _server->_cleanBuffers(); + _runQueue(); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_onPoll() +{ + if (_client->canSend() && (!_controlQueue.isEmpty() || !_messageQueue.isEmpty())) + { + _runQueue(); + } + else if (_keepAlivePeriod > 0 && _controlQueue.isEmpty() && _messageQueue.isEmpty() + && (millis() - _lastMessageTime) >= _keepAlivePeriod) + { + ping((uint8_t *)AWSC_PING_PAYLOAD, AWSC_PING_PAYLOAD_LEN); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_runQueue() +{ + while (!_messageQueue.isEmpty() && _messageQueue.front()->finished()) + { + _messageQueue.remove(_messageQueue.front()); + } + + if (!_controlQueue.isEmpty() && (_messageQueue.isEmpty() || _messageQueue.front()->betweenFrames()) && + webSocketSendFrameWindow(_client) > (size_t)(_controlQueue.front()->len() - 1)) + { + _controlQueue.front()->send(_client); + } + else if (!_messageQueue.isEmpty() && _messageQueue.front()->betweenFrames() && webSocketSendFrameWindow(_client)) + { + _messageQueue.front()->send(_client); + } +} + +///////////////////////////////////////////////// + +bool AsyncWebSocketClient::queueIsFull() +{ + if ((_messageQueue.length() >= WS_MAX_QUEUED_MESSAGES) || (_status != WS_CONNECTED) ) + return true; + + return false; +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_queueMessage(AsyncWebSocketMessage *dataMessage) +{ + if (dataMessage == NULL) + return; + + if (_status != WS_CONNECTED) + { + delete dataMessage; + return; + } + + if (_messageQueue.length() >= WS_MAX_QUEUED_MESSAGES) + { + AWS_LOGDEBUG("ERROR: Too many messages queued"); + + delete dataMessage; + } + else + { + _messageQueue.add(dataMessage); + } + + if (_client->canSend()) + _runQueue(); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_queueControl(AsyncWebSocketControl *controlMessage) +{ + if (controlMessage == NULL) + return; + + _controlQueue.add(controlMessage); + + if (_client->canSend()) + _runQueue(); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::close(uint16_t code, const char * message) +{ + if (_status != WS_CONNECTED) + return; + + if (code) + { + uint8_t packetLen = 2; + + if (message != NULL) + { + size_t mlen = strlen(message); + + if (mlen > 123) + mlen = 123; + + packetLen += mlen; + } + + char * buf = (char*)malloc(packetLen); + + if (buf != NULL) + { + buf[0] = (uint8_t)(code >> 8); + buf[1] = (uint8_t)(code & 0xFF); + + if (message != NULL) + { + memcpy(buf + 2, message, packetLen - 2); + } + + _queueControl(new AsyncWebSocketControl(WS_DISCONNECT, (uint8_t*)buf, packetLen)); + free(buf); + + return; + } + } + + _queueControl(new AsyncWebSocketControl(WS_DISCONNECT)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::ping(uint8_t *data, size_t len) +{ + if (_status == WS_CONNECTED) + _queueControl(new AsyncWebSocketControl(WS_PING, data, len)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_onError(int8_t) {} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_onTimeout(uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + _client->close(true); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_onDisconnect() +{ + _client = NULL; + _server->_handleDisconnect(this); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::_onData(void *pbuf, size_t plen) +{ + _lastMessageTime = millis(); + uint8_t *data = (uint8_t*)pbuf; + + while (plen > 0) + { + if (!_pstate) + { + const uint8_t *fdata = data; + _pinfo.index = 0; + _pinfo.final = (fdata[0] & 0x80) != 0; + _pinfo.opcode = fdata[0] & 0x0F; + _pinfo.masked = (fdata[1] & 0x80) != 0; + _pinfo.len = fdata[1] & 0x7F; + data += 2; + plen -= 2; + + if (_pinfo.len == 126) + { + _pinfo.len = fdata[3] | (uint16_t)(fdata[2]) << 8; + data += 2; + plen -= 2; + } + else if (_pinfo.len == 127) + { + _pinfo.len = fdata[9] | (uint16_t)(fdata[8]) << 8 | (uint32_t)(fdata[7]) << 16 | (uint32_t)(fdata[6]) << 24 | + (uint64_t)(fdata[5]) << 32 | (uint64_t)(fdata[4]) << 40 | (uint64_t)(fdata[3]) << 48 | + (uint64_t)(fdata[2]) << 56; + data += 8; + plen -= 8; + } + + if (_pinfo.masked) + { + memcpy(_pinfo.mask, data, 4); + data += 4; + plen -= 4; + } + } + + const size_t datalen = std::min((size_t)(_pinfo.len - _pinfo.index), plen); + const auto datalast = data[datalen]; + + if (_pinfo.masked) + { + for (size_t i = 0; i < datalen; i++) + data[i] ^= _pinfo.mask[(_pinfo.index + i) % 4]; + } + + if ((datalen + _pinfo.index) < _pinfo.len) + { + _pstate = 1; + + if (_pinfo.index == 0) + { + if (_pinfo.opcode) + { + _pinfo.message_opcode = _pinfo.opcode; + _pinfo.num = 0; + } + else + _pinfo.num += 1; + } + + _server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, (uint8_t*)data, datalen); + + _pinfo.index += datalen; + } + else if ((datalen + _pinfo.index) == _pinfo.len) + { + _pstate = 0; + + if (_pinfo.opcode == WS_DISCONNECT) + { + if (datalen) + { + uint16_t reasonCode = (uint16_t)(data[0] << 8) + data[1]; + char * reasonString = (char*)(data + 2); + + if (reasonCode > 1001) + { + _server->_handleEvent(this, WS_EVT_ERROR, (void *)&reasonCode, (uint8_t*)reasonString, strlen(reasonString)); + } + } + + if (_status == WS_DISCONNECTING) + { + _status = WS_DISCONNECTED; + _client->close(true); + } + else + { + _status = WS_DISCONNECTING; + _client->ackLater(); + _queueControl(new AsyncWebSocketControl(WS_DISCONNECT, data, datalen)); + } + } + else if (_pinfo.opcode == WS_PING) + { + _queueControl(new AsyncWebSocketControl(WS_PONG, data, datalen)); + } + else if (_pinfo.opcode == WS_PONG) + { + if (datalen != AWSC_PING_PAYLOAD_LEN || memcmp(AWSC_PING_PAYLOAD, data, AWSC_PING_PAYLOAD_LEN) != 0) + _server->_handleEvent(this, WS_EVT_PONG, NULL, data, datalen); + } + else if (_pinfo.opcode < 8) + { + //continuation or text/binary frame + _server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, data, datalen); + } + } + else + { + AWS_LOGDEBUG1("AsyncWebSocketClient::_onData: frame error: len: ", datalen); + AWS_LOGDEBUG3("index:", _pinfo.index, ", total:", _pinfo.len); + + //what should we do? + break; + } + + // restore byte as _handleEvent may have added a null terminator i.e., data[len] = 0; + if (datalen > 0) + data[datalen] = datalast; + + data += datalen; + plen -= datalen; + } +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocketClient::printf(const char *format, ...) +{ + va_list arg; + va_start(arg, format); + char* temp = new char[MAX_PRINTF_LEN]; + + if (!temp) + { + va_end(arg); + + return 0; + } + + char* buffer = temp; + size_t len = vsnprintf(temp, MAX_PRINTF_LEN, format, arg); + va_end(arg); + + if (len > (MAX_PRINTF_LEN - 1)) + { + buffer = new char[len + 1]; + + if (!buffer) + { + delete[] temp; + + return 0; + } + + va_start(arg, format); + vsnprintf(buffer, len + 1, format, arg); + va_end(arg); + } + + text(buffer, len); + + if (buffer != temp) + { + delete[] buffer; + } + + delete[] temp; + + return len; +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(const char * message, size_t len) +{ + _queueMessage(new AsyncWebSocketBasicMessage(message, len)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(const char * message) +{ + text(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(uint8_t * message, size_t len) +{ + text((const char *)message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(char * message) +{ + text(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(const String &message) +{ + text(message.c_str(), message.length()); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(const __FlashStringHelper *data) +{ + PGM_P p = reinterpret_cast(data); + size_t n = 0; + + while (1) + { + if (pgm_read_byte(p + n) == 0) + break; + + n += 1; + } + + char * message = (char*) malloc(n + 1); + + if (message) + { + for (size_t b = 0; b < n; b++) + message[b] = pgm_read_byte(p++); + + message[n] = 0; + text(message, n); + free(message); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::text(AsyncWebSocketMessageBuffer * buffer) +{ + _queueMessage(new AsyncWebSocketMultiMessage(buffer)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(const char * message, size_t len) +{ + _queueMessage(new AsyncWebSocketBasicMessage(message, len, WS_BINARY)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(const char * message) +{ + binary(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(uint8_t * message, size_t len) +{ + binary((const char *)message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(char * message) +{ + binary(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(const String &message) +{ + binary(message.c_str(), message.length()); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(const __FlashStringHelper *data, size_t len) +{ + PGM_P p = reinterpret_cast(data); + char * message = (char*) malloc(len); + + if (message) + { + for (size_t b = 0; b < len; b++) + message[b] = pgm_read_byte(p++); + + binary(message, len); + free(message); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer) +{ + _queueMessage(new AsyncWebSocketMultiMessage(buffer, WS_BINARY)); +} + +///////////////////////////////////////////////// + +IPAddress AsyncWebSocketClient::remoteIP() +{ + if (!_client) + { + return IPAddress((uint32_t) 0); + } + + return _client->remoteIP(); +} + +///////////////////////////////////////////////// + +uint16_t AsyncWebSocketClient::remotePort() +{ + if (!_client) + { + return 0; + } + + return _client->remotePort(); +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Async Web Socket - Each separate socket location +*/ + +AsyncWebSocket::AsyncWebSocket(const String& url) + : _url(url) + , _clients(LinkedList([](AsyncWebSocketClient * c) +{ + delete c; +})) +, _cNextId(1) +, _enabled(true) +, _buffers(LinkedList([](AsyncWebSocketMessageBuffer *b) +{ + delete b; +})) +{ + _eventHandler = NULL; +} + +///////////////////////////////////////////////// + +AsyncWebSocket::~AsyncWebSocket() {} + +void AsyncWebSocket::_handleEvent(AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, + size_t len) +{ + if (_eventHandler != NULL) + { + _eventHandler(this, client, type, arg, data, len); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::_addClient(AsyncWebSocketClient * client) +{ + _clients.add(client); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::_handleDisconnect(AsyncWebSocketClient * client) +{ + + _clients.remove_first([ = ](AsyncWebSocketClient * c) + { + return c->id() == client->id(); + }); +} + +///////////////////////////////////////////////// + +bool AsyncWebSocket::availableForWriteAll() +{ + for (const auto& c : _clients) + { + if (c->queueIsFull()) + return false; + } + + return true; +} + +///////////////////////////////////////////////// + +bool AsyncWebSocket::availableForWrite(uint32_t id) +{ + for (const auto& c : _clients) + { + if (c->queueIsFull() && (c->id() == id )) + return false; + } + + return true; +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocket::count() const +{ + return _clients.count_if([](AsyncWebSocketClient * c) + { + return c->status() == WS_CONNECTED; + }); +} + +///////////////////////////////////////////////// + +AsyncWebSocketClient * AsyncWebSocket::client(uint32_t id) +{ + for (const auto &c : _clients) + { + if (c->id() == id && c->status() == WS_CONNECTED) + { + return c; + } + } + + return nullptr; +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::close(uint32_t id, uint16_t code, const char * message) +{ + AsyncWebSocketClient * c = client(id); + + if (c) + c->close(code, message); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::closeAll(uint16_t code, const char * message) +{ + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + c->close(code, message); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::cleanupClients(uint16_t maxClients) +{ + if (count() > maxClients) + { + _clients.front()->close(); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::ping(uint32_t id, uint8_t *data, size_t len) +{ + AsyncWebSocketClient * c = client(id); + + if (c) + c->ping(data, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::pingAll(uint8_t *data, size_t len) +{ + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + c->ping(data, len); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::text(uint32_t id, const char * message, size_t len) +{ + AsyncWebSocketClient * c = client(id); + + if (c) + c->text(message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(AsyncWebSocketMessageBuffer * buffer) +{ + if (!buffer) + return; + + buffer->lock(); + + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + { + c->text(buffer); + } + } + + buffer->unlock(); + _cleanBuffers(); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(const char * message, size_t len) +{ + AsyncWebSocketMessageBuffer * WSBuffer = makeBuffer((uint8_t *)message, len); + textAll(WSBuffer); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binary(uint32_t id, const char * message, size_t len) +{ + AsyncWebSocketClient * c = client(id); + + if (c) + c->binary(message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(const char * message, size_t len) +{ + AsyncWebSocketMessageBuffer * buffer = makeBuffer((uint8_t *)message, len); + binaryAll(buffer); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(AsyncWebSocketMessageBuffer * buffer) +{ + if (!buffer) + return; + + buffer->lock(); + + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + c->binary(buffer); + } + + buffer->unlock(); + _cleanBuffers(); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::message(uint32_t id, AsyncWebSocketMessage *message) +{ + AsyncWebSocketClient * c = client(id); + + if (c) + c->message(message); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::messageAll(AsyncWebSocketMultiMessage *message) +{ + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + c->message(message); + } + + _cleanBuffers(); +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocket::printf(uint32_t id, const char *format, ...) +{ + AsyncWebSocketClient * c = client(id); + + if (c) + { + va_list arg; + va_start(arg, format); + size_t len = c->printf(format, arg); + va_end(arg); + + return len; + } + + return 0; +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocket::printfAll(const char *format, ...) +{ + va_list arg; + char* temp = new char[MAX_PRINTF_LEN]; + + if (!temp) + { + return 0; + } + + va_start(arg, format); + size_t len = vsnprintf(temp, MAX_PRINTF_LEN, format, arg); + va_end(arg); + delete[] temp; + + AsyncWebSocketMessageBuffer * buffer = makeBuffer(len); + + if (!buffer) + { + return 0; + } + + va_start(arg, format); + vsnprintf( (char *)buffer->get(), len + 1, format, arg); + va_end(arg); + + textAll(buffer); + + return len; +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocket::printfAll_P(PGM_P formatP, ...) +{ + va_list arg; + char* temp = new char[MAX_PRINTF_LEN]; + + if (!temp) + { + return 0; + } + + va_start(arg, formatP); + size_t len = vsnprintf_P(temp, MAX_PRINTF_LEN, formatP, arg); + va_end(arg); + delete[] temp; + + AsyncWebSocketMessageBuffer * buffer = makeBuffer(len + 1); + + if (!buffer) + { + return 0; + } + + va_start(arg, formatP); + vsnprintf_P((char *)buffer->get(), len + 1, formatP, arg); + va_end(arg); + + textAll(buffer); + + return len; +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::text(uint32_t id, const char * message) +{ + text(id, message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::text(uint32_t id, uint8_t * message, size_t len) +{ + text(id, (const char *)message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::text(uint32_t id, char * message) +{ + text(id, message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::text(uint32_t id, const String &message) +{ + text(id, message.c_str(), message.length()); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::text(uint32_t id, const __FlashStringHelper *message) +{ + AsyncWebSocketClient * c = client(id); + + if (c != NULL) + c->text(message); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(const char * message) +{ + textAll(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(uint8_t * message, size_t len) +{ + textAll((const char *)message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(char * message) +{ + textAll(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(const String &message) +{ + textAll(message.c_str(), message.length()); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::textAll(const __FlashStringHelper *message) +{ + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + c->text(message); + } +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binary(uint32_t id, const char * message) +{ + binary(id, message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binary(uint32_t id, uint8_t * message, size_t len) +{ + binary(id, (const char *)message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binary(uint32_t id, char * message) +{ + binary(id, message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binary(uint32_t id, const String &message) +{ + binary(id, message.c_str(), message.length()); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binary(uint32_t id, const __FlashStringHelper *message, size_t len) +{ + AsyncWebSocketClient * c = client(id); + + if (c != NULL) + c-> binary(message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(const char * message) +{ + binaryAll(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(uint8_t * message, size_t len) +{ + binaryAll((const char *)message, len); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(char * message) +{ + binaryAll(message, strlen(message)); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(const String &message) +{ + binaryAll(message.c_str(), message.length()); +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::binaryAll(const __FlashStringHelper *message, size_t len) +{ + for (const auto& c : _clients) + { + if (c->status() == WS_CONNECTED) + c-> binary(message, len); + } +} + +///////////////////////////////////////////////// + +const char * WS_STR_CONNECTION = "Connection"; +const char * WS_STR_UPGRADE = "Upgrade"; +const char * WS_STR_ORIGIN = "Origin"; +const char * WS_STR_VERSION = "Sec-WebSocket-Version"; +const char * WS_STR_KEY = "Sec-WebSocket-Key"; +const char * WS_STR_PROTOCOL = "Sec-WebSocket-Protocol"; +const char * WS_STR_ACCEPT = "Sec-WebSocket-Accept"; +const char * WS_STR_UUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + +///////////////////////////////////////////////// + +bool AsyncWebSocket::canHandle(AsyncWebServerRequest *request) +{ + if (!_enabled) + return false; + + if (request->method() != HTTP_GET || !request->url().equals(_url) || !request->isExpectedRequestedConnType(RCT_WS)) + return false; + + request->addInterestingHeader(WS_STR_CONNECTION); + request->addInterestingHeader(WS_STR_UPGRADE); + request->addInterestingHeader(WS_STR_ORIGIN); + request->addInterestingHeader(WS_STR_VERSION); + request->addInterestingHeader(WS_STR_KEY); + request->addInterestingHeader(WS_STR_PROTOCOL); + + return true; +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::handleRequest(AsyncWebServerRequest *request) +{ + if (!request->hasHeader(WS_STR_VERSION) || !request->hasHeader(WS_STR_KEY)) + { + request->send(400); + + return; + } + + if ((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str())) + { + return request->requestAuthentication(); + } + + AsyncWebHeader* version = request->getHeader(WS_STR_VERSION); + + if (version->value().toInt() != 13) + { + AsyncWebServerResponse *response = request->beginResponse(400); + response->addHeader(WS_STR_VERSION, "13"); + request->send(response); + + return; + } + + AsyncWebHeader* key = request->getHeader(WS_STR_KEY); + AsyncWebServerResponse *response = new AsyncWebSocketResponse(key->value(), this); + + if (request->hasHeader(WS_STR_PROTOCOL)) + { + AsyncWebHeader* protocol = request->getHeader(WS_STR_PROTOCOL); + //ToDo: check protocol + response->addHeader(WS_STR_PROTOCOL, protocol->value()); + } + + request->send(response); +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer * AsyncWebSocket::makeBuffer(size_t size) +{ + AsyncWebSocketMessageBuffer * buffer = new AsyncWebSocketMessageBuffer(size); + + if (buffer) + { + AsyncWebLockGuard l(_lock); + _buffers.add(buffer); + } + + return buffer; +} + +///////////////////////////////////////////////// + +AsyncWebSocketMessageBuffer * AsyncWebSocket::makeBuffer(uint8_t * data, size_t size) +{ + AsyncWebSocketMessageBuffer * buffer = new AsyncWebSocketMessageBuffer(data, size); + + if (buffer) + { + AsyncWebLockGuard l(_lock); + _buffers.add(buffer); + } + + return buffer; +} + +///////////////////////////////////////////////// + +void AsyncWebSocket::_cleanBuffers() +{ + AsyncWebLockGuard l(_lock); + + for (AsyncWebSocketMessageBuffer * c : _buffers) + { + if (c && c->canDelete()) + { + _buffers.remove(c); + } + } +} + +///////////////////////////////////////////////// + +AsyncWebSocket::AsyncWebSocketClientLinkedList AsyncWebSocket::getClients() const +{ + return _clients; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Response to Web Socket request - sends the authorization and detaches the TCP Client from the web server + Authentication code from https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSockets.cpp#L480 +*/ + +AsyncWebSocketResponse::AsyncWebSocketResponse(const String & key, AsyncWebSocket * server) +{ + _server = server; + _code = 101; + _sendContentLength = false; + + uint8_t * hash = (uint8_t*) malloc(HASH_BUFFER_SIZE); + + if (hash == NULL) + { + _state = RESPONSE_FAILED; + return; + } + + char * buffer = (char *) malloc(33); + + if (buffer == NULL) + { + free(hash); + _state = RESPONSE_FAILED; + return; + } + + sha1_context _ctx; + + (String&) key += WS_STR_UUID; + + sha1_starts(&_ctx); + sha1_update(&_ctx, (const unsigned char*) key.c_str(), key.length()); + sha1_finish(&_ctx, hash); + ////// + + base64_encodestate _state; + base64_init_encodestate(&_state); + int len = base64_encode_block((const char *) hash, HASH_BUFFER_SIZE, buffer, &_state); + len = base64_encode_blockend((buffer + len), &_state); + + addHeader(WS_STR_CONNECTION, WS_STR_UPGRADE); + addHeader(WS_STR_UPGRADE, "websocket"); + addHeader(WS_STR_ACCEPT, buffer); + + free(buffer); + free(hash); +} + +///////////////////////////////////////////////// + +void AsyncWebSocketResponse::_respond(AsyncWebServerRequest *request) +{ + if (_state == RESPONSE_FAILED) + { + request->client()->close(true); + return; + } + + String out = _assembleHead(request->version()); + request->client()->write(out.c_str(), _headLength); + _state = RESPONSE_WAIT_ACK; +} + +///////////////////////////////////////////////// + +size_t AsyncWebSocketResponse::_ack(AsyncWebServerRequest *request, size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + if (len) + { + new AsyncWebSocketClient(request, _server); + } + + return 0; +} + + diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h new file mode 100644 index 0000000..53cff78 --- /dev/null +++ b/src/AsyncWebSocket.h @@ -0,0 +1,609 @@ +/**************************************************************************************************************************** + AsyncWebSocket.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef ASYNCWEBSOCKET_H_ +#define ASYNCWEBSOCKET_H_ + +#include "mbedtls/version.h" + +#if (MBEDTLS_VERSION_NUMBER >= 0x02070000) + //#error Must use ESP32 core v1.0.6-, with MBEDTLS_VERSION_NUMBER < v2.7.0 +#endif + +#include + +#include +#define WS_MAX_QUEUED_MESSAGES 32 + +#include "AsyncWebServer_ESP32_ENC.h" + +#include "AsyncWebSynchronization.h" + +///////////////////////////////////////////////// + +#define DEFAULT_MAX_WS_CLIENTS 8 + +///////////////////////////////////////////////// + +class AsyncWebSocket; +class AsyncWebSocketResponse; +class AsyncWebSocketClient; +class AsyncWebSocketControl; + +///////////////////////////////////////////////// + +typedef struct +{ + /** Message type as defined by enum AwsFrameType. + Note: Applications will only see WS_TEXT and WS_BINARY. + All other types are handled by the library. */ + uint8_t message_opcode; + /** Frame number of a fragmented message. */ + uint32_t num; + /** Is this the last frame in a fragmented message ?*/ + uint8_t final; + /** Is this frame masked? */ + uint8_t masked; + /** Message type as defined by enum AwsFrameType. + This value is the same as message_opcode for non-fragmented + messages, but may also be WS_CONTINUATION in a fragmented message. */ + uint8_t opcode; + /** Length of the current frame. + This equals the total length of the message if num == 0 && final == true */ + uint64_t len; + /** Mask key */ + uint8_t mask[4]; + /** Offset of the data inside the current frame. */ + uint64_t index; +} AwsFrameInfo; + +///////////////////////////////////////////////// + +typedef enum +{ + WS_DISCONNECTED, + WS_CONNECTED, + WS_DISCONNECTING +} AwsClientStatus; + +typedef enum +{ + WS_CONTINUATION, + WS_TEXT, + WS_BINARY, + WS_DISCONNECT = 0x08, + WS_PING, + WS_PONG +} AwsFrameType; + +typedef enum +{ + WS_MSG_SENDING, + WS_MSG_SENT, + WS_MSG_ERROR +} AwsMessageStatus; + +typedef enum +{ + WS_EVT_CONNECT, + WS_EVT_DISCONNECT, + WS_EVT_PONG, + WS_EVT_ERROR, + WS_EVT_DATA +} AwsEventType; + +///////////////////////////////////////////////// + +class AsyncWebSocketMessageBuffer +{ + private: + uint8_t * _data; + size_t _len; + bool _lock; + uint32_t _count; + + public: + AsyncWebSocketMessageBuffer(); + AsyncWebSocketMessageBuffer(size_t size); + AsyncWebSocketMessageBuffer(uint8_t * data, size_t size); + AsyncWebSocketMessageBuffer(const AsyncWebSocketMessageBuffer &); + AsyncWebSocketMessageBuffer(AsyncWebSocketMessageBuffer &&); + ~AsyncWebSocketMessageBuffer(); + + ///////////////////////////////////////////////// + + void operator ++(int i) + { + ESP32_ENC_AWS_UNUSED(i); + _count++; + } + + ///////////////////////////////////////////////// + + void operator --(int i) + { + ESP32_ENC_AWS_UNUSED(i); + + if (_count > 0) + { + _count--; + } ; + } + + ///////////////////////////////////////////////// + + bool reserve(size_t size); + + ///////////////////////////////////////////////// + + inline void lock() + { + _lock = true; + } + + ///////////////////////////////////////////////// + + inline void unlock() + { + _lock = false; + } + + ///////////////////////////////////////////////// + + inline uint8_t * get() + { + return _data; + } + + ///////////////////////////////////////////////// + + inline size_t length() + { + return _len; + } + + ///////////////////////////////////////////////// + + inline uint32_t count() + { + return _count; + } + + ///////////////////////////////////////////////// + + inline bool canDelete() + { + return (!_count && !_lock); + } + + ///////////////////////////////////////////////// + + friend AsyncWebSocket; + +}; + +///////////////////////////////////////////////// + +class AsyncWebSocketMessage +{ + protected: + uint8_t _opcode; + bool _mask; + AwsMessageStatus _status; + + public: + AsyncWebSocketMessage(): _opcode(WS_TEXT), _mask(false), _status(WS_MSG_ERROR) {} + virtual ~AsyncWebSocketMessage() {} + virtual void ack(size_t len __attribute__((unused)), uint32_t time __attribute__((unused))) {} + + ///////////////////////////////////////////////// + + virtual size_t send(AsyncClient *client __attribute__((unused))) + { + return 0; + } + + ///////////////////////////////////////////////// + + virtual bool finished() + { + return _status != WS_MSG_SENDING; + } + + ///////////////////////////////////////////////// + + virtual bool betweenFrames() const + { + return false; + } +}; + +///////////////////////////////////////////////// + +class AsyncWebSocketBasicMessage: public AsyncWebSocketMessage +{ + private: + size_t _len; + size_t _sent; + size_t _ack; + size_t _acked; + uint8_t * _data; + + public: + AsyncWebSocketBasicMessage(const char * data, size_t len, uint8_t opcode = WS_TEXT, bool mask = false); + AsyncWebSocketBasicMessage(uint8_t opcode = WS_TEXT, bool mask = false); + virtual ~AsyncWebSocketBasicMessage() override; + + ///////////////////////////////////////////////// + + virtual bool betweenFrames() const override + { + return _acked == _ack; + } + + ///////////////////////////////////////////////// + + virtual void ack(size_t len, uint32_t time) override ; + virtual size_t send(AsyncClient *client) override ; +}; + +///////////////////////////////////////////////// + +class AsyncWebSocketMultiMessage: public AsyncWebSocketMessage +{ + private: + uint8_t * _data; + size_t _len; + size_t _sent; + size_t _ack; + size_t _acked; + AsyncWebSocketMessageBuffer * _WSbuffer; + + public: + AsyncWebSocketMultiMessage(AsyncWebSocketMessageBuffer * buffer, uint8_t opcode = WS_TEXT, bool mask = false); + virtual ~AsyncWebSocketMultiMessage() override; + + ///////////////////////////////////////////////// + + virtual bool betweenFrames() const override + { + return _acked == _ack; + } + + ///////////////////////////////////////////////// + + virtual void ack(size_t len, uint32_t time) override ; + virtual size_t send(AsyncClient *client) override ; +}; + +///////////////////////////////////////////////// + +class AsyncWebSocketClient +{ + private: + AsyncClient *_client; + AsyncWebSocket *_server; + uint32_t _clientId; + AwsClientStatus _status; + + LinkedList _controlQueue; + LinkedList _messageQueue; + + uint8_t _pstate; + AwsFrameInfo _pinfo; + + uint32_t _lastMessageTime; + uint32_t _keepAlivePeriod; + + void _queueMessage(AsyncWebSocketMessage *dataMessage); + void _queueControl(AsyncWebSocketControl *controlMessage); + void _runQueue(); + + public: + void *_tempObject; + + AsyncWebSocketClient(AsyncWebServerRequest *request, AsyncWebSocket *server); + ~AsyncWebSocketClient(); + + ///////////////////////////////////////////////// + + //client id increments for the given server + inline uint32_t id() + { + return _clientId; + } + + ///////////////////////////////////////////////// + + inline AwsClientStatus status() + { + return _status; + } + + ///////////////////////////////////////////////// + + inline AsyncClient* client() + { + return _client; + } + + ///////////////////////////////////////////////// + + inline AsyncWebSocket *server() + { + return _server; + } + + ///////////////////////////////////////////////// + + inline AwsFrameInfo const &pinfo() const + { + return _pinfo; + } + + ///////////////////////////////////////////////// + + IPAddress remoteIP(); + uint16_t remotePort(); + + //control frames + void close(uint16_t code = 0, const char * message = NULL); + void ping(uint8_t *data = NULL, size_t len = 0); + + ///////////////////////////////////////////////// + + //set auto-ping period in seconds. disabled if zero (default) + inline void keepAlivePeriod(uint16_t seconds) + { + _keepAlivePeriod = seconds * 1000; + } + + ///////////////////////////////////////////////// + + inline uint16_t keepAlivePeriod() + { + return (uint16_t)(_keepAlivePeriod / 1000); + } + + ///////////////////////////////////////////////// + + //data packets + inline void message(AsyncWebSocketMessage *message) + { + _queueMessage(message); + } + + ///////////////////////////////////////////////// + + bool queueIsFull(); + + size_t printf(const char *format, ...) __attribute__ ((format (printf, 2, 3))); + + void text(const char * message, size_t len); + void text(const char * message); + void text(uint8_t * message, size_t len); + void text(char * message); + void text(const String &message); + void text(const __FlashStringHelper *data); + void text(AsyncWebSocketMessageBuffer *buffer); + + void binary(const char * message, size_t len); + void binary(const char * message); + void binary(uint8_t * message, size_t len); + void binary(char * message); + void binary(const String &message); + void binary(const __FlashStringHelper *data, size_t len); + void binary(AsyncWebSocketMessageBuffer *buffer); + + ///////////////////////////////////////////////// + + inline bool canSend() + { + return _messageQueue.length() < WS_MAX_QUEUED_MESSAGES; + } + + ///////////////////////////////////////////////// + + //system callbacks (do not call) + void _onAck(size_t len, uint32_t time); + void _onError(int8_t); + void _onPoll(); + void _onTimeout(uint32_t time); + void _onDisconnect(); + void _onData(void *pbuf, size_t plen); +}; + +///////////////////////////////////////////////// + +typedef std::function +AwsEventHandler; + +///////////////////////////////////////////////// + +//WebServer Handler implementation that plays the role of a socket server +class AsyncWebSocket: public AsyncWebHandler +{ + public: + typedef LinkedList AsyncWebSocketClientLinkedList; + + private: + String _url; + AsyncWebSocketClientLinkedList _clients; + uint32_t _cNextId; + AwsEventHandler _eventHandler; + bool _enabled; + AsyncWebLock _lock; + + public: + AsyncWebSocket(const String& url); + ~AsyncWebSocket(); + + ///////////////////////////////////////////////// + + inline const char * url() const + { + return _url.c_str(); + } + + ///////////////////////////////////////////////// + + inline void enable(bool e) + { + _enabled = e; + } + + ///////////////////////////////////////////////// + + inline bool enabled() const + { + return _enabled; + } + + ///////////////////////////////////////////////// + + bool availableForWriteAll(); + bool availableForWrite(uint32_t id); + + size_t count() const; + AsyncWebSocketClient * client(uint32_t id); + + ///////////////////////////////////////////////// + + inline bool hasClient(uint32_t id) + { + return client(id) != NULL; + } + + ///////////////////////////////////////////////// + + void close(uint32_t id, uint16_t code = 0, const char * message = NULL); + void closeAll(uint16_t code = 0, const char * message = NULL); + void cleanupClients(uint16_t maxClients = DEFAULT_MAX_WS_CLIENTS); + + void ping(uint32_t id, uint8_t *data = NULL, size_t len = 0); + void pingAll(uint8_t *data = NULL, size_t len = 0); // done + + void text(uint32_t id, const char * message, size_t len); + void text(uint32_t id, const char * message); + void text(uint32_t id, uint8_t * message, size_t len); + void text(uint32_t id, char * message); + void text(uint32_t id, const String &message); + void text(uint32_t id, const __FlashStringHelper *message); + + void textAll(const char * message, size_t len); + void textAll(const char * message); + void textAll(uint8_t * message, size_t len); + void textAll(char * message); + void textAll(const String &message); + void textAll(const __FlashStringHelper *message); // need to convert + void textAll(AsyncWebSocketMessageBuffer * buffer); + + void binary(uint32_t id, const char * message, size_t len); + void binary(uint32_t id, const char * message); + void binary(uint32_t id, uint8_t * message, size_t len); + void binary(uint32_t id, char * message); + void binary(uint32_t id, const String &message); + void binary(uint32_t id, const __FlashStringHelper *message, size_t len); + + void binaryAll(const char * message, size_t len); + void binaryAll(const char * message); + void binaryAll(uint8_t * message, size_t len); + void binaryAll(char * message); + void binaryAll(const String &message); + void binaryAll(const __FlashStringHelper *message, size_t len); + void binaryAll(AsyncWebSocketMessageBuffer * buffer); + + void message(uint32_t id, AsyncWebSocketMessage *message); + void messageAll(AsyncWebSocketMultiMessage *message); + + size_t printf(uint32_t id, const char *format, ...) __attribute__ ((format (printf, 3, 4))); + size_t printfAll(const char *format, ...) __attribute__ ((format (printf, 2, 3))); + + size_t printfAll_P(PGM_P formatP, ...) __attribute__ ((format (printf, 2, 3))); + + ///////////////////////////////////////////////// + + //event listener + inline void onEvent(AwsEventHandler handler) + { + _eventHandler = handler; + } + + ///////////////////////////////////////////////// + + //system callbacks (do not call) + inline uint32_t _getNextId() + { + return _cNextId++; + } + + ///////////////////////////////////////////////// + + void _addClient(AsyncWebSocketClient * client); + void _handleDisconnect(AsyncWebSocketClient * client); + void _handleEvent(AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len); + virtual bool canHandle(AsyncWebServerRequest *request) override final; + virtual void handleRequest(AsyncWebServerRequest *request) override final; + + // messagebuffer functions/objects. + AsyncWebSocketMessageBuffer * makeBuffer(size_t size = 0); + AsyncWebSocketMessageBuffer * makeBuffer(uint8_t * data, size_t size); + LinkedList _buffers; + void _cleanBuffers(); + + AsyncWebSocketClientLinkedList getClients() const; +}; + +///////////////////////////////////////////////// + +//WebServer response to authenticate the socket and detach the tcp client from the web server request +class AsyncWebSocketResponse: public AsyncWebServerResponse +{ + private: + String _content; + AsyncWebSocket *_server; + + public: + AsyncWebSocketResponse(const String& key, AsyncWebSocket *server); + void _respond(AsyncWebServerRequest *request); + size_t _ack(AsyncWebServerRequest *request, size_t len, uint32_t time); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return true; + } +}; + +///////////////////////////////////////////////// + +#endif /* ASYNCWEBSOCKET_H_ */ diff --git a/src/AsyncWebSynchronization.h b/src/AsyncWebSynchronization.h new file mode 100644 index 0000000..a0c5c57 --- /dev/null +++ b/src/AsyncWebSynchronization.h @@ -0,0 +1,122 @@ +/**************************************************************************************************************************** + AsyncWebSynchronization.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef ASYNCWEBSYNCHRONIZATION_H_ +#define ASYNCWEBSYNCHRONIZATION_H_ + +// Synchronisation is only available on ESP32, as the ESP8266 isn't using FreeRTOS by default + +#include "AsyncWebServer_ESP32_ENC.h" + +///////////////////////////////////////////////// + +// This is the ESP32 version of the Sync Lock, using the FreeRTOS Semaphore +class AsyncWebLock +{ + private: + SemaphoreHandle_t _lock; + mutable void *_lockedBy; + + public: + AsyncWebLock() + { + _lock = xSemaphoreCreateBinary(); + _lockedBy = NULL; + xSemaphoreGive(_lock); + } + + ///////////////////////////////////////////////// + + ~AsyncWebLock() + { + vSemaphoreDelete(_lock); + } + + ///////////////////////////////////////////////// + + bool lock() const + { + extern void *pxCurrentTCB; + + if (_lockedBy != pxCurrentTCB) + { + xSemaphoreTake(_lock, portMAX_DELAY); + _lockedBy = pxCurrentTCB; + + return true; + } + + return false; + } + + ///////////////////////////////////////////////// + + void unlock() const + { + _lockedBy = NULL; + xSemaphoreGive(_lock); + } +}; + +///////////////////////////////////////////////// + +class AsyncWebLockGuard +{ + private: + const AsyncWebLock *_lock; + + public: + AsyncWebLockGuard(const AsyncWebLock &l) + { + if (l.lock()) + { + _lock = &l; + } + else + { + _lock = NULL; + } + } + + ///////////////////////////////////////////////// + + ~AsyncWebLockGuard() + { + if (_lock) + { + _lock->unlock(); + } + } +}; + +///////////////////////////////////////////////// + +#endif // ASYNCWEBSYNCHRONIZATION_H_ diff --git a/src/Crypto/Hash.cpp b/src/Crypto/Hash.cpp new file mode 100644 index 0000000..65257da --- /dev/null +++ b/src/Crypto/Hash.cpp @@ -0,0 +1,109 @@ +/** + @file Hash.cpp + @date 20.05.2015 + @author Markus Sattler + + Copyright (c) 2015 Markus Sattler. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include +#include "bearssl_hash.h" + +#include "Hash.h" + +/** + create a sha1 hash from data + @param data uint8_t + @param size uint32_t + @param hash uint8_t[HASH_BUFFER_SIZE] +*/ +void sha1(const uint8_t* data, uint32_t size, uint8_t hash[HASH_BUFFER_SIZE]) +{ + br_sha1_context ctx; + + AWS_LOGDEBUG0("DATA:"); + + for (uint16_t i = 0; i < size; i++) + { + AWS_LOGDEBUG0(data[i]); + } + + AWS_LOGDEBUG0("\nDATA:"); + + for (uint16_t i = 0; i < size; i++) + { + AWS_LOGDEBUG0((char) data[i]); + + } + + AWS_LOGDEBUG0("\n"); + + br_sha1_init(&ctx); + br_sha1_update(&ctx, data, size); + br_sha1_out(&ctx, hash); + + AWS_LOGDEBUG0("SHA1:"); + + for (uint16_t i = 0; i < HASH_BUFFER_SIZE; i++) + { + AWS_LOGDEBUG0(hash[i]); + } + + AWS_LOGDEBUG0("\n"); +} + +void sha1(const char* data, uint32_t size, uint8_t hash[HASH_BUFFER_SIZE]) +{ + sha1((const uint8_t *) data, size, hash); +} + +void sha1(const String& data, uint8_t hash[HASH_BUFFER_SIZE]) +{ + sha1(data.c_str(), data.length(), hash); +} + +String sha1(const uint8_t* data, uint32_t size) +{ + uint8_t hash[HASH_BUFFER_SIZE]; + + String hashStr((const char*)nullptr); + hashStr.reserve(HASH_BUFFER_SIZE * 2 + 1); + + sha1(&data[0], size, &hash[0]); + + for (uint16_t i = 0; i < HASH_BUFFER_SIZE; i++) + { + char hex[3]; + snprintf(hex, sizeof(hex), "%02x", hash[i]); + hashStr += hex; + } + + return hashStr; +} + +String sha1(const char* data, uint32_t size) +{ + return sha1((const uint8_t*) data, size); +} + +String sha1(const String& data) +{ + return sha1(data.c_str(), data.length()); +} + diff --git a/src/Crypto/Hash.h b/src/Crypto/Hash.h new file mode 100644 index 0000000..0dd1eab --- /dev/null +++ b/src/Crypto/Hash.h @@ -0,0 +1,46 @@ +/** + @file Hash.h + @date 20.05.2015 + @author Markus Sattler + + Copyright (c) 2015 Markus Sattler. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#pragma once + +#ifndef HASH_H_ +#define HASH_H_ + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +#ifdef HASH_BUFFER_SIZE + #undef HASH_BUFFER_SIZE +#endif + +#define HASH_BUFFER_SIZE 20 + +void sha1(const uint8_t* data, uint32_t size, uint8_t hash[HASH_BUFFER_SIZE]); +void sha1(const char* data, uint32_t size, uint8_t hash[HASH_BUFFER_SIZE]); +void sha1(const String& data, uint8_t hash[HASH_BUFFER_SIZE]); + +String sha1(const uint8_t* data, uint32_t size); +String sha1(const char* data, uint32_t size); +String sha1(const String& data); + +#endif /* HASH_H_ */ diff --git a/src/Crypto/bearssl_hash.h b/src/Crypto/bearssl_hash.h new file mode 100644 index 0000000..89ac628 --- /dev/null +++ b/src/Crypto/bearssl_hash.h @@ -0,0 +1,1357 @@ +/* + Copyright (c) 2016 Thomas Pornin + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef BR_BEARSSL_HASH_H__ +#define BR_BEARSSL_HASH_H__ + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** \file bearssl_hash.h + + # Hash Functions + + This file documents the API for hash functions. + + + ## Procedural API + + For each implemented hash function, of name "`xxx`", the following + elements are defined: + + - `br_xxx_vtable` + + An externally defined instance of `br_hash_class`. + + - `br_xxx_SIZE` + + A macro that evaluates to the output size (in bytes) of the + hash function. + + - `br_xxx_ID` + + A macro that evaluates to a symbolic identifier for the hash + function. Such identifiers are used with HMAC and signature + algorithm implementations. + + NOTE: for the "standard" hash functions defined in [the TLS + standard](https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1), + the symbolic identifiers match the constants used in TLS, i.e. + 1 to 6 for MD5, SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512, + respectively. + + - `br_xxx_context` + + Context for an ongoing computation. It is allocated by the + caller, and a pointer to it is passed to all functions. A + context contains no interior pointer, so it can be moved around + and cloned (with a simple `memcpy()` or equivalent) in order to + capture the function state at some point. Computations that use + distinct context structures are independent of each other. The + first field of `br_xxx_context` is always a pointer to the + `br_xxx_vtable` structure; `br_xxx_init()` sets that pointer. + + - `br_xxx_init(br_xxx_context *ctx)` + + Initialise the provided context. Previous contents of the structure + are ignored. This calls resets the context to the start of a new + hash computation; it also sets the first field of the context + structure (called `vtable`) to a pointer to the statically + allocated constant `br_xxx_vtable` structure. + + - `br_xxx_update(br_xxx_context *ctx, const void *data, size_t len)` + + Add some more bytes to the hash computation represented by the + provided context. + + - `br_xxx_out(const br_xxx_context *ctx, void *out)` + + Complete the hash computation and write the result in the provided + buffer. The output buffer MUST be large enough to accommodate the + result. The context is NOT modified by this operation, so this + function can be used to get a "partial hash" while still keeping + the possibility of adding more bytes to the input. + + - `br_xxx_state(const br_xxx_context *ctx, void *out)` + + Get a copy of the "current state" for the computation so far. For + MD functions (MD5, SHA-1, SHA-2 family), this is the running state + resulting from the processing of the last complete input block. + Returned value is the current input length (in bytes). + + - `br_xxx_set_state(br_xxx_context *ctx, const void *stb, uint64_t count)` + + Set the internal state to the provided values. The 'stb' and + 'count' values shall match that which was obtained from + `br_xxx_state()`. This restores the hash state only if the state + values were at an appropriate block boundary. This does NOT set + the `vtable` pointer in the context. + + Context structures can be discarded without any explicit deallocation. + Hash function implementations are purely software and don't reserve + any resources outside of the context structure itself. + + + ## Object-Oriented API + + For each hash function that follows the procedural API described + above, an object-oriented API is also provided. In that API, function + pointers from the vtable (`br_xxx_vtable`) are used. The vtable + incarnates object-oriented programming. An introduction on the OOP + concept used here can be read on the BearSSL Web site:
+    [https://www.bearssl.org/oop.html](https://www.bearssl.org/oop.html) + + The vtable offers functions called `init()`, `update()`, `out()`, + `set()` and `set_state()`, which are in fact the functions from + the procedural API. That vtable also contains two informative fields: + + - `context_size` + + The size of the context structure (`br_xxx_context`), in bytes. + This can be used by generic implementations to perform dynamic + context allocation. + + - `desc` + + A "descriptor" field that encodes some information on the hash + function: symbolic identifier, output size, state size, + internal block size, details on the padding. + + Users of this object-oriented API (in particular generic HMAC + implementations) may make the following assumptions: + + - Hash output size is no more than 64 bytes. + - Hash internal state size is no more than 64 bytes. + - Internal block size is a power of two, no less than 16 and no more + than 256. + + + ## Implemented Hash Functions + + Implemented hash functions are: + + | Function | Name | Output length | State length | + | :-------- | :------ | :-----------: | :----------: | + | MD5 | md5 | 16 | 16 | + | SHA-1 | sha1 | 20 | 20 | + | SHA-224 | sha224 | 28 | 32 | + | SHA-256 | sha256 | 32 | 32 | + | SHA-384 | sha384 | 48 | 64 | + | SHA-512 | sha512 | 64 | 64 | + | MD5+SHA-1 | md5sha1 | 36 | 36 | + + (MD5+SHA-1 is the concatenation of MD5 and SHA-1 computed over the + same input; in the implementation, the internal data buffer is + shared, thus making it more memory-efficient than separate MD5 and + SHA-1. It can be useful in implementing SSL 3.0, TLS 1.0 and TLS + 1.1.) + + + ## Multi-Hasher + + An aggregate hasher is provided, that can compute several standard + hash functions in parallel. It uses `br_multihash_context` and a + procedural API. It is configured with the implementations (the vtables) + that it should use; it will then compute all these hash functions in + parallel, on the same input. It is meant to be used in cases when the + hash of an object will be used, but the exact hash function is not + known yet (typically, streamed processing on X.509 certificates). + + Only the standard hash functions (MD5, SHA-1, SHA-224, SHA-256, SHA-384 + and SHA-512) are supported by the multi-hasher. + + + ## GHASH + + GHASH is not a generic hash function; it is a _universal_ hash function, + which, as the name does not say, means that it CANNOT be used in most + places where a hash function is needed. GHASH is used within the GCM + encryption mode, to provide the checked integrity functionality. + + A GHASH implementation is basically a function that uses the type defined + in this file under the name `br_ghash`: + + typedef void (*br_ghash)(void *y, const void *h, const void *data, size_t len); + + The `y` pointer refers to a 16-byte value which is used as input, and + receives the output of the GHASH invocation. `h` is a 16-byte secret + value (that serves as key). `data` and `len` define the input data. + + Three GHASH implementations are provided, all constant-time, based on + the use of integer multiplications with appropriate masking to cancel + carry propagation. +*/ + +/** + \brief Class type for hash function implementations. + + A `br_hash_class` instance references the methods implementing a hash + function. Constant instances of this structure are defined for each + implemented hash function. Such instances are also called "vtables". + + Vtables are used to support object-oriented programming, as + described on [the BearSSL Web site](https://www.bearssl.org/oop.html). +*/ +typedef struct br_hash_class_ br_hash_class; + +struct br_hash_class_ +{ + /** + \brief Size (in bytes) of the context structure appropriate for + computing this hash function. + */ + size_t context_size; + + /** + \brief Descriptor word that contains information about the hash + function. + + For each word `xxx` described below, use `BR_HASHDESC_xxx_OFF` + and `BR_HASHDESC_xxx_MASK` to access the specific value, as + follows: + + (hf->desc >> BR_HASHDESC_xxx_OFF) & BR_HASHDESC_xxx_MASK + + The defined elements are: + + - `ID`: the symbolic identifier for the function, as defined + in [TLS](https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1) + (MD5 = 1, SHA-1 = 2,...). + + - `OUT`: hash output size, in bytes. + + - `STATE`: internal running state size, in bytes. + + - `LBLEN`: base-2 logarithm for the internal block size, as + defined for HMAC processing (this is 6 for MD5, SHA-1, SHA-224 + and SHA-256, since these functions use 64-byte blocks; for + SHA-384 and SHA-512, this is 7, corresponding to their + 128-byte blocks). + + The descriptor may contain a few other flags. + */ + uint32_t desc; + + /** + \brief Initialisation method. + + This method takes as parameter a pointer to a context area, + that it initialises. The first field of the context is set + to this vtable; other elements are initialised for a new hash + computation. + + \param ctx pointer to (the first field of) the context. + */ + void (*init)(const br_hash_class **ctx); + + /** + \brief Data injection method. + + The `len` bytes starting at address `data` are injected into + the running hash computation incarnated by the specified + context. The context is updated accordingly. It is allowed + to have `len == 0`, in which case `data` is ignored (and could + be `NULL`), and nothing happens. + on the input data. + + \param ctx pointer to (the first field of) the context. + \param data pointer to the first data byte to inject. + \param len number of bytes to inject. + */ + void (*update)(const br_hash_class **ctx, const void *data, size_t len); + + /** + \brief Produce hash output. + + The hash output corresponding to all data bytes injected in the + context since the last `init()` call is computed, and written + in the buffer pointed to by `dst`. The hash output size depends + on the implemented hash function (e.g. 16 bytes for MD5). + The context is _not_ modified by this call, so further bytes + may be afterwards injected to continue the current computation. + + \param ctx pointer to (the first field of) the context. + \param dst destination buffer for the hash output. + */ + void (*out)(const br_hash_class *const *ctx, void *dst); + + /** + \brief Get running state. + + This method saves the current running state into the `dst` + buffer. What constitutes the "running state" depends on the + hash function; for Merkle-Damgård hash functions (like + MD5 or SHA-1), this is the output obtained after processing + each block. The number of bytes injected so far is returned. + The context is not modified by this call. + + \param ctx pointer to (the first field of) the context. + \param dst destination buffer for the state. + \return the injected total byte length. + */ + uint64_t (*state)(const br_hash_class *const *ctx, void *dst); + + /** + \brief Set running state. + + This methods replaces the running state for the function. + + \param ctx pointer to (the first field of) the context. + \param stb source buffer for the state. + \param count injected total byte length. + */ + void (*set_state)(const br_hash_class **ctx, + const void *stb, uint64_t count); +}; + +#ifndef BR_DOXYGEN_IGNORE +#define BR_HASHDESC_ID(id) ((uint32_t)(id) << BR_HASHDESC_ID_OFF) +#define BR_HASHDESC_ID_OFF 0 +#define BR_HASHDESC_ID_MASK 0xFF + +#define BR_HASHDESC_OUT(size) ((uint32_t)(size) << BR_HASHDESC_OUT_OFF) +#define BR_HASHDESC_OUT_OFF 8 +#define BR_HASHDESC_OUT_MASK 0x7F + +#define BR_HASHDESC_STATE(size) ((uint32_t)(size) << BR_HASHDESC_STATE_OFF) +#define BR_HASHDESC_STATE_OFF 15 +#define BR_HASHDESC_STATE_MASK 0xFF + +#define BR_HASHDESC_LBLEN(ls) ((uint32_t)(ls) << BR_HASHDESC_LBLEN_OFF) +#define BR_HASHDESC_LBLEN_OFF 23 +#define BR_HASHDESC_LBLEN_MASK 0x0F + +#define BR_HASHDESC_MD_PADDING ((uint32_t)1 << 28) +#define BR_HASHDESC_MD_PADDING_128 ((uint32_t)1 << 29) +#define BR_HASHDESC_MD_PADDING_BE ((uint32_t)1 << 30) +#endif + +/* + Specific hash functions. + + Rules for contexts: + -- No interior pointer. + -- No pointer to external dynamically allocated resources. + -- First field is called 'vtable' and is a pointer to a + const-qualified br_hash_class instance (pointer is set by init()). + -- SHA-224 and SHA-256 contexts are identical. + -- SHA-384 and SHA-512 contexts are identical. + + Thus, contexts can be moved and cloned to capture the hash function + current state; and there is no need for any explicit "release" function. +*/ + +/** + \brief Symbolic identifier for MD5. +*/ +#define br_md5_ID 1 + +/** + \brief MD5 output size (in bytes). +*/ +#define br_md5_SIZE 16 + +/** + \brief Constant vtable for MD5. +*/ +extern const br_hash_class br_md5_vtable; + +/** + \brief MD5 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +#ifndef BR_DOXYGEN_IGNORE + unsigned char buf[64]; + uint64_t count; + uint32_t val[4]; +#endif +} br_md5_context; + +/** + \brief MD5 context initialisation. + + This function initialises or resets a context for a new MD5 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_md5_init(br_md5_context *ctx); + +/** + \brief Inject some data bytes in a running MD5 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_md5_update(br_md5_context *ctx, const void *data, size_t len); + +/** + \brief Compute MD5 output. + + The MD5 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_md5_out(const br_md5_context *ctx, void *out); + +/** + \brief Save MD5 running state. + + The running state for MD5 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_md5_state(const br_md5_context *ctx, void *out); + +/** + \brief Restore MD5 running state. + + The running state for MD5 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_md5_set_state(br_md5_context *ctx, const void *stb, uint64_t count); + +/** + \brief Symbolic identifier for SHA-1. +*/ +#define br_sha1_ID 2 + +/** + \brief SHA-1 output size (in bytes). +*/ +#define br_sha1_SIZE 20 + +/** + \brief Constant vtable for SHA-1. +*/ +extern const br_hash_class br_sha1_vtable; + +/** + \brief SHA-1 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +#ifndef BR_DOXYGEN_IGNORE + unsigned char buf[64]; + uint64_t count; + uint32_t val[5]; +#endif +} br_sha1_context; + +/** + \brief SHA-1 context initialisation. + + This function initialises or resets a context for a new SHA-1 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_sha1_init(br_sha1_context *ctx); + +/** + \brief Inject some data bytes in a running SHA-1 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_sha1_update(br_sha1_context *ctx, const void *data, size_t len); + +/** + \brief Compute SHA-1 output. + + The SHA-1 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_sha1_out(const br_sha1_context *ctx, void *out); + +/** + \brief Save SHA-1 running state. + + The running state for SHA-1 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_sha1_state(const br_sha1_context *ctx, void *out); + +/** + \brief Restore SHA-1 running state. + + The running state for SHA-1 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_sha1_set_state(br_sha1_context *ctx, const void *stb, uint64_t count); + +/** + \brief Symbolic identifier for SHA-224. +*/ +#define br_sha224_ID 3 + +/** + \brief SHA-224 output size (in bytes). +*/ +#define br_sha224_SIZE 28 + +/** + \brief Constant vtable for SHA-224. +*/ +extern const br_hash_class br_sha224_vtable; + +/** + \brief SHA-224 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +#ifndef BR_DOXYGEN_IGNORE + unsigned char buf[64]; + uint64_t count; + uint32_t val[8]; +#endif +} br_sha224_context; + +/** + \brief SHA-224 context initialisation. + + This function initialises or resets a context for a new SHA-224 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_sha224_init(br_sha224_context *ctx); + +/** + \brief Inject some data bytes in a running SHA-224 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_sha224_update(br_sha224_context *ctx, const void *data, size_t len); + +/** + \brief Compute SHA-224 output. + + The SHA-224 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_sha224_out(const br_sha224_context *ctx, void *out); + +/** + \brief Save SHA-224 running state. + + The running state for SHA-224 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_sha224_state(const br_sha224_context *ctx, void *out); + +/** + \brief Restore SHA-224 running state. + + The running state for SHA-224 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_sha224_set_state(br_sha224_context *ctx, const void *stb, uint64_t count); + +/** + \brief Symbolic identifier for SHA-256. +*/ +#define br_sha256_ID 4 + +/** + \brief SHA-256 output size (in bytes). +*/ +#define br_sha256_SIZE 32 + +/** + \brief Constant vtable for SHA-256. +*/ +extern const br_hash_class br_sha256_vtable; + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief SHA-256 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +} br_sha256_context; + +#else +typedef br_sha224_context br_sha256_context; +#endif + +/** + \brief SHA-256 context initialisation. + + This function initialises or resets a context for a new SHA-256 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_sha256_init(br_sha256_context *ctx); + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief Inject some data bytes in a running SHA-256 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_sha256_update(br_sha256_context *ctx, const void *data, size_t len); +#else +#define br_sha256_update br_sha224_update +#endif + +/** + \brief Compute SHA-256 output. + + The SHA-256 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_sha256_out(const br_sha256_context *ctx, void *out); + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief Save SHA-256 running state. + + The running state for SHA-256 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_sha256_state(const br_sha256_context *ctx, void *out); +#else +#define br_sha256_state br_sha224_state +#endif + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief Restore SHA-256 running state. + + The running state for SHA-256 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_sha256_set_state(br_sha256_context *ctx, const void *stb, uint64_t count); +#else +#define br_sha256_set_state br_sha224_set_state +#endif + +/** + \brief Symbolic identifier for SHA-384. +*/ +#define br_sha384_ID 5 + +/** + \brief SHA-384 output size (in bytes). +*/ +#define br_sha384_SIZE 48 + +/** + \brief Constant vtable for SHA-384. +*/ +extern const br_hash_class br_sha384_vtable; + +/** + \brief SHA-384 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +#ifndef BR_DOXYGEN_IGNORE + unsigned char buf[128]; + uint64_t count; + uint64_t val[8]; +#endif +} br_sha384_context; + +/** + \brief SHA-384 context initialisation. + + This function initialises or resets a context for a new SHA-384 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_sha384_init(br_sha384_context *ctx); + +/** + \brief Inject some data bytes in a running SHA-384 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_sha384_update(br_sha384_context *ctx, const void *data, size_t len); + +/** + \brief Compute SHA-384 output. + + The SHA-384 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_sha384_out(const br_sha384_context *ctx, void *out); + +/** + \brief Save SHA-384 running state. + + The running state for SHA-384 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_sha384_state(const br_sha384_context *ctx, void *out); + +/** + \brief Restore SHA-384 running state. + + The running state for SHA-384 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_sha384_set_state(br_sha384_context *ctx, + const void *stb, uint64_t count); + +/** + \brief Symbolic identifier for SHA-512. +*/ +#define br_sha512_ID 6 + +/** + \brief SHA-512 output size (in bytes). +*/ +#define br_sha512_SIZE 64 + +/** + \brief Constant vtable for SHA-512. +*/ +extern const br_hash_class br_sha512_vtable; + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief SHA-512 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +} br_sha512_context; +#else +typedef br_sha384_context br_sha512_context; +#endif + +/** + \brief SHA-512 context initialisation. + + This function initialises or resets a context for a new SHA-512 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_sha512_init(br_sha512_context *ctx); + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief Inject some data bytes in a running SHA-512 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_sha512_update(br_sha512_context *ctx, const void *data, size_t len); +#else +#define br_sha512_update br_sha384_update +#endif + +/** + \brief Compute SHA-512 output. + + The SHA-512 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_sha512_out(const br_sha512_context *ctx, void *out); + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief Save SHA-512 running state. + + The running state for SHA-512 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_sha512_state(const br_sha512_context *ctx, void *out); +#else +#define br_sha512_state br_sha384_state +#endif + +#ifdef BR_DOXYGEN_IGNORE +/** + \brief Restore SHA-512 running state. + + The running state for SHA-512 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_sha512_set_state(br_sha512_context *ctx, const void *stb, uint64_t count); +#else +#define br_sha512_set_state br_sha384_set_state +#endif + +/* + "md5sha1" is a special hash function that computes both MD5 and SHA-1 + on the same input, and produces a 36-byte output (MD5 and SHA-1 + concatenation, in that order). State size is also 36 bytes. +*/ + +/** + \brief Symbolic identifier for MD5+SHA-1. + + MD5+SHA-1 is the concatenation of MD5 and SHA-1, computed over the + same input. It is not one of the functions identified in TLS, so + we give it a symbolic identifier of value 0. +*/ +#define br_md5sha1_ID 0 + +/** + \brief MD5+SHA-1 output size (in bytes). +*/ +#define br_md5sha1_SIZE 36 + +/** + \brief Constant vtable for MD5+SHA-1. +*/ +extern const br_hash_class br_md5sha1_vtable; + +/** + \brief MD5+SHA-1 context. + + First field is a pointer to the vtable; it is set by the initialisation + function. Other fields are not supposed to be accessed by user code. +*/ +typedef struct +{ + /** + \brief Pointer to vtable for this context. + */ + const br_hash_class *vtable; +#ifndef BR_DOXYGEN_IGNORE + unsigned char buf[64]; + uint64_t count; + uint32_t val_md5[4]; + uint32_t val_sha1[5]; +#endif +} br_md5sha1_context; + +/** + \brief MD5+SHA-1 context initialisation. + + This function initialises or resets a context for a new SHA-512 + computation. It also sets the vtable pointer. + + \param ctx pointer to the context structure. +*/ +void br_md5sha1_init(br_md5sha1_context *ctx); + +/** + \brief Inject some data bytes in a running MD5+SHA-1 computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_md5sha1_update(br_md5sha1_context *ctx, const void *data, size_t len); + +/** + \brief Compute MD5+SHA-1 output. + + The MD5+SHA-1 output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `out`. The context + itself is not modified, so extra bytes may be injected afterwards + to continue that computation. + + \param ctx pointer to the context structure. + \param out destination buffer for the hash output. +*/ +void br_md5sha1_out(const br_md5sha1_context *ctx, void *out); + +/** + \brief Save MD5+SHA-1 running state. + + The running state for MD5+SHA-1 (output of the last internal block + processing) is written in the buffer pointed to by `out`. The + number of bytes injected since the last initialisation or reset + call is returned. The context is not modified. + + \param ctx pointer to the context structure. + \param out destination buffer for the running state. + \return the injected total byte length. +*/ +uint64_t br_md5sha1_state(const br_md5sha1_context *ctx, void *out); + +/** + \brief Restore MD5+SHA-1 running state. + + The running state for MD5+SHA-1 is set to the provided values. + + \param ctx pointer to the context structure. + \param stb source buffer for the running state. + \param count the injected total byte length. +*/ +void br_md5sha1_set_state(br_md5sha1_context *ctx, + const void *stb, uint64_t count); + +/** + \brief Aggregate context for configurable hash function support. + + The `br_hash_compat_context` type is a type which is large enough to + serve as context for all standard hash functions defined above. +*/ +typedef union +{ + const br_hash_class *vtable; + br_md5_context md5; + br_sha1_context sha1; + br_sha224_context sha224; + br_sha256_context sha256; + br_sha384_context sha384; + br_sha512_context sha512; + br_md5sha1_context md5sha1; +} br_hash_compat_context; + +/* + The multi-hasher is a construct that handles hashing of the same input + data with several hash functions, with a single shared input buffer. + It can handle MD5, SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 + simultaneously, though which functions are activated depends on + the set implementation pointers. +*/ + +/** + \brief Multi-hasher context structure. + + The multi-hasher runs up to six hash functions in the standard TLS list + (MD5, SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512) in parallel, over + the same input. + + The multi-hasher does _not_ follow the OOP structure with a vtable. + Instead, it is configured with the vtables of the hash functions it + should run. Structure fields are not supposed to be accessed directly. +*/ +typedef struct +{ +#ifndef BR_DOXYGEN_IGNORE + unsigned char buf[128]; + uint64_t count; + uint32_t val_32[25]; + uint64_t val_64[16]; + const br_hash_class *impl[6]; +#endif +} br_multihash_context; + +/** + \brief Clear a multi-hasher context. + + This should always be called once on a given context, _before_ setting + the implementation pointers. + + \param ctx the multi-hasher context. +*/ +void br_multihash_zero(br_multihash_context *ctx); + +/** + \brief Set a hash function implementation. + + Implementations shall be set _after_ clearing the context (with + `br_multihash_zero()`) but _before_ initialising the computation + (with `br_multihash_init()`). The hash function implementation + MUST be one of the standard hash functions (MD5, SHA-1, SHA-224, + SHA-256, SHA-384 or SHA-512); it may also be `NULL` to remove + an implementation from the multi-hasher. + + \param ctx the multi-hasher context. + \param id the hash function symbolic identifier. + \param impl the hash function vtable, or `NULL`. +*/ +static inline void +br_multihash_setimpl(br_multihash_context *ctx, int id, const br_hash_class *impl) +{ + /* + This code relies on hash functions ID being values 1 to 6, + in the MD5 to SHA-512 order. + */ + ctx->impl[id - 1] = impl; +} + +/** + \brief Get a hash function implementation. + + This function returns the currently configured vtable for a given + hash function (by symbolic ID). If no such function was configured in + the provided multi-hasher context, then this function returns `NULL`. + + \param ctx the multi-hasher context. + \param id the hash function symbolic identifier. + \return the hash function vtable, or `NULL`. +*/ +static inline const br_hash_class * +br_multihash_getimpl(const br_multihash_context *ctx, int id) +{ + return ctx->impl[id - 1]; +} + +/** + \brief Reset a multi-hasher context. + + This function prepares the context for a new hashing computation, + for all implementations configured at that point. + + \param ctx the multi-hasher context. +*/ +void br_multihash_init(br_multihash_context *ctx); + +/** + \brief Inject some data bytes in a running multi-hashing computation. + + The provided context is updated with some data bytes. If the number + of bytes (`len`) is zero, then the data pointer (`data`) is ignored + and may be `NULL`, and this function does nothing. + + \param ctx pointer to the context structure. + \param data pointer to the injected data. + \param len injected data length (in bytes). +*/ +void br_multihash_update(br_multihash_context *ctx, const void *data, size_t len); + +/** + \brief Compute a hash output from a multi-hasher. + + The hash output for the concatenation of all bytes injected in the + provided context since the last initialisation or reset call, is + computed and written in the buffer pointed to by `dst`. The hash + function to use is identified by `id` and must be one of the standard + hash functions. If that hash function was indeed configured in the + multi-hasher context, the corresponding hash value is written in + `dst` and its length (in bytes) is returned. If the hash function + was _not_ configured, then nothing is written in `dst` and 0 is + returned. + + The context itself is not modified, so extra bytes may be injected + afterwards to continue the hash computations. + + \param ctx pointer to the context structure. + \param id the hash function symbolic identifier. + \param dst destination buffer for the hash output. + \return the hash output length (in bytes), or 0. +*/ +size_t br_multihash_out(const br_multihash_context *ctx, int id, void *dst); + +/** + \brief Type for a GHASH implementation. + + GHASH is a sort of keyed hash meant to be used to implement GCM in + combination with a block cipher (with 16-byte blocks). + + The `y` array has length 16 bytes and is used for input and output; in + a complete GHASH run, it starts with an all-zero value. `h` is a 16-byte + value that serves as key (it is derived from the encryption key in GCM, + using the block cipher). The data length (`len`) is expressed in bytes. + The `y` array is updated. + + If the data length is not a multiple of 16, then the data is implicitly + padded with zeros up to the next multiple of 16. Thus, when using GHASH + in GCM, this method may be called twice, for the associated data and + for the ciphertext, respectively; the zero-padding implements exactly + the GCM rules. + + \param y the array to update. + \param h the GHASH key. + \param data the input data (may be `NULL` if `len` is zero). + \param len the input data length (in bytes). +*/ +typedef void (*br_ghash)(void *y, const void *h, const void *data, size_t len); + +/** + \brief GHASH implementation using multiplications (mixed 32-bit). + + This implementation uses multiplications of 32-bit values, with a + 64-bit result. It is constant-time (if multiplications are + constant-time). + + \param y the array to update. + \param h the GHASH key. + \param data the input data (may be `NULL` if `len` is zero). + \param len the input data length (in bytes). +*/ +void br_ghash_ctmul(void *y, const void *h, const void *data, size_t len); + +/** + \brief GHASH implementation using multiplications (strict 32-bit). + + This implementation uses multiplications of 32-bit values, with a + 32-bit result. It is usually somewhat slower than `br_ghash_ctmul()`, + but it is expected to be faster on architectures for which the + 32-bit multiplication opcode does not yield the upper 32 bits of the + product. It is constant-time (if multiplications are constant-time). + + \param y the array to update. + \param h the GHASH key. + \param data the input data (may be `NULL` if `len` is zero). + \param len the input data length (in bytes). +*/ +void br_ghash_ctmul32(void *y, const void *h, const void *data, size_t len); + +/** + \brief GHASH implementation using multiplications (64-bit). + + This implementation uses multiplications of 64-bit values, with a + 64-bit result. It is constant-time (if multiplications are + constant-time). It is substantially faster than `br_ghash_ctmul()` + and `br_ghash_ctmul32()` on most 64-bit architectures. + + \param y the array to update. + \param h the GHASH key. + \param data the input data (may be `NULL` if `len` is zero). + \param len the input data length (in bytes). +*/ +void br_ghash_ctmul64(void *y, const void *h, const void *data, size_t len); + +/** + \brief GHASH implementation using the `pclmulqdq` opcode (part of the + AES-NI instructions). + + This implementation is available only on x86 platforms where the + compiler supports the relevant intrinsic functions. Even if the + compiler supports these functions, the local CPU might not support + the `pclmulqdq` opcode, meaning that a call will fail with an + illegal instruction exception. To safely obtain a pointer to this + function when supported (or 0 otherwise), use `br_ghash_pclmul_get()`. + + \param y the array to update. + \param h the GHASH key. + \param data the input data (may be `NULL` if `len` is zero). + \param len the input data length (in bytes). +*/ +void br_ghash_pclmul(void *y, const void *h, const void *data, size_t len); + +/** + \brief Obtain the `pclmul` GHASH implementation, if available. + + If the `pclmul` implementation was compiled in the library (depending + on the compiler abilities) _and_ the local CPU appears to support the + opcode, then this function will return a pointer to the + `br_ghash_pclmul()` function. Otherwise, it will return `0`. + + \return the `pclmul` GHASH implementation, or `0`. +*/ +br_ghash br_ghash_pclmul_get(); + +/** + \brief GHASH implementation using the POWER8 opcodes. + + This implementation is available only on POWER8 platforms (and later). + To safely obtain a pointer to this function when supported (or 0 + otherwise), use `br_ghash_pwr8_get()`. + + \param y the array to update. + \param h the GHASH key. + \param data the input data (may be `NULL` if `len` is zero). + \param len the input data length (in bytes). +*/ +void br_ghash_pwr8(void *y, const void *h, const void *data, size_t len); + +/** + \brief Obtain the `pwr8` GHASH implementation, if available. + + If the `pwr8` implementation was compiled in the library (depending + on the compiler abilities) _and_ the local CPU appears to support the + opcode, then this function will return a pointer to the + `br_ghash_pwr8()` function. Otherwise, it will return `0`. + + \return the `pwr8` GHASH implementation, or `0`. +*/ +br_ghash br_ghash_pwr8_get(); + +#ifdef __cplusplus +} +#endif + +#endif // BR_BEARSSL_HASH_H__ diff --git a/src/Crypto/md5.h b/src/Crypto/md5.h new file mode 100644 index 0000000..dff727f --- /dev/null +++ b/src/Crypto/md5.h @@ -0,0 +1,95 @@ +/** + \file md5.h + + Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + + Copyright (C) 2009 Paul Bakker + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#pragma once + +#ifndef LWIP_INCLUDED_POLARSSL_MD5_H +#define LWIP_INCLUDED_POLARSSL_MD5_H + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +/** + \brief MD5 context structure +*/ +typedef struct +{ + unsigned long total[2]; /*!< number of bytes processed */ + unsigned long state[4]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +md5_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + \brief MD5 context setup + + \param ctx context to be initialized +*/ +void md5_starts( md5_context *ctx ); + +/** + \brief MD5 process buffer + + \param ctx MD5 context + \param input buffer holding the data + \param ilen length of the input data +*/ +void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); + +/** + \brief MD5 final digest + + \param ctx MD5 context + \param output MD5 checksum result +*/ +void md5_finish( md5_context *ctx, unsigned char output[16] ); + +/** + \brief Output = MD5( input buffer ) + + \param input buffer holding the data + \param ilen length of the input data + \param output MD5 checksum result +*/ +void md5( unsigned char *input, int ilen, unsigned char output[16] ); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ diff --git a/src/Crypto/sha1.c b/src/Crypto/sha1.c new file mode 100644 index 0000000..0bd892d --- /dev/null +++ b/src/Crypto/sha1.c @@ -0,0 +1,330 @@ +/* + FIPS-180-1 compliant SHA-1 implementation + + Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + + Copyright (C) 2009 Paul Bakker + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/* + The SHA-1 standard was published by NIST in 1993. + + http://www.itl.nist.gov/fipspubs/fip180-1.htm +*/ + +#include "sha1.h" + +#include + +/* + 32-bit integer manipulation macros (big endian) +*/ +#ifndef GET_ULONG_BE +#define GET_ULONG_BE(n,b,i) \ +{ \ + (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ + | ( (unsigned long) (b)[(i) + 1] << 16 ) \ + | ( (unsigned long) (b)[(i) + 2] << 8 ) \ + | ( (unsigned long) (b)[(i) + 3] ); \ +} +#endif + +#ifndef PUT_ULONG_BE +#define PUT_ULONG_BE(n,b,i) \ +{ \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} +#endif + +/* + SHA-1 context setup +*/ +void sha1_starts( sha1_context *ctx ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xC3D2E1F0; +} + +static void sha1_process( sha1_context *ctx, const unsigned char data[64] ) +{ + unsigned long temp, W[16], A, B, C, D, E; + + GET_ULONG_BE( W[ 0], data, 0 ); + GET_ULONG_BE( W[ 1], data, 4 ); + GET_ULONG_BE( W[ 2], data, 8 ); + GET_ULONG_BE( W[ 3], data, 12 ); + GET_ULONG_BE( W[ 4], data, 16 ); + GET_ULONG_BE( W[ 5], data, 20 ); + GET_ULONG_BE( W[ 6], data, 24 ); + GET_ULONG_BE( W[ 7], data, 28 ); + GET_ULONG_BE( W[ 8], data, 32 ); + GET_ULONG_BE( W[ 9], data, 36 ); + GET_ULONG_BE( W[10], data, 40 ); + GET_ULONG_BE( W[11], data, 44 ); + GET_ULONG_BE( W[12], data, 48 ); + GET_ULONG_BE( W[13], data, 52 ); + GET_ULONG_BE( W[14], data, 56 ); + GET_ULONG_BE( W[15], data, 60 ); + +#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define R(t) \ +( \ + temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \ + W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \ + ( W[t & 0x0F] = S(temp,1) ) \ +) + +#define P(a,b,c,d,e,x) \ +{ \ + e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ +} + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + +#define F(x,y,z) (z ^ (x & (y ^ z))) +#define K 0x5A827999 + + P( A, B, C, D, E, W[0] ); + P( E, A, B, C, D, W[1] ); + P( D, E, A, B, C, W[2] ); + P( C, D, E, A, B, W[3] ); + P( B, C, D, E, A, W[4] ); + P( A, B, C, D, E, W[5] ); + P( E, A, B, C, D, W[6] ); + P( D, E, A, B, C, W[7] ); + P( C, D, E, A, B, W[8] ); + P( B, C, D, E, A, W[9] ); + P( A, B, C, D, E, W[10] ); + P( E, A, B, C, D, W[11] ); + P( D, E, A, B, C, W[12] ); + P( C, D, E, A, B, W[13] ); + P( B, C, D, E, A, W[14] ); + P( A, B, C, D, E, W[15] ); + P( E, A, B, C, D, R(16) ); + P( D, E, A, B, C, R(17) ); + P( C, D, E, A, B, R(18) ); + P( B, C, D, E, A, R(19) ); + +#undef K +#undef F + +#define F(x,y,z) (x ^ y ^ z) +#define K 0x6ED9EBA1 + + P( A, B, C, D, E, R(20) ); + P( E, A, B, C, D, R(21) ); + P( D, E, A, B, C, R(22) ); + P( C, D, E, A, B, R(23) ); + P( B, C, D, E, A, R(24) ); + P( A, B, C, D, E, R(25) ); + P( E, A, B, C, D, R(26) ); + P( D, E, A, B, C, R(27) ); + P( C, D, E, A, B, R(28) ); + P( B, C, D, E, A, R(29) ); + P( A, B, C, D, E, R(30) ); + P( E, A, B, C, D, R(31) ); + P( D, E, A, B, C, R(32) ); + P( C, D, E, A, B, R(33) ); + P( B, C, D, E, A, R(34) ); + P( A, B, C, D, E, R(35) ); + P( E, A, B, C, D, R(36) ); + P( D, E, A, B, C, R(37) ); + P( C, D, E, A, B, R(38) ); + P( B, C, D, E, A, R(39) ); + +#undef K +#undef F + +#define F(x,y,z) ((x & y) | (z & (x | y))) +#define K 0x8F1BBCDC + + P( A, B, C, D, E, R(40) ); + P( E, A, B, C, D, R(41) ); + P( D, E, A, B, C, R(42) ); + P( C, D, E, A, B, R(43) ); + P( B, C, D, E, A, R(44) ); + P( A, B, C, D, E, R(45) ); + P( E, A, B, C, D, R(46) ); + P( D, E, A, B, C, R(47) ); + P( C, D, E, A, B, R(48) ); + P( B, C, D, E, A, R(49) ); + P( A, B, C, D, E, R(50) ); + P( E, A, B, C, D, R(51) ); + P( D, E, A, B, C, R(52) ); + P( C, D, E, A, B, R(53) ); + P( B, C, D, E, A, R(54) ); + P( A, B, C, D, E, R(55) ); + P( E, A, B, C, D, R(56) ); + P( D, E, A, B, C, R(57) ); + P( C, D, E, A, B, R(58) ); + P( B, C, D, E, A, R(59) ); + +#undef K +#undef F + +#define F(x,y,z) (x ^ y ^ z) +#define K 0xCA62C1D6 + + P( A, B, C, D, E, R(60) ); + P( E, A, B, C, D, R(61) ); + P( D, E, A, B, C, R(62) ); + P( C, D, E, A, B, R(63) ); + P( B, C, D, E, A, R(64) ); + P( A, B, C, D, E, R(65) ); + P( E, A, B, C, D, R(66) ); + P( D, E, A, B, C, R(67) ); + P( C, D, E, A, B, R(68) ); + P( B, C, D, E, A, R(69) ); + P( A, B, C, D, E, R(70) ); + P( E, A, B, C, D, R(71) ); + P( D, E, A, B, C, R(72) ); + P( C, D, E, A, B, R(73) ); + P( B, C, D, E, A, R(74) ); + P( A, B, C, D, E, R(75) ); + P( E, A, B, C, D, R(76) ); + P( D, E, A, B, C, R(77) ); + P( C, D, E, A, B, R(78) ); + P( B, C, D, E, A, R(79) ); + +#undef K +#undef F + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; +} + +/* + SHA-1 process buffer +*/ +void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ) +{ + int fill; + unsigned long left; + + if ( ilen <= 0 ) + return; + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if ( ctx->total[0] < (unsigned long) ilen ) + ctx->total[1]++; + + if ( left && ilen >= fill ) + { + memcpy( (void *) (ctx->buffer + left), + input, fill ); + sha1_process( ctx, ctx->buffer ); + input += fill; + ilen -= fill; + left = 0; + } + + while ( ilen >= 64 ) + { + sha1_process( ctx, input ); + input += 64; + ilen -= 64; + } + + if ( ilen > 0 ) + { + memcpy( (void *) (ctx->buffer + left), + input, ilen ); + } +} + +static const unsigned char sha1_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* + SHA-1 final digest +*/ +void sha1_finish( sha1_context *ctx, unsigned char output[SHA1_BUFFER_SIZE] ) +{ + unsigned long last, padn; + unsigned long high, low; + unsigned char msglen[8]; + + high = ( ctx->total[0] >> 29 ) + | ( ctx->total[1] << 3 ); + low = ( ctx->total[0] << 3 ); + + PUT_ULONG_BE( high, msglen, 0 ); + PUT_ULONG_BE( low, msglen, 4 ); + + last = ctx->total[0] & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + sha1_update( ctx, sha1_padding, padn ); + sha1_update( ctx, msglen, 8 ); + + PUT_ULONG_BE( ctx->state[0], output, 0 ); + PUT_ULONG_BE( ctx->state[1], output, 4 ); + PUT_ULONG_BE( ctx->state[2], output, 8 ); + PUT_ULONG_BE( ctx->state[3], output, 12 ); + PUT_ULONG_BE( ctx->state[4], output, 16 ); +} + +/* + output = SHA-1( input buffer ) +*/ +void sha1( unsigned char *input, int ilen, unsigned char output[SHA1_BUFFER_SIZE] ) +{ + sha1_context ctx; + + sha1_starts( &ctx ); + sha1_update( &ctx, input, ilen ); + sha1_finish( &ctx, output ); +} diff --git a/src/Crypto/sha1.h b/src/Crypto/sha1.h new file mode 100644 index 0000000..a68c3ee --- /dev/null +++ b/src/Crypto/sha1.h @@ -0,0 +1,101 @@ +/** + \file sha1.h + + Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + + Copyright (C) 2009 Paul Bakker + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#pragma once + +#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H +#define LWIP_INCLUDED_POLARSSL_SHA1_H + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +#ifdef SHA1_BUFFER_SIZE + #undef SHA1_BUFFER_SIZE +#endif + +#define SHA1_BUFFER_SIZE 20 + +/** + \brief SHA-1 context structure +*/ +typedef struct +{ + unsigned long total[2]; /*!< number of bytes processed */ + unsigned long state[5]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +sha1_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + \brief SHA-1 context setup + + \param ctx context to be initialized +*/ +void sha1_starts( sha1_context *ctx ); + +/** + \brief SHA-1 process buffer + + \param ctx SHA-1 context + \param input buffer holding the data + \param ilen length of the input data +*/ +void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); + +/** + \brief SHA-1 final digest + + \param ctx SHA-1 context + \param output SHA-1 checksum result +*/ +void sha1_finish( sha1_context *ctx, unsigned char output[SHA1_BUFFER_SIZE] ); + +/** + \brief Output = SHA-1( input buffer ) + + \param input buffer holding the data + \param ilen length of the input data + \param output SHA-1 checksum result +*/ +void sha1( unsigned char *input, int ilen, unsigned char output[SHA1_BUFFER_SIZE] ); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ diff --git a/src/ESP32_ENC_SPIFFSEditor.cpp b/src/ESP32_ENC_SPIFFSEditor.cpp new file mode 100644 index 0000000..a8aa04a --- /dev/null +++ b/src/ESP32_ENC_SPIFFSEditor.cpp @@ -0,0 +1,687 @@ +/**************************************************************************************************************************** + ESP32_ENC_SPIFFSEditor.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "ESP32_ENC_SPIFFSEditor.h" +#include + +///////////////////////////////////////////////// + +//File: edit.htm.gz, Size: 4151 +#define edit_htm_gz_len 4151 + +const uint8_t edit_htm_gz[] PROGMEM = +{ + 0x1F, 0x8B, 0x08, 0x08, 0xB8, 0x94, 0xB1, 0x59, 0x00, 0x03, 0x65, 0x64, 0x69, 0x74, 0x2E, 0x68, + 0x74, 0x6D, 0x00, 0xB5, 0x3A, 0x0B, 0x7B, 0xDA, 0xB8, 0xB2, 0x7F, 0xC5, 0x71, 0xCF, 0x66, 0xED, + 0x83, 0x31, 0x90, 0xA4, 0xD9, 0xD6, 0xC4, 0xC9, 0x42, 0x92, 0x36, 0x6D, 0xF3, 0x6A, 0x80, 0xB6, + 0x69, 0x4F, 0xEE, 0x7E, 0xC2, 0x16, 0xA0, 0xC6, 0x96, 0x5D, 0x5B, 0x0E, 0x49, 0x59, 0xFE, 0xFB, + 0x9D, 0x91, 0x6C, 0xB0, 0x09, 0x69, 0x77, 0xCF, 0xBD, 0xBB, 0xDD, 0x2D, 0x92, 0x46, 0x33, 0x9A, + 0x19, 0xCD, 0x53, 0xDE, 0xBD, 0x8D, 0xA3, 0x8B, 0xC3, 0xFE, 0xF5, 0xE5, 0xB1, 0x36, 0x11, 0x61, + 0xB0, 0xBF, 0x87, 0x7F, 0x6B, 0x01, 0xE1, 0x63, 0x97, 0xF2, 0xFD, 0x3D, 0xC1, 0x44, 0x40, 0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C, 0x72, 0x39, 0xB0, 0xBF, 0x07, 0x5D, 0x33, 0x2A, 0x41, 0x79, 0xB1, 0x26, + 0x9B, 0xE6, 0x7C, 0x02, 0x82, 0x01, 0x70, 0xB1, 0xA3, 0x48, 0xCD, 0x2B, 0xCB, 0x98, 0x9B, 0x57, + 0x96, 0x54, 0xE2, 0x5F, 0x59, 0xCC, 0xDB, 0x9F, 0xFC, 0xDB, 0x4C, 0xF9, 0x7F, 0x5B, 0x28, 0x36, + 0x32, 0xF9, 0xE1, 0x09, 0xF7, 0x56, 0x3F, 0x45, 0xAD, 0x47, 0x51, 0xBB, 0xF7, 0xFF, 0x17, 0x53, + 0xE8, 0x9D, 0x36, 0x92, 0x29, 0x00, 0x00 +}; + +///////////////////////////////////////////////// + +#define SPIFFS_MAXLENGTH_FILEPATH 32 + +const char *excludeListFile = "/.exclude.files"; + +typedef struct ExcludeListS +{ + char *item; + ExcludeListS *next; +} ExcludeList; + +static ExcludeList *excludes = NULL; + +///////////////////////////////////////////////// + +static bool matchWild(const char *pattern, const char *testee) +{ + const char *nxPat = NULL, *nxTst = NULL; + + while (*testee) + { + if (( *pattern == '?' ) || (*pattern == *testee)) + { + pattern++; + testee++; + continue; + } + + if (*pattern == '*') + { + nxPat = pattern++; + nxTst = testee; + continue; + } + + if (nxPat) + { + pattern = nxPat + 1; + testee = ++nxTst; + continue; + } + + return false; + } + + while (*pattern == '*') + { + pattern++; + } + + return (*pattern == 0); +} + +///////////////////////////////////////////////// + +static bool addExclude(const char *item) +{ + size_t len = strlen(item); + + if (!len) + { + return false; + } + + ExcludeList *e = (ExcludeList *)malloc(sizeof(ExcludeList)); + + if (!e) + { + return false; + } + + e->item = (char *)malloc(len + 1); + + if (!e->item) + { + free(e); + return false; + } + + memcpy(e->item, item, len + 1); + e->next = excludes; + excludes = e; + + return true; +} + +///////////////////////////////////////////////// + +static void loadExcludeList(fs::FS &_fs, const char *filename) +{ + static char linebuf[SPIFFS_MAXLENGTH_FILEPATH]; + fs::File excludeFile = _fs.open(filename, "r"); + + if (!excludeFile) + { + //addExclude("/*.js.gz"); + return; + } + + if (excludeFile.isDirectory()) + { + excludeFile.close(); + return; + } + + if (excludeFile.size() > 0) + { + uint8_t idx; + bool isOverflowed = false; + + while (excludeFile.available()) + { + linebuf[0] = '\0'; + idx = 0; + int lastChar; + + do + { + lastChar = excludeFile.read(); + + if (lastChar != '\r') + { + linebuf[idx++] = (char) lastChar; + } + } while ((lastChar >= 0) && (lastChar != '\n') && (idx < SPIFFS_MAXLENGTH_FILEPATH)); + + if (isOverflowed) + { + isOverflowed = (lastChar != '\n'); + continue; + } + + isOverflowed = (idx >= SPIFFS_MAXLENGTH_FILEPATH); + linebuf[idx - 1] = '\0'; + + if (!addExclude(linebuf)) + { + excludeFile.close(); + return; + } + } + } + + excludeFile.close(); +} + +///////////////////////////////////////////////// + +static bool isExcluded(fs::FS &_fs, const char *filename) +{ + if (excludes == NULL) + { + loadExcludeList(_fs, excludeListFile); + } + + ExcludeList *e = excludes; + + while (e) + { + if (matchWild(e->item, filename)) + { + return true; + } + + e = e->next; + } + + return false; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +// WEB HANDLER IMPLEMENTATION + +SPIFFSEditor::SPIFFSEditor(const fs::FS& fs, const String& username, const String& password) + : _fs(fs) + , _username(username) + , _password(password) + , _authenticated(false) + , _startTime(0) +{} + +///////////////////////////////////////////////// + +bool SPIFFSEditor::canHandle(AsyncWebServerRequest *request) +{ + if (request->url().equalsIgnoreCase("/edit")) + { + if (request->method() == HTTP_GET) + { + if (request->hasParam("list")) + return true; + + if (request->hasParam("edit")) + { + request->_tempFile = _fs.open(request->arg("edit"), "r"); + + if (!request->_tempFile) + { + return false; + } + + if (request->_tempFile.isDirectory()) + { + request->_tempFile.close(); + return false; + } + } + + if (request->hasParam("download")) + { + request->_tempFile = _fs.open(request->arg("download"), "r"); + + if (!request->_tempFile) + { + return false; + } + + if (request->_tempFile.isDirectory()) + { + request->_tempFile.close(); + return false; + } + } + + request->addInterestingHeader("If-Modified-Since"); + return true; + } + + else if (request->method() == HTTP_POST) + return true; + else if (request->method() == HTTP_DELETE) + return true; + else if (request->method() == HTTP_PUT) + return true; + } + + return false; +} + +///////////////////////////////////////////////// + +void SPIFFSEditor::handleRequest(AsyncWebServerRequest *request) +{ + if (_username.length() && _password.length() && !request->authenticate(_username.c_str(), _password.c_str())) + return request->requestAuthentication(); + + if (request->method() == HTTP_GET) + { + if (request->hasParam("list")) + { + String path = request->getParam("list")->value(); + File dir = _fs.open(path); + path = String(); + String output = "["; + + File entry = dir.openNextFile(); + + while (entry) + { + if (isExcluded(_fs, entry.name())) + { + entry = dir.openNextFile(); + continue; + } + + if (output != "[") + output += ','; + + output += "{\"type\":\""; + output += "file"; + output += "\",\"name\":\""; + output += String(entry.name()); + output += "\",\"size\":"; + output += String(entry.size()); + output += "}"; + + entry = dir.openNextFile(); + } + + dir.close(); + output += "]"; + request->send(200, "application/json", output); + output = String(); + } + else if (request->hasParam("edit") || request->hasParam("download")) + { + request->send(request->_tempFile, request->_tempFile.name(), String(), request->hasParam("download")); + } + else + { + const char * buildTime = __DATE__ " " __TIME__ " GMT"; + + if (request->header("If-Modified-Since").equals(buildTime)) + { + request->send(304); + } + else + { + AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", edit_htm_gz, edit_htm_gz_len); + response->addHeader("Content-Encoding", "gzip"); + response->addHeader("Last-Modified", buildTime); + request->send(response); + } + } + } + else if (request->method() == HTTP_DELETE) + { + if (request->hasParam("path", true)) + { + _fs.remove(request->getParam("path", true)->value()); + request->send(200, "", "DELETE: " + request->getParam("path", true)->value()); + } + else + request->send(404); + } + else if (request->method() == HTTP_POST) + { + if (request->hasParam("data", true, true) && _fs.exists(request->getParam("data", true, true)->value())) + request->send(200, "", "UPLOADED: " + request->getParam("data", true, true)->value()); + else + request->send(500); + } + else if (request->method() == HTTP_PUT) + { + if (request->hasParam("path", true)) + { + String filename = request->getParam("path", true)->value(); + + if (_fs.exists(filename)) + { + request->send(200); + } + else + { + fs::File f = _fs.open(filename, "w"); + + if (f) + { + f.write((uint8_t)0x00); + f.close(); + request->send(200, "", "CREATE: " + filename); + } + else + { + request->send(500); + } + } + } + else + request->send(400); + } +} + +///////////////////////////////////////////////// + +void SPIFFSEditor::handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, + size_t len, bool final) +{ + if (!index) + { + if (!_username.length() || request->authenticate(_username.c_str(), _password.c_str())) + { + _authenticated = true; + request->_tempFile = _fs.open(filename, "w"); + _startTime = millis(); + } + } + + if (_authenticated && request->_tempFile) + { + if (len) + { + request->_tempFile.write(data, len); + } + + if (final) + { + request->_tempFile.close(); + } + } +} diff --git a/src/ESP32_ENC_SPIFFSEditor.h b/src/ESP32_ENC_SPIFFSEditor.h new file mode 100644 index 0000000..9cd1901 --- /dev/null +++ b/src/ESP32_ENC_SPIFFSEditor.h @@ -0,0 +1,63 @@ +/**************************************************************************************************************************** + ESP32_ENC_SPIFFSEditor.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef ESP32_ENC_SPIFFSEditor_H_ +#define ESP32_ENC_SPIFFSEditor_H_ + +#include "AsyncWebServer_ESP32_ENC.h" + +///////////////////////////////////////////////// + +class SPIFFSEditor: public AsyncWebHandler +{ + private: + fs::FS _fs; + String _username; + String _password; + bool _authenticated; + uint32_t _startTime; + + public: + SPIFFSEditor(const fs::FS& fs, const String& username = String(), const String& password = String()); + virtual bool canHandle(AsyncWebServerRequest *request) override final; + virtual void handleRequest(AsyncWebServerRequest *request) override final; + virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, + size_t len, bool final) override final; + + virtual bool isRequestHandlerTrivial() override final + { + return false; + } +}; + +///////////////////////////////////////////////// + +#endif // SPIFFSEditor_H_ diff --git a/src/StringArray.h b/src/StringArray.h new file mode 100644 index 0000000..e4a206d --- /dev/null +++ b/src/StringArray.h @@ -0,0 +1,351 @@ +/**************************************************************************************************************************** + StringArray.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef STRINGARRAY_H_ +#define STRINGARRAY_H_ + +#include "stddef.h" +#include "WString.h" + +///////////////////////////////////////////////// + +template +class LinkedListNode +{ + T _value; + + public: + LinkedListNode* next; + LinkedListNode(const T val): _value(val), next(nullptr) {} + ~LinkedListNode() {} + + ///////////////////////////////////////////////// + + inline const T& value() const + { + return _value; + }; + + ///////////////////////////////////////////////// + + inline T& value() + { + return _value; + } +}; + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +template class Item = LinkedListNode> +class LinkedList +{ + public: + typedef Item ItemType; + typedef std::function OnRemove; + typedef std::function Predicate; + + private: + ItemType* _root; + OnRemove _onRemove; + + class Iterator + { + ItemType* _node; + + public: + Iterator(ItemType* current = nullptr) : _node(current) {} + Iterator(const Iterator& i) : _node(i._node) {} + + ///////////////////////////////////////////////// + + inline Iterator& operator ++() + { + _node = _node->next; + return *this; + } + + ///////////////////////////////////////////////// + + inline bool operator != (const Iterator& i) const + { + return _node != i._node; + } + + ///////////////////////////////////////////////// + + inline const T& operator * () const + { + return _node->value(); + } + + ///////////////////////////////////////////////// + + inline const T* operator -> () const + { + return &_node->value(); + } + }; + + public: + typedef const Iterator ConstIterator; + + ///////////////////////////////////////////////// + + inline ConstIterator begin() const + { + return ConstIterator(_root); + } + + ///////////////////////////////////////////////// + + inline ConstIterator end() const + { + return ConstIterator(nullptr); + } + + ///////////////////////////////////////////////// + + LinkedList(OnRemove onRemove) : _root(nullptr), _onRemove(onRemove) {} + ~LinkedList() {} + + ///////////////////////////////////////////////// + + void add(const T& t) + { + auto it = new ItemType(t); + + if (!_root) + { + _root = it; + } + else + { + auto i = _root; + + while (i->next) + i = i->next; + + i->next = it; + } + } + + ///////////////////////////////////////////////// + + inline T& front() const + { + return _root->value(); + } + + ///////////////////////////////////////////////// + + inline bool isEmpty() const + { + return _root == nullptr; + } + + ///////////////////////////////////////////////// + + size_t length() const + { + size_t i = 0; + auto it = _root; + + while (it) + { + i++; + it = it->next; + } + + return i; + } + + ///////////////////////////////////////////////// + + size_t count_if(Predicate predicate) const + { + size_t i = 0; + auto it = _root; + + while (it) + { + if (!predicate) + { + i++; + } + else if (predicate(it->value())) + { + i++; + } + + it = it->next; + } + + return i; + } + + ///////////////////////////////////////////////// + + const T* nth(size_t N) const + { + size_t i = 0; + auto it = _root; + + while (it) + { + if (i++ == N) + return &(it->value()); + + it = it->next; + } + + return nullptr; + } + + ///////////////////////////////////////////////// + + bool remove(const T& t) + { + auto it = _root; + auto pit = _root; + + while (it) + { + if (it->value() == t) + { + if (it == _root) + { + _root = _root->next; + } + else + { + pit->next = it->next; + } + + if (_onRemove) + { + _onRemove(it->value()); + } + + delete it; + return true; + } + + pit = it; + it = it->next; + } + + return false; + } + + ///////////////////////////////////////////////// + + bool remove_first(Predicate predicate) + { + auto it = _root; + auto pit = _root; + + while (it) + { + if (predicate(it->value())) + { + if (it == _root) + { + _root = _root->next; + } + else + { + pit->next = it->next; + } + + if (_onRemove) + { + _onRemove(it->value()); + } + + delete it; + return true; + } + + pit = it; + it = it->next; + } + + return false; + } + + ///////////////////////////////////////////////// + + void free() + { + while (_root != nullptr) + { + auto it = _root; + _root = _root->next; + + if (_onRemove) + { + _onRemove(it->value()); + } + + delete it; + } + + _root = nullptr; + } +}; + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +class StringArray : public LinkedList +{ + public: + + StringArray() : LinkedList(nullptr) {} + + ///////////////////////////////////////////////// + + bool containsIgnoreCase(const String& str) + { + for (const auto& s : *this) + { + if (str.equalsIgnoreCase(s)) + { + return true; + } + } + + return false; + } +}; + +#endif /* STRINGARRAY_H_ */ diff --git a/src/WebAuthentication.cpp b/src/WebAuthentication.cpp new file mode 100644 index 0000000..d896a47 --- /dev/null +++ b/src/WebAuthentication.cpp @@ -0,0 +1,358 @@ +/**************************************************************************************************************************** + WebAuthentication.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "WebAuthentication.h" +#include + +#include "mbedtls/md5.h" +#include "mbedtls/version.h" + +///////////////////////////////////////////////// + +// Basic Auth hash = base64("username:password") + +bool checkBasicAuthentication(const char * hash, const char * username, const char * password) +{ + if (username == NULL || password == NULL || hash == NULL) + return false; + + size_t toencodeLen = strlen(username) + strlen(password) + 1; + size_t encodedLen = base64_encode_expected_len(toencodeLen); + + if (strlen(hash) != encodedLen) + return false; + + char *toencode = new char[toencodeLen + 1]; + + if (toencode == NULL) + { + return false; + } + + char *encoded = new char[base64_encode_expected_len(toencodeLen) + 1]; + + if (encoded == NULL) + { + delete[] toencode; + + return false; + } + + sprintf(toencode, "%s:%s", username, password); + + if (base64_encode_chars(toencode, toencodeLen, encoded) > 0 && memcmp(hash, encoded, encodedLen) == 0) + { + delete[] toencode; + delete[] encoded; + + return true; + } + + delete[] toencode; + delete[] encoded; + + return false; +} + +///////////////////////////////////////////////// + +static bool getMD5(uint8_t * data, uint16_t len, char * output) +{ + //33 bytes or more + mbedtls_md5_context _ctx; + uint8_t i; + uint8_t * _buf = (uint8_t*)malloc(16); + + if (_buf == NULL) + return false; + + memset(_buf, 0x00, 16); + + mbedtls_md5_init(&_ctx); + +#if (MBEDTLS_VERSION_NUMBER < 0x02070000) + // Superseded from v2.7.0 + mbedtls_md5_starts(&_ctx); + mbedtls_md5_update(&_ctx, data, len); + mbedtls_md5_finish(&_ctx, _buf); +#else + mbedtls_md5_starts_ret(&_ctx); + mbedtls_md5_update_ret(&_ctx, data, len); + mbedtls_md5_finish_ret(&_ctx, _buf); +#endif + + for (i = 0; i < 16; i++) + { + sprintf(output + (i * 2), "%02x", _buf[i]); + } + + free(_buf); + + return true; +} + +///////////////////////////////////////////////// + +static String genRandomMD5() +{ + uint32_t r = rand(); + char * out = (char*)malloc(33); + + if (out == NULL || !getMD5((uint8_t*)(&r), 4, out)) + return ""; + + String res = String(out); + free(out); + + return res; +} + +///////////////////////////////////////////////// + +static String stringMD5(const String& in) +{ + char * out = (char*)malloc(33); + + if (out == NULL || !getMD5((uint8_t*)(in.c_str()), in.length(), out)) + return ""; + + String res = String(out); + free(out); + + return res; +} + +///////////////////////////////////////////////// + +String generateDigestHash(const char * username, const char * password, const char * realm) +{ + if (username == NULL || password == NULL || realm == NULL) + { + return ""; + } + + char * out = (char*)malloc(33); + String res = String(username); + res.concat(":"); + res.concat(realm); + res.concat(":"); + String in = res; + in.concat(password); + + if (out == NULL || !getMD5((uint8_t*)(in.c_str()), in.length(), out)) + return ""; + + res.concat(out); + free(out); + + return res; +} + +///////////////////////////////////////////////// + +String requestDigestAuthentication(const char * realm) +{ + String header = "realm=\""; + + if (realm == NULL) + header.concat("asyncesp"); + else + header.concat(realm); + + header.concat( "\", qop=\"auth\", nonce=\""); + header.concat(genRandomMD5()); + header.concat("\", opaque=\""); + header.concat(genRandomMD5()); + header.concat("\""); + + return header; +} + +///////////////////////////////////////////////// + +bool checkDigestAuthentication(const char * header, const char * method, const char * username, const char * password, + const char * realm, + bool passwordIsHash, const char * nonce, const char * opaque, const char * uri) +{ + if (username == NULL || password == NULL || header == NULL || method == NULL) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, missing required fields")); + + return false; + } + + String myHeader = String(header); + int nextBreak = myHeader.indexOf(","); + + if (nextBreak < 0) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, no variables")); + + return false; + } + + String myUsername = String(); + String myRealm = String(); + String myNonce = String(); + String myUri = String(); + String myResponse = String(); + String myQop = String(); + String myNc = String(); + String myCnonce = String(); + + myHeader += ", "; + + do + { + String avLine = myHeader.substring(0, nextBreak); + avLine.trim(); + myHeader = myHeader.substring(nextBreak + 1); + nextBreak = myHeader.indexOf(","); + + int eqSign = avLine.indexOf("="); + + if (eqSign < 0) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, no = sign")); + + return false; + } + + String varName = avLine.substring(0, eqSign); + avLine = avLine.substring(eqSign + 1); + + if (avLine.startsWith("\"")) + { + avLine = avLine.substring(1, avLine.length() - 1); + } + + if (varName.equals("username")) + { + if (!avLine.equals(username)) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, username")); + + return false; + } + + AWS_LOGINFO1(F("checkDigestAuthentication: myUsername ="), myUsername); + + myUsername = avLine; + } + else if (varName.equals("realm")) + { + if (realm != NULL && !avLine.equals(realm)) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, realm")); + + return false; + } + + AWS_LOGINFO1(F("checkDigestAuthentication: myRealm ="), myRealm); + + myRealm = avLine; + } + else if (varName.equals("nonce")) + { + if (nonce != NULL && !avLine.equals(nonce)) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, nonce")); + + return false; + } + + AWS_LOGINFO1(F("checkDigestAuthentication: myNonce ="), myNonce); + + myNonce = avLine; + } + else if (varName.equals("opaque")) + { + if (opaque != NULL && !avLine.equals(opaque)) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, opaque")); + + return false; + } + } + else if (varName.equals("uri")) + { + if (uri != NULL && !avLine.equals(uri)) + { + AWS_LOGERROR(F("checkDigestAuthentication: AUTH FAIL, uri")); + + return false; + } + + AWS_LOGINFO1(F("checkDigestAuthentication: myUri ="), myUri); + + myUri = avLine; + } + else if (varName.equals("response")) + { + AWS_LOGINFO1(F("checkDigestAuthentication: myResponse ="), myResponse); + + myResponse = avLine; + } + else if (varName.equals("qop")) + { + AWS_LOGINFO1(F("checkDigestAuthentication: myQop ="), myQop); + + myQop = avLine; + } + else if (varName.equals("nc")) + { + AWS_LOGINFO1(F("checkDigestAuthentication: myNc ="), myNc); + + myNc = avLine; + } + else if (varName.equals("cnonce")) + { + AWS_LOGINFO1(F("checkDigestAuthentication: myCnonce ="), myCnonce); + + myCnonce = avLine; + } + } while (nextBreak > 0); + + String ha1 = (passwordIsHash) ? String(password) : stringMD5(myUsername + ":" + myRealm + ":" + String(password)); + String ha2 = String(method) + ":" + myUri; + String response = ha1 + ":" + myNonce + ":" + myNc + ":" + myCnonce + ":" + myQop + ":" + stringMD5(ha2); + + if (myResponse.equals(stringMD5(response))) + { + AWS_LOGINFO(F("AUTH SUCCESS")); + + return true; + } + + AWS_LOGINFO(F("AUTH FAIL: password")); + + return false; +} diff --git a/src/WebAuthentication.h b/src/WebAuthentication.h new file mode 100644 index 0000000..6812864 --- /dev/null +++ b/src/WebAuthentication.h @@ -0,0 +1,53 @@ +/**************************************************************************************************************************** + WebAuthentication.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef WEB_AUTHENTICATION_H_ +#define WEB_AUTHENTICATION_H_ + +#include "Arduino.h" + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +///////////////////////////////////////////////// + +bool checkBasicAuthentication(const char * header, const char * username, const char * password); +String requestDigestAuthentication(const char * realm); + +bool checkDigestAuthentication(const char * header, const char * method, const char * username, const char * password, + const char * realm, + bool passwordIsHash, const char * nonce, const char * opaque, const char * uri); + +//for storing hashed versions on the device that can be authenticated against +String generateDigestHash(const char * username, const char * password, const char * realm); + +///////////////////////////////////////////////// + +#endif // WEB_AUTHENTICATION_H_ diff --git a/src/WebHandlerImpl.h b/src/WebHandlerImpl.h new file mode 100644 index 0000000..a5e27e0 --- /dev/null +++ b/src/WebHandlerImpl.h @@ -0,0 +1,243 @@ +/**************************************************************************************************************************** + WebHandlerImpl.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef ASYNCWEBSERVERHANDLERIMPL_H_ +#define ASYNCWEBSERVERHANDLERIMPL_H_ + +#include + +#ifdef ASYNCWEBSERVER_REGEX + #include +#endif + +#include "stddef.h" +#include + +#include "AsyncWebServer_ESP32_ENC_Debug.h" + +///////////////////////////////////////////////// + +class AsyncStaticWebHandler: public AsyncWebHandler +{ + using File = fs::File; + using FS = fs::FS; + + private: + bool _getFile(AsyncWebServerRequest *request); + bool _fileExists(AsyncWebServerRequest *request, const String& path); + uint8_t _countBits(const uint8_t value) const; + + protected: + FS _fs; + String _uri; + String _path; + String _default_file; + String _cache_control; + String _last_modified; + AwsTemplateProcessor _callback; + bool _isDir; + bool _gzipFirst; + uint8_t _gzipStats; + + public: + AsyncStaticWebHandler(const char* uri, FS& fs, const char* path, const char* cache_control); + virtual bool canHandle(AsyncWebServerRequest *request) override final; + virtual void handleRequest(AsyncWebServerRequest *request) override final; + AsyncStaticWebHandler& setIsDir(bool isDir); + AsyncStaticWebHandler& setDefaultFile(const char* filename); + AsyncStaticWebHandler& setCacheControl(const char* cache_control); + AsyncStaticWebHandler& setLastModified(const char* last_modified); + AsyncStaticWebHandler& setLastModified(struct tm* last_modified); + + AsyncStaticWebHandler& setTemplateProcessor(AwsTemplateProcessor newCallback) + { + _callback = newCallback; + return *this; + } +}; + +///////////////////////////////////////////////// + +class AsyncCallbackWebHandler: public AsyncWebHandler +{ + private: + + protected: + String _uri; + WebRequestMethodComposite _method; + ArRequestHandlerFunction _onRequest; + ArUploadHandlerFunction _onUpload; + ArBodyHandlerFunction _onBody; + bool _isRegex; + + public: + AsyncCallbackWebHandler() : _uri(), _method(HTTP_ANY), _onRequest(NULL), _onUpload(NULL), _onBody(NULL), + _isRegex(false) {} + + ///////////////////////////////////////////////// + + inline void setUri(const String& uri) + { + _uri = uri; + _isRegex = uri.startsWith("^") && uri.endsWith("$"); + } + + ///////////////////////////////////////////////// + + inline void setMethod(WebRequestMethodComposite method) + { + _method = method; + } + + ///////////////////////////////////////////////// + + inline void onRequest(ArRequestHandlerFunction fn) + { + _onRequest = fn; + } + + ///////////////////////////////////////////////// + + inline void onUpload(ArUploadHandlerFunction fn) + { + _onUpload = fn; + } + + ///////////////////////////////////////////////// + + inline void onBody(ArBodyHandlerFunction fn) + { + _onBody = fn; + } + + ///////////////////////////////////////////////// + + virtual bool canHandle(AsyncWebServerRequest *request) override final + { + if (!_onRequest) + return false; + + if (!(_method & request->method())) + return false; + +#ifdef ASYNCWEBSERVER_REGEX + + if (_isRegex) + { + std::regex pattern(_uri.c_str()); + std::smatch matches; + std::string s(request->url().c_str()); + + if (std::regex_search(s, matches, pattern)) + { + for (size_t i = 1; i < matches.size(); ++i) + { + // start from 1 + request->_addPathParam(matches[i].str().c_str()); + } + } + else + { + return false; + } + } + else +#endif + if (_uri.length() && _uri.startsWith("/*.")) + { + String uriTemplate = String (_uri); + uriTemplate = uriTemplate.substring(uriTemplate.lastIndexOf(".")); + + if (!request->url().endsWith(uriTemplate)) + return false; + } + else if (_uri.length() && _uri.endsWith("*")) + { + String uriTemplate = String(_uri); + uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1); + + if (!request->url().startsWith(uriTemplate)) + return false; + } + else if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/"))) + return false; + + request->addInterestingHeader("ANY"); + + return true; + } + + ///////////////////////////////////////////////// + + virtual void handleRequest(AsyncWebServerRequest *request) override final + { + if ((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str())) + return request->requestAuthentication(); + + if (_onRequest) + _onRequest(request); + else + request->send(500); + } + + ///////////////////////////////////////////////// + + virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, + size_t len, bool final) override final + { + if ((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str())) + return request->requestAuthentication(); + + if (_onUpload) + _onUpload(request, filename, index, data, len, final); + } + + ///////////////////////////////////////////////// + + virtual void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, + size_t total) override final + { + if ((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str())) + return request->requestAuthentication(); + + if (_onBody) + _onBody(request, data, len, index, total); + } + + ///////////////////////////////////////////////// + + virtual bool isRequestHandlerTrivial() override final + { + return _onRequest ? false : true; + } +}; + +#endif /* ASYNCWEBSERVERHANDLERIMPL_H_ */ diff --git a/src/WebHandlers.cpp b/src/WebHandlers.cpp new file mode 100644 index 0000000..6e59871 --- /dev/null +++ b/src/WebHandlers.cpp @@ -0,0 +1,292 @@ +/**************************************************************************************************************************** + WebHandlers.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "AsyncWebServer_ESP32_ENC.h" + +#include "WebHandlerImpl.h" + +///////////////////////////////////////////////// + +AsyncStaticWebHandler::AsyncStaticWebHandler(const char* uri, FS& fs, const char* path, const char* cache_control) + : _fs(fs), _uri(uri), _path(path), _default_file("index.htm"), _cache_control(cache_control), _last_modified(""), + _callback(nullptr) +{ + // Ensure leading '/' + if (_uri.length() == 0 || _uri[0] != '/') + _uri = "/" + _uri; + + if (_path.length() == 0 || _path[0] != '/') + _path = "/" + _path; + + // If path ends with '/' we assume a hint that this is a directory to improve performance. + // However - if it does not end with '/' we, can't assume a file, path can still be a directory. + _isDir = _path[_path.length() - 1] == '/'; + + // Remove the trailing '/' so we can handle default file + // Notice that root will be "" not "/" + if (_uri[_uri.length() - 1] == '/') + _uri = _uri.substring(0, _uri.length() - 1); + + if (_path[_path.length() - 1] == '/') + _path = _path.substring(0, _path.length() - 1); + + // Reset stats + _gzipFirst = false; + _gzipStats = 0xF8; +} + +///////////////////////////////////////////////// + +AsyncStaticWebHandler& AsyncStaticWebHandler::setIsDir(bool isDir) +{ + _isDir = isDir; + + return *this; +} + +///////////////////////////////////////////////// + +AsyncStaticWebHandler& AsyncStaticWebHandler::setDefaultFile(const char* filename) +{ + _default_file = String(filename); + + return *this; +} + +///////////////////////////////////////////////// + +AsyncStaticWebHandler& AsyncStaticWebHandler::setCacheControl(const char* cache_control) +{ + _cache_control = String(cache_control); + + return *this; +} + +///////////////////////////////////////////////// + +AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(const char* last_modified) +{ + _last_modified = String(last_modified); + + return *this; +} + +///////////////////////////////////////////////// + +AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(struct tm* last_modified) +{ + char result[30]; + strftime (result, 30, "%a, %d %b %Y %H:%M:%S %Z", last_modified); + + return setLastModified((const char *)result); +} + +///////////////////////////////////////////////// + +bool AsyncStaticWebHandler::canHandle(AsyncWebServerRequest *request) +{ + if (request->method() != HTTP_GET || !request->url().startsWith(_uri) + || !request->isExpectedRequestedConnType(RCT_DEFAULT, RCT_HTTP) ) + { + return false; + } + + if (_getFile(request)) + { + // We interested in "If-Modified-Since" header to check if file was modified + if (_last_modified.length()) + request->addInterestingHeader("If-Modified-Since"); + + if (_cache_control.length()) + request->addInterestingHeader("If-None-Match"); + + AWS_LOGDEBUG("[AsyncStaticWebHandler::canHandle] TRUE"); + + return true; + } + + return false; +} + +///////////////////////////////////////////////// + +bool AsyncStaticWebHandler::_getFile(AsyncWebServerRequest *request) +{ + // Remove the found uri + String path = request->url().substring(_uri.length()); + + // We can skip the file check and look for default if request is to the root of a directory or that request path ends with '/' + bool canSkipFileCheck = (_isDir && path.length() == 0) || (path.length() && path[path.length() - 1] == '/'); + + path = _path + path; + + // Do we have a file or .gz file + if (!canSkipFileCheck && _fileExists(request, path)) + return true; + + // Can't handle if not default file + if (_default_file.length() == 0) + return false; + + // Try to add default file, ensure there is a trailing '/' ot the path. + if (path.length() == 0 || path[path.length() - 1] != '/') + path += "/"; + + path += _default_file; + + return _fileExists(request, path); +} + +///////////////////////////////////////////////// + +#define FILE_IS_REAL(f) (f == true && !f.isDirectory()) + +///////////////////////////////////////////////// + +bool AsyncStaticWebHandler::_fileExists(AsyncWebServerRequest *request, const String& path) +{ + bool fileFound = false; + bool gzipFound = false; + + String gzip = path + ".gz"; + + if (_gzipFirst) + { + request->_tempFile = _fs.open(gzip, "r"); + gzipFound = FILE_IS_REAL(request->_tempFile); + + if (!gzipFound) + { + request->_tempFile = _fs.open(path, "r"); + fileFound = FILE_IS_REAL(request->_tempFile); + } + } + else + { + request->_tempFile = _fs.open(path, "r"); + fileFound = FILE_IS_REAL(request->_tempFile); + + if (!fileFound) + { + request->_tempFile = _fs.open(gzip, "r"); + gzipFound = FILE_IS_REAL(request->_tempFile); + } + } + + bool found = fileFound || gzipFound; + + if (found) + { + // Extract the file name from the path and keep it in _tempObject + size_t pathLen = path.length(); + char * _tempPath = (char*)malloc(pathLen + 1); + snprintf(_tempPath, pathLen + 1, "%s", path.c_str()); + request->_tempObject = (void*)_tempPath; + + // Calculate gzip statistic + _gzipStats = (_gzipStats << 1) + (gzipFound ? 1 : 0); + + if (_gzipStats == 0x00) + _gzipFirst = false; // All files are not gzip + else if (_gzipStats == 0xFF) + _gzipFirst = true; // All files are gzip + else + _gzipFirst = _countBits(_gzipStats) > 4; // IF we have more gzip files - try gzip first + } + + return found; +} + +///////////////////////////////////////////////// + +uint8_t AsyncStaticWebHandler::_countBits(const uint8_t value) const +{ + uint8_t w = value; + uint8_t n; + + for (n = 0; w != 0; n++) + w &= w - 1; + + return n; +} + +///////////////////////////////////////////////// + +void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request) +{ + // Get the filename from request->_tempObject and free it + String filename = String((char*)request->_tempObject); + free(request->_tempObject); + request->_tempObject = NULL; + + if ((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str())) + return request->requestAuthentication(); + + if (request->_tempFile == true) + { + String etag = String(request->_tempFile.size()); + + if (_last_modified.length() && _last_modified == request->header("If-Modified-Since")) + { + request->_tempFile.close(); + request->send(304); // Not modified + } + else if (_cache_control.length() && request->hasHeader("If-None-Match") + && request->header("If-None-Match").equals(etag)) + { + request->_tempFile.close(); + AsyncWebServerResponse * response = new AsyncBasicResponse(304); // Not modified + + response->addHeader("Cache-Control", _cache_control); + response->addHeader("ETag", etag); + request->send(response); + } + else + { + AsyncWebServerResponse * response = new AsyncFileResponse(request->_tempFile, filename, String(), false, _callback); + + if (_last_modified.length()) + response->addHeader("Last-Modified", _last_modified); + + if (_cache_control.length()) + { + response->addHeader("Cache-Control", _cache_control); + response->addHeader("ETag", etag); + } + + request->send(response); + } + } + else + { + request->send(404); + } +} diff --git a/src/WebRequest.cpp b/src/WebRequest.cpp new file mode 100644 index 0000000..b99b13b --- /dev/null +++ b/src/WebRequest.cpp @@ -0,0 +1,1751 @@ +/**************************************************************************************************************************** + WebRequest.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +//#include "ESPAsyncWebServer.h" +#include "AsyncWebServer_ESP32_ENC.h" + +#include "WebResponseImpl.h" +#include "WebAuthentication.h" + +#ifndef ESP8266 + #define os_strlen strlen +#endif + +///////////////////////////////////////////////// + +static const String SharedEmptyString = String(); + +#define __is_param_char(c) ((c) && ((c) != '{') && ((c) != '[') && ((c) != '&') && ((c) != '=')) + +enum { PARSE_REQ_START, PARSE_REQ_HEADERS, PARSE_REQ_BODY, PARSE_REQ_END, PARSE_REQ_FAIL }; + +///////////////////////////////////////////////// + +AsyncWebServerRequest::AsyncWebServerRequest(AsyncWebServer* s, AsyncClient* c) + : _client(c) + , _server(s) + , _handler(NULL) + , _response(NULL) + , _temp() + , _parseState(0) + , _version(0) + , _method(HTTP_ANY) + , _url() + , _host() + , _contentType() + , _boundary() + , _authorization() + , _reqconntype(RCT_HTTP) + , _isDigest(false) + , _isMultipart(false) + , _isPlainPost(false) + , _expectingContinue(false) + , _contentLength(0) + , _parsedLength(0) + , _headers(LinkedList([](AsyncWebHeader * h) +{ + delete h; +})) +, _params(LinkedList([](AsyncWebParameter *p) +{ + delete p; +})) +, _pathParams(LinkedList([](String *p) +{ + delete p; +})) +, _multiParseState(0) +, _boundaryPosition(0) +, _itemStartIndex(0) +, _itemSize(0) +, _itemName() +, _itemFilename() +, _itemType() +, _itemValue() +, _itemBuffer(0) +, _itemBufferIndex(0) +, _itemIsFile(false) +, _tempObject(NULL) +{ + c->onError([](void *r, AsyncClient * c, int8_t error) + { + ESP32_ENC_AWS_UNUSED(c); + AsyncWebServerRequest *req = (AsyncWebServerRequest*)r; + req->_onError(error); + }, this); + + c->onAck([](void *r, AsyncClient * c, size_t len, uint32_t time) + { + ESP32_ENC_AWS_UNUSED(c); + AsyncWebServerRequest *req = (AsyncWebServerRequest*)r; + req->_onAck(len, time); + }, this); + + c->onDisconnect([](void *r, AsyncClient * c) + { + AsyncWebServerRequest *req = (AsyncWebServerRequest*)r; + req->_onDisconnect(); + delete c; + }, this); + + c->onTimeout([](void *r, AsyncClient * c, uint32_t time) + { + ESP32_ENC_AWS_UNUSED(c); + AsyncWebServerRequest *req = (AsyncWebServerRequest*)r; + req->_onTimeout(time); + }, this); + + c->onData([](void *r, AsyncClient * c, void *buf, size_t len) + { + ESP32_ENC_AWS_UNUSED(c); + AsyncWebServerRequest *req = (AsyncWebServerRequest*)r; + req->_onData(buf, len); + }, this); + + c->onPoll([](void *r, AsyncClient * c) + { + ESP32_ENC_AWS_UNUSED(c); + AsyncWebServerRequest *req = ( AsyncWebServerRequest*)r; + req->_onPoll(); + }, this); +} + +///////////////////////////////////////////////// + +AsyncWebServerRequest::~AsyncWebServerRequest() +{ + _headers.free(); + + _params.free(); + _pathParams.free(); + + _interestingHeaders.free(); + + if (_response != NULL) + { + delete _response; + } + + if (_tempObject != NULL) + { + free(_tempObject); + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_onData(void *buf, size_t len) +{ + size_t i = 0; + + while (true) + { + if (_parseState < PARSE_REQ_BODY) + { + // Find new line in buf + char *str = (char*)buf; + + for (i = 0; i < len; i++) + { + if (str[i] == '\n') + { + break; + } + } + + if (i == len) + { + // No new line, just add the buffer in _temp + char ch = str[len - 1]; + str[len - 1] = 0; + _temp.reserve(_temp.length() + len); + _temp.concat(str); + _temp.concat(ch); + } + else + { + // Found new line - extract it and parse + str[i] = 0; // Terminate the string at the end of the line. + _temp.concat(str); + _temp.trim(); + _parseLine(); + + if (++i < len) + { + // Still have more buffer to process + buf = str + i; + len -= i; + continue; + } + } + } + else if (_parseState == PARSE_REQ_BODY) + { + // A handler should be already attached at this point in _parseLine function. + // If handler does nothing (_onRequest is NULL), we don't need to really parse the body. + const bool needParse = _handler && !_handler->isRequestHandlerTrivial(); + + if (_isMultipart) + { + if (needParse) + { + size_t i; + + for (i = 0; i < len; i++) + { + _parseMultipartPostByte(((uint8_t*)buf)[i], i == len - 1); + _parsedLength++; + } + } + else + _parsedLength += len; + } + else + { + if (_parsedLength == 0) + { + if (_contentType.startsWith("application/x-www-form-urlencoded")) + { + _isPlainPost = true; + } + else if (_contentType == "text/plain" && __is_param_char(((char*)buf)[0])) + { + size_t i = 0; + + while (i < len && __is_param_char(((char*)buf)[i++])); + + if (i < len && ((char*)buf)[i - 1] == '=') + { + _isPlainPost = true; + } + } + } + + if (!_isPlainPost) + { + //check if authenticated before calling the body + if (_handler) + _handler->handleBody(this, (uint8_t*)buf, len, _parsedLength, _contentLength); + + _parsedLength += len; + } + else if (needParse) + { + size_t i; + + for (i = 0; i < len; i++) + { + _parsedLength++; + _parsePlainPostChar(((uint8_t*)buf)[i]); + } + } + else + { + _parsedLength += len; + } + } + + if (_parsedLength == _contentLength) + { + _parseState = PARSE_REQ_END; + + //check if authenticated before calling handleRequest and request auth instead + if (_handler) + _handler->handleRequest(this); + + else + send(501); + } + } + + break; + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_removeNotInterestingHeaders() +{ + if (_interestingHeaders.containsIgnoreCase("ANY")) + return; // nothing to do + + for (const auto& header : _headers) + { + if (!_interestingHeaders.containsIgnoreCase(header->name().c_str())) + { + _headers.remove(header); + } + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_onPoll() +{ + if (_response != NULL && _client != NULL && _client->canSend() && !_response->_finished()) + { + _response->_ack(this, 0, 0); + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_onAck(size_t len, uint32_t time) +{ + AWS_LOGDEBUG3("onAck: len =", len, ", time =", time); + + if (_response != NULL) + { + if (!_response->_finished()) + { + _response->_ack(this, len, time); + } + else + { + AsyncWebServerResponse* r = _response; + _response = NULL; + delete r; + } + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_onError(int8_t error) +{ + ESP32_ENC_AWS_UNUSED(error); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_onTimeout(uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + AWS_LOGDEBUG3("TIMEOUT: time =", time, ", state =", _client->stateToString()); + + _client->close(); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::onDisconnect (ArDisconnectHandler fn) +{ + _onDisconnectfn = fn; +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_onDisconnect() +{ + if (_onDisconnectfn) + { + _onDisconnectfn(); + } + + _server->_handleDisconnect(this); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_addParam(AsyncWebParameter *p) +{ + _params.add(p); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_addPathParam(const char *p) +{ + _pathParams.add(new String(p)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_addGetParams(const String& params) +{ + size_t start = 0; + + while (start < params.length()) + { + int end = params.indexOf('&', start); + + if (end < 0) + end = params.length(); + + int equal = params.indexOf('=', start); + + if (equal < 0 || equal > end) + equal = end; + + String name = params.substring(start, equal); + String value = equal + 1 < end ? params.substring(equal + 1, end) : String(); + _addParam(new AsyncWebParameter(urlDecode(name), urlDecode(value))); + start = end + 1; + } +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::_parseReqHead() +{ + // Split the head into method, url and version + int index = _temp.indexOf(' '); + String m = _temp.substring(0, index); + index = _temp.indexOf(' ', index + 1); + String u = _temp.substring(m.length() + 1, index); + _temp = _temp.substring(index + 1); + + if (m == "GET") + { + _method = HTTP_GET; + } + else if (m == "POST") + { + _method = HTTP_POST; + } + else if (m == "DELETE") + { + _method = HTTP_DELETE; + } + else if (m == "PUT") + { + _method = HTTP_PUT; + } + else if (m == "PATCH") + { + _method = HTTP_PATCH; + } + else if (m == "HEAD") + { + _method = HTTP_HEAD; + } + else if (m == "OPTIONS") + { + _method = HTTP_OPTIONS; + } + + String g = String(); + index = u.indexOf('?'); + + if (index > 0) + { + g = u.substring(index + 1); + u = u.substring(0, index); + } + + _url = urlDecode(u); + _addGetParams(g); + + if (!_temp.startsWith("HTTP/1.0")) + _version = 1; + + _temp = String(); + + return true; +} + +///////////////////////////////////////////////// + +bool strContains(String src, String find, bool mindcase = true) +{ + int pos = 0, i = 0; + const int slen = src.length(); + const int flen = find.length(); + + if (slen < flen) + return false; + + while (pos <= (slen - flen)) + { + for (i = 0; i < flen; i++) + { + if (mindcase) + { + if (src[pos + i] != find[i]) + i = flen + 1; // no match + } + else if (tolower(src[pos + i]) != tolower(find[i])) + i = flen + 1; // no match + } + + if (i == flen) + return true; + + pos++; + } + + return false; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::_parseReqHeader() +{ + int index = _temp.indexOf(':'); + + if (index) + { + String name = _temp.substring(0, index); + String value = _temp.substring(index + 2); + + if (name.equalsIgnoreCase("Host")) + { + _host = value; + } + else if (name.equalsIgnoreCase("Content-Type")) + { + _contentType = value.substring(0, value.indexOf(';')); + + if (value.startsWith("multipart/")) + { + _boundary = value.substring(value.indexOf('=') + 1); + _boundary.replace("\"", ""); + _isMultipart = true; + } + } + else if (name.equalsIgnoreCase("Content-Length")) + { + _contentLength = atoi(value.c_str()); + } + else if (name.equalsIgnoreCase("Expect") && value == "100-continue") + { + _expectingContinue = true; + } + else if (name.equalsIgnoreCase("Authorization")) + { + if (value.length() > 5 && value.substring(0, 5).equalsIgnoreCase("Basic")) + { + _authorization = value.substring(6); + } + else if (value.length() > 6 && value.substring(0, 6).equalsIgnoreCase("Digest")) + { + _isDigest = true; + _authorization = value.substring(7); + } + } + else + { + if (name.equalsIgnoreCase("Upgrade") && value.equalsIgnoreCase("websocket")) + { + // WebSocket request can be uniquely identified by header: [Upgrade: websocket] + _reqconntype = RCT_WS; + } + else + { + if (name.equalsIgnoreCase("Accept") && strContains(value, "text/event-stream", false)) + { + // WebEvent request can be uniquely identified by header: [Accept: text/event-stream] + _reqconntype = RCT_EVENT; + } + } + } + + _headers.add(new AsyncWebHeader(name, value)); + } + + _temp = String(); + + return true; +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_parsePlainPostChar(uint8_t data) +{ + if (data && (char)data != '&') + _temp += (char)data; + + if (!data || (char)data == '&' || _parsedLength == _contentLength) + { + String name = "body"; + String value = _temp; + + if (!_temp.startsWith("{") && !_temp.startsWith("[") && _temp.indexOf('=') > 0) + { + name = _temp.substring(0, _temp.indexOf('=')); + value = _temp.substring(_temp.indexOf('=') + 1); + } + + _addParam(new AsyncWebParameter(urlDecode(name), urlDecode(value), true)); + _temp = String(); + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_handleUploadByte(uint8_t data, bool last) +{ + _itemBuffer[_itemBufferIndex++] = data; + + if (last || _itemBufferIndex == 1460) + { + //check if authenticated before calling the upload + if (_handler) + _handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, false); + + _itemBufferIndex = 0; + } +} + +///////////////////////////////////////////////// + +enum +{ + EXPECT_BOUNDARY, + PARSE_HEADERS, + WAIT_FOR_RETURN1, + EXPECT_FEED1, + EXPECT_DASH1, + EXPECT_DASH2, + BOUNDARY_OR_DATA, + DASH3_OR_RETURN2, + EXPECT_FEED2, + PARSING_FINISHED, + PARSE_ERROR +}; + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last) +{ +#define itemWriteByte(b) do { _itemSize++; if(_itemIsFile) _handleUploadByte(b, last); else _itemValue+=(char)(b); } while(0) + + if (!_parsedLength) + { + _multiParseState = EXPECT_BOUNDARY; + _temp = String(); + _itemName = String(); + _itemFilename = String(); + _itemType = String(); + } + + if (_multiParseState == WAIT_FOR_RETURN1) + { + if (data != '\r') + { + itemWriteByte(data); + } + else + { + _multiParseState = EXPECT_FEED1; + } + } + else if (_multiParseState == EXPECT_BOUNDARY) + { + if (_parsedLength < 2 && data != '-') + { + _multiParseState = PARSE_ERROR; + + return; + } + else if (_parsedLength - 2 < _boundary.length() && _boundary.c_str()[_parsedLength - 2] != data) + { + _multiParseState = PARSE_ERROR; + + return; + } + else if (_parsedLength - 2 == _boundary.length() && data != '\r') + { + _multiParseState = PARSE_ERROR; + + return; + } + else if (_parsedLength - 3 == _boundary.length()) + { + if (data != '\n') + { + _multiParseState = PARSE_ERROR; + + return; + } + + _multiParseState = PARSE_HEADERS; + _itemIsFile = false; + } + } + else if (_multiParseState == PARSE_HEADERS) + { + if ((char)data != '\r' && (char)data != '\n') + _temp += (char)data; + + if ((char)data == '\n') + { + if (_temp.length()) + { + if (_temp.length() > 12 && _temp.substring(0, 12).equalsIgnoreCase("Content-Type")) + { + _itemType = _temp.substring(14); + _itemIsFile = true; + } + else if (_temp.length() > 19 && _temp.substring(0, 19).equalsIgnoreCase("Content-Disposition")) + { + _temp = _temp.substring(_temp.indexOf(';') + 2); + + while (_temp.indexOf(';') > 0) + { + String name = _temp.substring(0, _temp.indexOf('=')); + String nameVal = _temp.substring(_temp.indexOf('=') + 2, _temp.indexOf(';') - 1); + + if (name == "name") + { + _itemName = nameVal; + } + else if (name == "filename") + { + _itemFilename = nameVal; + _itemIsFile = true; + } + + _temp = _temp.substring(_temp.indexOf(';') + 2); + } + + String name = _temp.substring(0, _temp.indexOf('=')); + String nameVal = _temp.substring(_temp.indexOf('=') + 2, _temp.length() - 1); + + if (name == "name") + { + _itemName = nameVal; + } + else if (name == "filename") + { + _itemFilename = nameVal; + _itemIsFile = true; + } + } + + _temp = String(); + } + else + { + _multiParseState = WAIT_FOR_RETURN1; + + //value starts from here + _itemSize = 0; + _itemStartIndex = _parsedLength; + _itemValue = String(); + + if (_itemIsFile) + { + if (_itemBuffer) + free(_itemBuffer); + + _itemBuffer = (uint8_t*) malloc(1460); + + if (_itemBuffer == NULL) + { + _multiParseState = PARSE_ERROR; + + return; + } + + _itemBufferIndex = 0; + } + } + } + } + else if (_multiParseState == EXPECT_FEED1) + { + if (data != '\n') + { + _multiParseState = WAIT_FOR_RETURN1; + itemWriteByte('\r'); + + _parseMultipartPostByte(data, last); + } + else + { + _multiParseState = EXPECT_DASH1; + } + } + else if (_multiParseState == EXPECT_DASH1) + { + if (data != '-') + { + _multiParseState = WAIT_FOR_RETURN1; + itemWriteByte('\r'); + itemWriteByte('\n'); + + _parseMultipartPostByte(data, last); + } + else + { + _multiParseState = EXPECT_DASH2; + } + } + else if (_multiParseState == EXPECT_DASH2) + { + if (data != '-') + { + _multiParseState = WAIT_FOR_RETURN1; + itemWriteByte('\r'); + itemWriteByte('\n'); + itemWriteByte('-'); + + _parseMultipartPostByte(data, last); + } + else + { + _multiParseState = BOUNDARY_OR_DATA; + _boundaryPosition = 0; + } + } + else if (_multiParseState == BOUNDARY_OR_DATA) + { + if (_boundaryPosition < _boundary.length() && _boundary.c_str()[_boundaryPosition] != data) + { + _multiParseState = WAIT_FOR_RETURN1; + itemWriteByte('\r'); + itemWriteByte('\n'); + itemWriteByte('-'); + itemWriteByte('-'); + + uint8_t i; + + for (i = 0; i < _boundaryPosition; i++) + itemWriteByte(_boundary.c_str()[i]); + + _parseMultipartPostByte(data, last); + } + else if (_boundaryPosition == _boundary.length() - 1) + { + _multiParseState = DASH3_OR_RETURN2; + + if (!_itemIsFile) + { + _addParam(new AsyncWebParameter(_itemName, _itemValue, true)); + } + else + { + if (_itemSize) + { + //check if authenticated before calling the upload + if (_handler) + _handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, true); + + _itemBufferIndex = 0; + _addParam(new AsyncWebParameter(_itemName, _itemFilename, true, true, _itemSize)); + } + + free(_itemBuffer); + _itemBuffer = NULL; + } + + } + else + { + _boundaryPosition++; + } + } + else if (_multiParseState == DASH3_OR_RETURN2) + { + if (data == '-' && (_contentLength - _parsedLength - 4) != 0) + { + AWS_LOGDEBUG1("ERROR: The parser got to the end of the POST but is expecting more bytes =", + (_contentLength - _parsedLength - 4)); + AWS_LOGDEBUG("Drop an issue so we can have more info on the matter!"); + + _contentLength = _parsedLength + 4;//lets close the request gracefully + } + + if (data == '\r') + { + _multiParseState = EXPECT_FEED2; + } + else if (data == '-' && _contentLength == (_parsedLength + 4)) + { + _multiParseState = PARSING_FINISHED; + } + else + { + _multiParseState = WAIT_FOR_RETURN1; + itemWriteByte('\r'); + itemWriteByte('\n'); + itemWriteByte('-'); + itemWriteByte('-'); + + uint8_t i; + + for (i = 0; i < _boundary.length(); i++) + itemWriteByte(_boundary.c_str()[i]); + + _parseMultipartPostByte(data, last); + } + } + else if (_multiParseState == EXPECT_FEED2) + { + if (data == '\n') + { + _multiParseState = PARSE_HEADERS; + _itemIsFile = false; + } + else + { + _multiParseState = WAIT_FOR_RETURN1; + itemWriteByte('\r'); + itemWriteByte('\n'); + itemWriteByte('-'); + itemWriteByte('-'); + + uint8_t i; + + for (i = 0; i < _boundary.length(); i++) + itemWriteByte(_boundary.c_str()[i]); + + itemWriteByte('\r'); + + _parseMultipartPostByte(data, last); + } + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::_parseLine() +{ + if (_parseState == PARSE_REQ_START) + { + if (!_temp.length()) + { + _parseState = PARSE_REQ_FAIL; + _client->close(); + } + else + { + _parseReqHead(); + _parseState = PARSE_REQ_HEADERS; + } + + return; + } + + if (_parseState == PARSE_REQ_HEADERS) + { + if (!_temp.length()) + { + //end of headers + _server->_rewriteRequest(this); + _server->_attachHandler(this); + _removeNotInterestingHeaders(); + + if (_expectingContinue) + { + const char * response = "HTTP/1.1 100 Continue\r\n\r\n"; + //_client->write(response, os_strlen(response)); + _client->write(response, strlen(response)); + } + + //check handler for authentication + if (_contentLength) + { + _parseState = PARSE_REQ_BODY; + } + else + { + _parseState = PARSE_REQ_END; + + if (_handler) + _handler->handleRequest(this); + else + send(501); + } + } + else + _parseReqHeader(); + } +} + +///////////////////////////////////////////////// + +size_t AsyncWebServerRequest::headers() const +{ + return _headers.length(); +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::hasHeader(const String& name) const +{ + for (const auto& h : _headers) + { + if (h->name().equalsIgnoreCase(name)) + { + return true; + } + } + + return false; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::hasHeader(const __FlashStringHelper * data) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = 0; + + while (1) + { + if (pgm_read_byte(p + n) == 0) + break; + + n += 1; + } + + char * name = (char*) malloc(n + 1); + name[n] = 0; + + if (name) + { + for (size_t b = 0; b < n; b++) + name[b] = pgm_read_byte(p++); + + bool result = hasHeader( String(name) ); + free(name); + return result; + } + else + { + return false; + } +} + +///////////////////////////////////////////////// + +AsyncWebHeader* AsyncWebServerRequest::getHeader(const String& name) const +{ + for (const auto& h : _headers) + { + if (h->name().equalsIgnoreCase(name)) + { + return h; + } + } + + return nullptr; +} + +///////////////////////////////////////////////// + +AsyncWebHeader* AsyncWebServerRequest::getHeader(const __FlashStringHelper * data) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = strlen_P(p); + char * name = (char*) malloc(n + 1); + + if (name) + { + strcpy_P(name, p); + AsyncWebHeader* result = getHeader( String(name)); + free(name); + return result; + } + else + { + return nullptr; + } +} + +///////////////////////////////////////////////// + +AsyncWebHeader* AsyncWebServerRequest::getHeader(size_t num) const +{ + auto header = _headers.nth(num); + + return (header ? *header : nullptr); +} + +///////////////////////////////////////////////// + +size_t AsyncWebServerRequest::params() const +{ + return _params.length(); +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::hasParam(const String& name, bool post, bool file) const +{ + for (const auto& p : _params) + { + if (p->name() == name && p->isPost() == post && p->isFile() == file) + { + return true; + } + } + + return false; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::hasParam(const __FlashStringHelper * data, bool post, bool file) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = strlen_P(p); + + char * name = (char*) malloc(n + 1); + name[n] = 0; + + if (name) + { + strcpy_P(name, p); + bool result = hasParam( name, post, file); + free(name); + + return result; + } + else + { + return false; + } +} + +///////////////////////////////////////////////// + +AsyncWebParameter* AsyncWebServerRequest::getParam(const String& name, bool post, bool file) const +{ + for (const auto& p : _params) + { + if (p->name() == name && p->isPost() == post && p->isFile() == file) + { + return p; + } + } + + return nullptr; +} + +///////////////////////////////////////////////// + +AsyncWebParameter* AsyncWebServerRequest::getParam(const __FlashStringHelper * data, bool post, bool file) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = strlen_P(p); + char * name = (char*) malloc(n + 1); + + if (name) + { + strcpy_P(name, p); + AsyncWebParameter* result = getParam(name, post, file); + free(name); + + return result; + } + else + { + return nullptr; + } +} + +///////////////////////////////////////////////// + +AsyncWebParameter* AsyncWebServerRequest::getParam(size_t num) const +{ + auto param = _params.nth(num); + + return (param ? *param : nullptr); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::addInterestingHeader(const String& name) +{ + if (!_interestingHeaders.containsIgnoreCase(name)) + _interestingHeaders.add(name); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send(AsyncWebServerResponse *response) +{ + _response = response; + + if (_response == NULL) + { + _client->close(true); + + _onDisconnect(); + + return; + } + + if (!_response->_sourceValid()) + { + delete response; + _response = NULL; + send(500); + } + else + { + _client->setRxTimeout(0); + _response->_respond(this); + } +} + +//RSMOD/////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(int code, const String& contentType, const char * content) +{ + return new AsyncBasicResponse(code, contentType, content); +} +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(int code, const String& contentType, + const String& content) +{ + return new AsyncBasicResponse(code, contentType, content); +} + +///////////////////////////////////////////////// +// KH add for favicon +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(int code, const String& contentType, + const uint8_t * content, size_t len, + AwsTemplateProcessor callback) +{ + return new AsyncProgmemResponse(code, contentType, content, len, callback); +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(FS &fs, const String& path, const String& contentType, + bool download, + AwsTemplateProcessor callback) +{ + if (fs.exists(path) || (!download && fs.exists(path + ".gz"))) + return new AsyncFileResponse(fs, path, contentType, download, callback); + + return NULL; +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(File content, const String& path, + const String& contentType, bool download, + AwsTemplateProcessor callback) +{ + if (content == true) + return new AsyncFileResponse(content, path, contentType, download, callback); + + return NULL; +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(Stream &stream, const String& contentType, size_t len, + AwsTemplateProcessor callback) +{ + return new AsyncStreamResponse(stream, contentType, len, callback); +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse(const String& contentType, size_t len, + AwsResponseFiller callback, + AwsTemplateProcessor templateCallback) +{ + return new AsyncCallbackResponse(contentType, len, callback, templateCallback); +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginChunkedResponse(const String& contentType, + AwsResponseFiller callback, + AwsTemplateProcessor templateCallback) +{ + if (_version) + return new AsyncChunkedResponse(contentType, callback, templateCallback); + + return new AsyncCallbackResponse(contentType, 0, callback, templateCallback); +} + +///////////////////////////////////////////////// + +AsyncResponseStream * AsyncWebServerRequest::beginResponseStream(const String& contentType, size_t bufferSize) +{ + return new AsyncResponseStream(contentType, bufferSize); +} + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse_P(int code, const String& contentType, + const uint8_t * content, size_t len, + AwsTemplateProcessor callback) +{ + return new AsyncProgmemResponse(code, contentType, content, len, callback); +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse * AsyncWebServerRequest::beginResponse_P(int code, const String& contentType, PGM_P content, + AwsTemplateProcessor callback) +{ + return beginResponse_P(code, contentType, (const uint8_t *)content, strlen_P(content), callback); +} + +//RSMOD/////////////////////////////////////////////// + +void AsyncWebServerRequest::send(int code, const String& contentType, const char *content, bool nonDetructiveSend) +{ + if (nonDetructiveSend) + { + send(beginResponse(code, contentType, String(content))); // for backwards compatibility + } + else + { + send(beginResponse(code, contentType, content)); + } +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send(int code, const String& contentType, const String& content) +{ + send(beginResponse(code, contentType, content)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send(FS &fs, const String& path, const String& contentType, bool download, + AwsTemplateProcessor callback) +{ + if (fs.exists(path) || (!download && fs.exists(path + ".gz"))) + { + send(beginResponse(fs, path, contentType, download, callback)); + } + else + send(404); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send(File content, const String& path, const String& contentType, bool download, + AwsTemplateProcessor callback) +{ + if (content == true) + { + send(beginResponse(content, path, contentType, download, callback)); + } + else + send(404); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback) +{ + send(beginResponse(stream, contentType, len, callback)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send(const String& contentType, size_t len, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback) +{ + send(beginResponse(contentType, len, callback, templateCallback)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::sendChunked(const String& contentType, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback) +{ + send(beginChunkedResponse(contentType, callback, templateCallback)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send_P(int code, const String& contentType, const uint8_t * content, size_t len, + AwsTemplateProcessor callback) +{ + send(beginResponse_P(code, contentType, content, len, callback)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::send_P(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback) +{ + send(beginResponse_P(code, contentType, content, callback)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::redirect(const String& url) +{ + AsyncWebServerResponse * response = beginResponse(302); + + response->addHeader("Location", url); + send(response); +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::authenticate(const char * username, const char * password, const char * realm, + bool passwordIsHash) +{ + AWS_LOGDEBUG1("AsyncWebServerRequest::authenticate: auth-len =", _authorization.length()); + + if (_authorization.length()) + { + if (_isDigest) + { + AWS_LOGDEBUG("AsyncWebServerRequest::authenticate: _isDigest"); + + return checkDigestAuthentication(_authorization.c_str(), methodToString(), username, password, realm, passwordIsHash, + NULL, NULL, NULL); + } + else if (!passwordIsHash) + { + AWS_LOGDEBUG("AsyncWebServerRequest::authenticate: !passwordIsHash"); + + return checkBasicAuthentication(_authorization.c_str(), username, password); + } + else + { + AWS_LOGDEBUG("AsyncWebServerRequest::authenticate: Using password _authorization.equals"); + + return _authorization.equals(password); + } + } + + AWS_LOGDEBUG("AsyncWebServerRequest::authenticate: failed, len = 0"); + + return false; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::authenticate(const char * hash) +{ + if (!_authorization.length() || hash == NULL) + return false; + + if (_isDigest) + { + String hStr = String(hash); + int separator = hStr.indexOf(":"); + + if (separator <= 0) + return false; + + String username = hStr.substring(0, separator); + hStr = hStr.substring(separator + 1); + separator = hStr.indexOf(":"); + + if (separator <= 0) + return false; + + String realm = hStr.substring(0, separator); + hStr = hStr.substring(separator + 1); + + return checkDigestAuthentication(_authorization.c_str(), methodToString(), username.c_str(), hStr.c_str(), + realm.c_str(), true, NULL, NULL, NULL); + } + + return (_authorization.equals(hash)); +} + +///////////////////////////////////////////////// + +void AsyncWebServerRequest::requestAuthentication(const char * realm, bool isDigest) +{ + AsyncWebServerResponse * r = beginResponse(401); + + if (!isDigest && realm == NULL) + { + r->addHeader("WWW-Authenticate", "Basic realm=\"Login Required\""); + } + else if (!isDigest) + { + String header = "Basic realm=\""; + header.concat(realm); + header.concat("\""); + r->addHeader("WWW-Authenticate", header); + } + else + { + String header = "Digest "; + header.concat(requestDigestAuthentication(realm)); + r->addHeader("WWW-Authenticate", header); + } + + send(r); +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::hasArg(const char* name) const +{ + for (const auto& arg : _params) + { + if (arg->name() == name) + { + return true; + } + } + + return false; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::hasArg(const __FlashStringHelper * data) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = strlen_P(p); + char * name = (char*) malloc(n + 1); + + if (name) + { + strcpy_P(name, p); + bool result = hasArg( name ); + free(name); + + return result; + } + else + { + return false; + } +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::arg(const String& name) const +{ + for (const auto& arg : _params) + { + if (arg->name() == name) + { + return arg->value(); + } + } + + return SharedEmptyString; +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::arg(const __FlashStringHelper * data) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = strlen_P(p); + char * name = (char*) malloc(n + 1); + + if (name) + { + strcpy_P(name, p); + const String & result = arg( String(name) ); + free(name); + + return result; + } + else + { + return SharedEmptyString; + } +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::arg(size_t i) const +{ + return getParam(i)->value(); +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::argName(size_t i) const +{ + return getParam(i)->name(); +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::pathArg(size_t i) const +{ + auto param = _pathParams.nth(i); + + return (param ? **param : SharedEmptyString); +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::header(const char* name) const +{ + AsyncWebHeader* h = getHeader(String(name)); + + return (h ? h->value() : SharedEmptyString); +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::header(const __FlashStringHelper * data) const +{ + PGM_P p = reinterpret_cast(data); + size_t n = strlen_P(p); + char * name = (char*) malloc(n + 1); + + if (name) + { + strcpy_P(name, p); + const String & result = header( (const char *)name ); + free(name); + + return result; + } + else + { + return SharedEmptyString; + } +}; +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::header(size_t i) const +{ + AsyncWebHeader* h = getHeader(i); + + return (h ? h->value() : SharedEmptyString); +} + +///////////////////////////////////////////////// + +const String& AsyncWebServerRequest::headerName(size_t i) const +{ + AsyncWebHeader* h = getHeader(i); + + return (h ? h->name() : SharedEmptyString); +} + +///////////////////////////////////////////////// + +String AsyncWebServerRequest::urlDecode(const String& text) const +{ + char temp[] = "0x00"; + unsigned int len = text.length(); + unsigned int i = 0; + String decoded = String(); + decoded.reserve(len); // Allocate the string internal buffer - never longer from source text + + while (i < len) + { + char decodedChar; + char encodedChar = text.charAt(i++); + + if ((encodedChar == '%') && (i + 1 < len)) + { + temp[2] = text.charAt(i++); + temp[3] = text.charAt(i++); + decodedChar = strtol(temp, NULL, 16); + } + else if (encodedChar == '+') + { + decodedChar = ' '; + } + else + { + decodedChar = encodedChar; // normal ascii char + } + + decoded.concat(decodedChar); + } + + return decoded; +} + +///////////////////////////////////////////////// + +const char * AsyncWebServerRequest::methodToString() const +{ + if (_method == HTTP_ANY) + return "ANY"; + else if (_method & HTTP_GET) + return "GET"; + else if (_method & HTTP_POST) + return "POST"; + else if (_method & HTTP_DELETE) + return "DELETE"; + else if (_method & HTTP_PUT) + return "PUT"; + else if (_method & HTTP_PATCH) + return "PATCH"; + else if (_method & HTTP_HEAD) + return "HEAD"; + else if (_method & HTTP_OPTIONS) + return "OPTIONS"; + + return "UNKNOWN"; +} + +///////////////////////////////////////////////// + +const char *AsyncWebServerRequest::requestedConnTypeToString() const +{ + switch (_reqconntype) + { + case RCT_NOT_USED: + return "RCT_NOT_USED"; + + case RCT_DEFAULT: + return "RCT_DEFAULT"; + + case RCT_HTTP: + return "RCT_HTTP"; + + case RCT_WS: + return "RCT_WS"; + + case RCT_EVENT: + return "RCT_EVENT"; + + default: + return "ERROR"; + } +} + +///////////////////////////////////////////////// + +bool AsyncWebServerRequest::isExpectedRequestedConnType(RequestedConnectionType erct1, RequestedConnectionType erct2, + RequestedConnectionType erct3) +{ + bool res = false; + + if ((erct1 != RCT_NOT_USED) && (erct1 == _reqconntype)) + res = true; + + if ((erct2 != RCT_NOT_USED) && (erct2 == _reqconntype)) + res = true; + + if ((erct3 != RCT_NOT_USED) && (erct3 == _reqconntype)) + res = true; + + return res; +} + +///////////////////////////////////////////////// diff --git a/src/WebResponseImpl.h b/src/WebResponseImpl.h new file mode 100644 index 0000000..0d6fafd --- /dev/null +++ b/src/WebResponseImpl.h @@ -0,0 +1,276 @@ +/**************************************************************************************************************************** + WebResponseImpl.h - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#ifndef ASYNCWEBSERVERRESPONSEIMPL_H_ +#define ASYNCWEBSERVERRESPONSEIMPL_H_ + +#ifdef Arduino_h + // arduino is not compatible with std::vector + #undef min + #undef max +#endif + +#include + +// It is possible to restore these defines, but one can use _min and _max instead. Or std::min, std::max. + +///////////////////////////////////////////////// + +class AsyncBasicResponse: public AsyncWebServerResponse +{ + private: + String _content; + + char *_contentCstr; // RSMOD + String _partialHeader; + + public: + AsyncBasicResponse(int code, const String& contentType = String(), const String& content = String()); + + AsyncBasicResponse(int code, const String& contentType, const char *content = nullptr); // RSMOD + + void _respond(AsyncWebServerRequest *request); + size_t _ack(AsyncWebServerRequest *request, size_t len, uint32_t time); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return true; + } + + ///////////////////////////////////////////////// +}; + +///////////////////////////////////////////////// + +class AsyncAbstractResponse: public AsyncWebServerResponse +{ + private: + String _head; + // Data is inserted into cache at begin(). + // This is inefficient with vector, but if we use some other container, + // we won't be able to access it as contiguous array of bytes when reading from it, + // so by gaining performance in one place, we'll lose it in another. + std::vector _cache; + size_t _readDataFromCacheOrContent(uint8_t* data, const size_t len); + size_t _fillBufferAndProcessTemplates(uint8_t* buf, size_t maxLen); + + protected: + AwsTemplateProcessor _callback; + + public: + AsyncAbstractResponse(AwsTemplateProcessor callback = nullptr); + void _respond(AsyncWebServerRequest *request); + size_t _ack(AsyncWebServerRequest *request, size_t len, uint32_t time); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return false; + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf __attribute__((unused)), size_t maxLen __attribute__((unused))) + { + return 0; + } + + ///////////////////////////////////////////////// +}; + +///////////////////////////////////////////////// + +#ifndef TEMPLATE_PLACEHOLDER + #define TEMPLATE_PLACEHOLDER '%' +#endif + +#define TEMPLATE_PARAM_NAME_LENGTH 32 + +///////////////////////////////////////////////// + +class AsyncFileResponse: public AsyncAbstractResponse +{ + using File = fs::File; + using FS = fs::FS; + + private: + File _content; + String _path; + void _setContentType(const String& path); + + public: + AsyncFileResponse(FS &fs, const String& path, const String& contentType = String(), bool download = false, + AwsTemplateProcessor callback = nullptr); + AsyncFileResponse(File content, const String& path, const String& contentType = String(), bool download = false, + AwsTemplateProcessor callback = nullptr); + + ~AsyncFileResponse(); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return !!(_content); + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) override; +}; + +///////////////////////////////////////////////// + +class AsyncStreamResponse: public AsyncAbstractResponse +{ + private: + Stream *_content; + + public: + AsyncStreamResponse(Stream &stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return !!(_content); + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) override; +}; + +///////////////////////////////////////////////// + +class AsyncCallbackResponse: public AsyncAbstractResponse +{ + private: + AwsResponseFiller _content; + size_t _filledLength; + + public: + AsyncCallbackResponse(const String& contentType, size_t len, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback = nullptr); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return !!(_content); + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) override; +}; + +///////////////////////////////////////////////// + +class AsyncChunkedResponse: public AsyncAbstractResponse +{ + private: + AwsResponseFiller _content; + size_t _filledLength; + + public: + AsyncChunkedResponse(const String& contentType, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback = nullptr); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return !!(_content); + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) override; +}; + +///////////////////////////////////////////////// + +class AsyncProgmemResponse: public AsyncAbstractResponse +{ + private: + const uint8_t * _content; + size_t _readLength; + + public: + AsyncProgmemResponse(int code, const String& contentType, const uint8_t * content, size_t len, + AwsTemplateProcessor callback = nullptr); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return true; + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) override; +}; + +///////////////////////////////////////////////// + +class cbuf; + +///////////////////////////////////////////////// + +class AsyncResponseStream: public AsyncAbstractResponse, public Print +{ + private: + cbuf *_content; + + public: + AsyncResponseStream(const String& contentType, size_t bufferSize); + ~AsyncResponseStream(); + + ///////////////////////////////////////////////// + + inline bool _sourceValid() const + { + return (_state < RESPONSE_END); + } + + ///////////////////////////////////////////////// + + virtual size_t _fillBuffer(uint8_t *buf, size_t maxLen) override; + size_t write(const uint8_t *data, size_t len); + size_t write(uint8_t data); + using Print::write; +}; + +#endif /* ASYNCWEBSERVERRESPONSEIMPL_H_ */ diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp new file mode 100644 index 0000000..64b13ee --- /dev/null +++ b/src/WebResponses.cpp @@ -0,0 +1,1298 @@ +/**************************************************************************************************************************** + WebResponses.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "AsyncWebServer_ESP32_ENC.h" + +#include "WebResponseImpl.h" +#include "cbuf.h" + +///////////////////////////////////////////////// + +void* memchr(void* ptr, int ch, size_t count) +{ + unsigned char* p = static_cast(ptr); + + while (count--) + if (*p++ == static_cast(ch)) + return --p; + + return nullptr; +} + +///////////////////////////////////////////////// + +/* + Abstract Response + * */ +const char* AsyncWebServerResponse::_responseCodeToString(int code) +{ + switch (code) + { + case 100: + return "Continue"; + + case 101: + return "Switching Protocols"; + + case 200: + return "OK"; + + case 201: + return "Created"; + + case 202: + return "Accepted"; + + case 203: + return "Non-Authoritative Information"; + + case 204: + return "No Content"; + + case 205: + return "Reset Content"; + + case 206: + return "Partial Content"; + + case 300: + return "Multiple Choices"; + + case 301: + return "Moved Permanently"; + + case 302: + return "Found"; + + case 303: + return "See Other"; + + case 304: + return "Not Modified"; + + case 305: + return "Use Proxy"; + + case 307: + return "Temporary Redirect"; + + case 400: + return "Bad Request"; + + case 401: + return "Unauthorized"; + + case 402: + return "Payment Required"; + + case 403: + return "Forbidden"; + + case 404: + return "Not Found"; + + case 405: + return "Method Not Allowed"; + + case 406: + return "Not Acceptable"; + + case 407: + return "Proxy Authentication Required"; + + case 408: + return "Request Time-out"; + + case 409: + return "Conflict"; + + case 410: + return "Gone"; + + case 411: + return "Length Required"; + + case 412: + return "Precondition Failed"; + + case 413: + return "Request Entity Too Large"; + + case 414: + return "Request-URI Too Large"; + + case 415: + return "Unsupported Media Type"; + + case 416: + return "Requested range not satisfiable"; + + case 417: + return "Expectation Failed"; + + case 500: + return "Internal Server Error"; + + case 501: + return "Not Implemented"; + + case 502: + return "Bad Gateway"; + + case 503: + return "Service Unavailable"; + + case 504: + return "Gateway Time-out"; + + case 505: + return "HTTP Version not supported"; + + default: + return ""; + } +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse::AsyncWebServerResponse() + : _code(0) + , _headers(LinkedList([](AsyncWebHeader * h) +{ + delete h; +})) +, _contentType() +, _contentLength(0) +, _sendContentLength(true) +, _chunked(false) +, _headLength(0) +, _sentLength(0) +, _ackedLength(0) +, _writtenLength(0) +, _state(RESPONSE_SETUP) +{ + for (auto header : DefaultHeaders::Instance()) + { + _headers.add(new AsyncWebHeader(header->name(), header->value())); + } +} + +///////////////////////////////////////////////// + +AsyncWebServerResponse::~AsyncWebServerResponse() +{ + _headers.free(); +} + +///////////////////////////////////////////////// + +void AsyncWebServerResponse::setCode(int code) +{ + if (_state == RESPONSE_SETUP) + _code = code; +} + +void AsyncWebServerResponse::setContentLength(size_t len) +{ + if (_state == RESPONSE_SETUP) + _contentLength = len; +} + +///////////////////////////////////////////////// + +void AsyncWebServerResponse::setContentType(const String& type) +{ + if (_state == RESPONSE_SETUP) + _contentType = type; +} + +///////////////////////////////////////////////// + +void AsyncWebServerResponse::addHeader(const String& name, const String& value) +{ + _headers.add(new AsyncWebHeader(name, value)); +} + +///////////////////////////////////////////////// + +String AsyncWebServerResponse::_assembleHead(uint8_t version) +{ + if (version) + { + addHeader("Accept-Ranges", "none"); + + if (_chunked) + addHeader("Transfer-Encoding", "chunked"); + } + + String out = String(); + int bufSize = 300; + char buf[bufSize]; + + snprintf(buf, bufSize, "HTTP/1.%d %d %s\r\n", version, _code, _responseCodeToString(_code)); + out.concat(buf); + + if (_sendContentLength) + { + snprintf(buf, bufSize, "Content-Length: %d\r\n", _contentLength); + out.concat(buf); + } + + if (_contentType.length()) + { + snprintf(buf, bufSize, "Content-Type: %s\r\n", _contentType.c_str()); + out.concat(buf); + } + + for (const auto& header : _headers) + { + snprintf(buf, bufSize, "%s: %s\r\n", header->name().c_str(), header->value().c_str()); + out.concat(buf); + } + + _headers.free(); + + out.concat("\r\n"); + _headLength = out.length(); + + return out; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerResponse::_started() const +{ + return _state > RESPONSE_SETUP; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerResponse::_finished() const +{ + return _state > RESPONSE_WAIT_ACK; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerResponse::_failed() const +{ + return _state == RESPONSE_FAILED; +} + +///////////////////////////////////////////////// + +bool AsyncWebServerResponse::_sourceValid() const +{ + return false; +} + +///////////////////////////////////////////////// + +void AsyncWebServerResponse::_respond(AsyncWebServerRequest *request) +{ + _state = RESPONSE_END; + request->client()->close(); +} + +///////////////////////////////////////////////// + +size_t AsyncWebServerResponse::_ack(AsyncWebServerRequest *request, size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(request); + ESP32_ENC_AWS_UNUSED(len); + ESP32_ENC_AWS_UNUSED(time); + + return 0; +} + +//RSMOD/////////////////////////////////////////////// + +/* + String/Code Response + * */ +AsyncBasicResponse::AsyncBasicResponse(int code, const String& contentType, const char *content) +{ + _code = code; + _content = String(""); + _contentCstr = (char *)content; // RSMOD + _contentType = contentType; + _partialHeader = String(); + + int iLen; + + if ((iLen = strlen(_contentCstr))) + { + _contentLength = iLen; + + if (!_contentType.length()) + _contentType = "text/plain"; + } + + addHeader("Connection", "close"); +} + +///////////////////////////////////////////////// + +/* + String/Code Response + * */ +AsyncBasicResponse::AsyncBasicResponse(int code, const String& contentType, const String& content) +{ + _code = code; + _content = content; + + _contentCstr = nullptr; // RSMOD + + _contentType = contentType; + _partialHeader = String(); + + if (_content.length()) + { + _contentLength = _content.length(); + + if (!_contentType.length()) + _contentType = "text/plain"; + } + + addHeader("Connection", "close"); +} + +///////////////////////////////////////////////// + +void AsyncBasicResponse::_respond(AsyncWebServerRequest *request) +{ + _state = RESPONSE_HEADERS; + String out = _assembleHead(request->version()); + size_t outLen = out.length(); + size_t space = request->client()->space(); + + AWS_LOGDEBUG3("AsyncBasicResponse::_respond : Pre_respond, _contentLength =", _contentLength, ", out =", out ); + AWS_LOGDEBUG3("outLen =", outLen, ", _contentCstr =", _contentCstr); + + if (!_contentLength && space >= outLen) + { + AWS_LOGDEBUG("Step 1"); + + _writtenLength += request->client()->write(out.c_str(), outLen); + _state = RESPONSE_WAIT_ACK; + } + else if (_contentLength && space >= outLen + _contentLength) + { + AWS_LOGDEBUG("Step 2"); + + if (_contentCstr) + { + _content = String( + _contentCstr); // short _contentCstr - so just send as Arduino String - not much of a penalty - fall into below + } + + out += _content; + outLen += _contentLength; + _writtenLength += request->client()->write(out.c_str(), outLen); + + _state = RESPONSE_WAIT_ACK; + } + else if (space && space < outLen) + { + String partial = out.substring(0, space); + + AWS_LOGDEBUG("Step 3"); + + if (_contentCstr) + { + _partialHeader = out.substring(space); + } + else + { + _content = out.substring(space) + _content; + _contentLength += outLen - space; + } + + AWS_LOGDEBUG1("partial =", partial); + + _writtenLength += request->client()->write(partial.c_str(), partial.length()); + + _state = RESPONSE_CONTENT; + } + else if (space > outLen && space < (outLen + _contentLength)) + { + size_t shift = space - outLen; + + AWS_LOGDEBUG("Step 4"); + + outLen += shift; + _sentLength += shift; + + if (_contentCstr) + { + char *s = (char *)malloc(shift + 1); + + if (s != nullptr) + { + strncpy(s, _contentCstr, shift); + s[shift] = '\0'; + out += String(s); + _contentCstr += shift; + + free(s); + } + else + { + AWS_LOGERROR("AsyncBasicResponse::_respond: Out of heap"); + + return; + } + } + else + { + out += _content.substring(0, shift); + _content = _content.substring(shift); + } + + AWS_LOGDEBUG1("out =", out); + + _writtenLength += request->client()->write(out.c_str(), outLen); + _state = RESPONSE_CONTENT; + } + else + { + AWS_LOGDEBUG("Step 5"); + + if (_contentCstr) + { + _partialHeader = out; + } + else + { + _content = out + _content; + _contentLength += outLen; + } + + _state = RESPONSE_CONTENT; + } + + AWS_LOGDEBUG3("AsyncBasicResponse::_respond : Post_respond, _contentLength =", _contentLength, ", out =", out ); + AWS_LOGDEBUG3("outLen =", outLen, ", _contentCstr =", _contentCstr); +} + +///////////////////////////////////////////////// + +size_t AsyncBasicResponse::_ack(AsyncWebServerRequest *request, size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + AWS_LOGDEBUG1("AsyncBasicResponse::_ack : Pre_ack, _contentLength =", _contentLength); + + _ackedLength += len; + + if (_state == RESPONSE_CONTENT) + { + String out; + size_t available = _contentLength - _sentLength; + size_t space = request->client()->space(); + + if (_partialHeader.length() > 0) + { + if (_partialHeader.length() > space) + { + // Header longer than space - send a piece of it, and make the _partialHeader = to what remains + String _subHeader; + String tmpString; + + _subHeader = _partialHeader.substring(0, space); + tmpString = _partialHeader.substring(space); + _partialHeader = tmpString; + + _writtenLength += request->client()->write(_subHeader.c_str(), space); + + return (_partialHeader.length()); + } + else + { + // _partialHeader is <= space length - therefore send the whole thing, and make the remaining length = to the _contrentLength + _writtenLength += request->client()->write(_partialHeader.c_str(), _partialHeader.length()); + + _partialHeader = String(); + + return (_contentLength); + } + } + + // if we are here - there is no _partialHJeader to send + + AWS_LOGDEBUG3("AsyncBasicResponse::_ack : available =", available, ", space =", space ); + + //we can fit in this packet + if (space > available) + { + AWS_LOGDEBUG1("AsyncBasicResponse::_ack : Pre_ack, _contentLength =", _contentLength); + + if (_contentCstr) + { + AWS_LOGDEBUG1("In space>available : output =", _contentCstr); + + _writtenLength += request->client()->write(_contentCstr, available); + //_contentCstr[0] = '\0'; + } + else + { + _writtenLength += request->client()->write(_content.c_str(), available); + _content = String(); + } + + _state = RESPONSE_WAIT_ACK; + + return available; + } + + //send some data, the rest on ack + if (_contentCstr) + { + char *s = (char *)malloc(space + 1); + + if (s != nullptr) + { + strncpy(s, _contentCstr, space); + s[space] = '\0'; + out = String(s); + _contentCstr += space; + + free(s); + } + else + { + AWS_LOGERROR("AsyncBasicResponse::_ack: Out of heap"); + + return 0; + } + } + else + { + out = _content.substring(0, space); + _content = _content.substring(space); + } + + _sentLength += space; + + AWS_LOGDEBUG1("In space>available : output =", out); + + _writtenLength += request->client()->write(out.c_str(), space); + + return space; + } + else if (_state == RESPONSE_WAIT_ACK) + { + if (_ackedLength >= _writtenLength) + { + _state = RESPONSE_END; + } + } + + AWS_LOGDEBUG3("AsyncBasicResponse::_ack : Post_ack, _contentLength =", _contentLength, ", _contentCstr =", + _contentCstr); + + return 0; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Abstract Response + * */ + +AsyncAbstractResponse::AsyncAbstractResponse(AwsTemplateProcessor callback): _callback(callback) +{ + // In case of template processing, we're unable to determine real response size + if (callback) + { + _contentLength = 0; + _sendContentLength = false; + _chunked = true; + } +} + +///////////////////////////////////////////////// + +void AsyncAbstractResponse::_respond(AsyncWebServerRequest *request) +{ + addHeader("Connection", "close"); + _head = _assembleHead(request->version()); + _state = RESPONSE_HEADERS; + _ack(request, 0, 0); +} + +///////////////////////////////////////////////// + +size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, uint32_t time) +{ + ESP32_ENC_AWS_UNUSED(time); + + if (!_sourceValid()) + { + _state = RESPONSE_FAILED; + request->client()->close(); + return 0; + } + + _ackedLength += len; + size_t space = request->client()->space(); + + size_t headLen = _head.length(); + + if (_state == RESPONSE_HEADERS) + { + if (space >= headLen) + { + _state = RESPONSE_CONTENT; + space -= headLen; + } + else + { + String out = _head.substring(0, space); + _head = _head.substring(space); + _writtenLength += request->client()->write(out.c_str(), out.length()); + + return out.length(); + } + } + + if (_state == RESPONSE_CONTENT) + { + size_t outLen; + + if (_chunked) + { + if (space <= 8) + { + return 0; + } + + outLen = space; + } + else if (!_sendContentLength) + { + outLen = space; + } + else + { + outLen = ((_contentLength - _sentLength) > space) ? space : (_contentLength - _sentLength); + } + + uint8_t *buf = (uint8_t *)malloc(outLen + headLen); + + if (!buf) + { + AWS_LOGERROR1(F("[AsyncAbstractResponse::_ack] _ack malloc failed, size ="), outLen + headLen); + + return 0; + } + + if (headLen) + { + memcpy(buf, _head.c_str(), _head.length()); + } + + size_t readLen = 0; + + if (_chunked) + { + // HTTP 1.1 allows leading zeros in chunk length. Or spaces may be added. + // See RFC2616 sections 2, 3.6.1. + readLen = _fillBufferAndProcessTemplates(buf + headLen + 6, outLen - 8); + + if (readLen == RESPONSE_TRY_AGAIN) + { + free(buf); + return 0; + } + + outLen = sprintf((char*)buf + headLen, "%x", readLen) + headLen; + + while (outLen < headLen + 4) + buf[outLen++] = ' '; + + buf[outLen++] = '\r'; + buf[outLen++] = '\n'; + outLen += readLen; + buf[outLen++] = '\r'; + buf[outLen++] = '\n'; + } + else + { + readLen = _fillBufferAndProcessTemplates(buf + headLen, outLen); + + if (readLen == RESPONSE_TRY_AGAIN) + { + free(buf); + return 0; + } + + outLen = readLen + headLen; + } + + if (headLen) + { + _head = String(); + } + + if (outLen) + { + _writtenLength += request->client()->write((const char*)buf, outLen); + } + + if (_chunked) + { + _sentLength += readLen; + } + else + { + _sentLength += outLen - headLen; + } + + free(buf); + + if ((_chunked && readLen == 0) || (!_sendContentLength && outLen == 0) || (!_chunked && _sentLength == _contentLength)) + { + _state = RESPONSE_WAIT_ACK; + } + + return outLen; + + } + else if (_state == RESPONSE_WAIT_ACK) + { + if (!_sendContentLength || _ackedLength >= _writtenLength) + { + _state = RESPONSE_END; + + if (!_chunked && !_sendContentLength) + request->client()->close(true); + } + } + + return 0; +} + +///////////////////////////////////////////////// + +size_t AsyncAbstractResponse::_readDataFromCacheOrContent(uint8_t* data, const size_t len) +{ + // If we have something in cache, copy it to buffer + const size_t readFromCache = std::min(len, _cache.size()); + + if (readFromCache) + { + memcpy(data, _cache.data(), readFromCache); + _cache.erase(_cache.begin(), _cache.begin() + readFromCache); + } + + // If we need to read more... + const size_t needFromFile = len - readFromCache; + const size_t readFromContent = _fillBuffer(data + readFromCache, needFromFile); + + return readFromCache + readFromContent; +} + +///////////////////////////////////////////////// + +size_t AsyncAbstractResponse::_fillBufferAndProcessTemplates(uint8_t* data, size_t len) +{ + if (!_callback) + return _fillBuffer(data, len); + + const size_t originalLen = len; + len = _readDataFromCacheOrContent(data, len); + + // Now we've read 'len' bytes, either from cache or from file + // Search for template placeholders + uint8_t* pTemplateStart = data; + + while ((pTemplateStart < &data[len]) + && (pTemplateStart = (uint8_t*)memchr(pTemplateStart, TEMPLATE_PLACEHOLDER, &data[len - 1] - pTemplateStart + 1))) + { + // data[0] ... data[len - 1] + uint8_t* pTemplateEnd = (pTemplateStart < &data[len - 1]) ? (uint8_t*)memchr(pTemplateStart + 1, TEMPLATE_PLACEHOLDER, + &data[len - 1] - pTemplateStart) : nullptr; + // temporary buffer to hold parameter name + uint8_t buf[TEMPLATE_PARAM_NAME_LENGTH + 1]; + String paramName; + + // If closing placeholder is found: + if (pTemplateEnd) + { + // prepare argument to callback + const size_t paramNameLength = std::min(sizeof(buf) - 1, (unsigned int)(pTemplateEnd - pTemplateStart - 1)); + + if (paramNameLength) + { + memcpy(buf, pTemplateStart + 1, paramNameLength); + buf[paramNameLength] = 0; + paramName = String(reinterpret_cast(buf)); + } + else + { + // double percent sign encountered, this is single percent sign escaped. + // remove the 2nd percent sign + memmove(pTemplateEnd, pTemplateEnd + 1, &data[len] - pTemplateEnd - 1); + len += _readDataFromCacheOrContent(&data[len - 1], 1) - 1; + ++pTemplateStart; + } + } + else if (&data[len - 1] - pTemplateStart + 1 < TEMPLATE_PARAM_NAME_LENGTH + 2) + { + // closing placeholder not found, check if it's in the remaining file data + memcpy(buf, pTemplateStart + 1, &data[len - 1] - pTemplateStart); + + const size_t readFromCacheOrContent = _readDataFromCacheOrContent(buf + (&data[len - 1] - pTemplateStart), + TEMPLATE_PARAM_NAME_LENGTH + 2 - (&data[len - 1] - pTemplateStart + 1)); + + if (readFromCacheOrContent) + { + pTemplateEnd = (uint8_t*)memchr(buf + (&data[len - 1] - pTemplateStart), TEMPLATE_PLACEHOLDER, readFromCacheOrContent); + + if (pTemplateEnd) + { + // prepare argument to callback + *pTemplateEnd = 0; + paramName = String(reinterpret_cast(buf)); + + // Copy remaining read-ahead data into cache + _cache.insert(_cache.begin(), pTemplateEnd + 1, buf + (&data[len - 1] - pTemplateStart) + readFromCacheOrContent); + pTemplateEnd = &data[len - 1]; + } + else // closing placeholder not found in file data, store found percent symbol as is and advance to the next position + { + // but first, store read file data in cache + _cache.insert(_cache.begin(), buf + (&data[len - 1] - pTemplateStart), + buf + (&data[len - 1] - pTemplateStart) + readFromCacheOrContent); + ++pTemplateStart; + } + } + else // closing placeholder not found in content data, store found percent symbol as is and advance to the next position + ++pTemplateStart; + } + else // closing placeholder not found in content data, store found percent symbol as is and advance to the next position + ++pTemplateStart; + + if (paramName.length()) + { + // call callback and replace with result. + // Everything in range [pTemplateStart, pTemplateEnd] can be safely replaced with parameter value. + // Data after pTemplateEnd may need to be moved. + // The first byte of data after placeholder is located at pTemplateEnd + 1. + // It should be located at pTemplateStart + numBytesCopied (to begin right after inserted parameter value). + const String paramValue(_callback(paramName)); + const char* pvstr = paramValue.c_str(); + const unsigned int pvlen = paramValue.length(); + const size_t numBytesCopied = std::min(pvlen, static_cast(&data[originalLen - 1] - pTemplateStart + 1)); + + // make room for param value + // 1. move extra data to cache if parameter value is longer than placeholder AND if there is no room to store + if ((pTemplateEnd + 1 < pTemplateStart + numBytesCopied) + && (originalLen - (pTemplateStart + numBytesCopied - pTemplateEnd - 1) < len)) + { + _cache.insert(_cache.begin(), &data[originalLen - (pTemplateStart + numBytesCopied - pTemplateEnd - 1)], &data[len]); + //2. parameter value is longer than placeholder text, push the data after placeholder which not saved into cache further to the end + memmove(pTemplateStart + numBytesCopied, pTemplateEnd + 1, &data[originalLen] - pTemplateStart - numBytesCopied); + len = originalLen; // fix issue with truncated data, not sure if it has any side effects + } + else if (pTemplateEnd + 1 != pTemplateStart + numBytesCopied) + //2. Either parameter value is shorter than placeholder text OR there is enough free space in buffer to fit. + // Move the entire data after the placeholder + memmove(pTemplateStart + numBytesCopied, pTemplateEnd + 1, &data[len] - pTemplateEnd - 1); + + // 3. replace placeholder with actual value + memcpy(pTemplateStart, pvstr, numBytesCopied); + + // If result is longer than buffer, copy the remainder into cache (this could happen only if placeholder text itself did not fit entirely in buffer) + if (numBytesCopied < pvlen) + { + _cache.insert(_cache.begin(), pvstr + numBytesCopied, pvstr + pvlen); + } + else if (pTemplateStart + numBytesCopied < pTemplateEnd + 1) + { + // result is copied fully; if result is shorter than placeholder text... + // there is some free room, fill it from cache + const size_t roomFreed = pTemplateEnd + 1 - pTemplateStart - numBytesCopied; + const size_t totalFreeRoom = originalLen - len + roomFreed; + len += _readDataFromCacheOrContent(&data[len - roomFreed], totalFreeRoom) - roomFreed; + } + else + { + // result is copied fully; it is longer than placeholder text + const size_t roomTaken = pTemplateStart + numBytesCopied - pTemplateEnd - 1; + len = std::min(len + roomTaken, originalLen); + } + } + } // while(pTemplateStart) + + return len; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + File Response + * */ + +AsyncFileResponse::~AsyncFileResponse() +{ + if (_content) + _content.close(); +} + +///////////////////////////////////////////////// + +void AsyncFileResponse::_setContentType(const String& path) +{ + if (path.endsWith(".html")) + _contentType = "text/html"; + else if (path.endsWith(".htm")) + _contentType = "text/html"; + else if (path.endsWith(".css")) + _contentType = "text/css"; + else if (path.endsWith(".json")) + _contentType = "application/json"; + else if (path.endsWith(".js")) + _contentType = "application/javascript"; + else if (path.endsWith(".png")) + _contentType = "image/png"; + else if (path.endsWith(".gif")) + _contentType = "image/gif"; + else if (path.endsWith(".jpg")) + _contentType = "image/jpeg"; + else if (path.endsWith(".ico")) + _contentType = "image/x-icon"; + else if (path.endsWith(".svg")) + _contentType = "image/svg+xml"; + else if (path.endsWith(".eot")) + _contentType = "font/eot"; + else if (path.endsWith(".woff")) + _contentType = "font/woff"; + else if (path.endsWith(".woff2")) + _contentType = "font/woff2"; + else if (path.endsWith(".ttf")) + _contentType = "font/ttf"; + else if (path.endsWith(".xml")) + _contentType = "text/xml"; + else if (path.endsWith(".pdf")) + _contentType = "application/pdf"; + else if (path.endsWith(".zip")) + _contentType = "application/zip"; + else if (path.endsWith(".gz")) + _contentType = "application/x-gzip"; + else + _contentType = "text/plain"; +} + +///////////////////////////////////////////////// + +AsyncFileResponse::AsyncFileResponse(FS &fs, const String& path, const String& contentType, bool download, + AwsTemplateProcessor callback): AsyncAbstractResponse(callback) +{ + _code = 200; + _path = path; + + if (!download && !fs.exists(_path) && fs.exists(_path + ".gz")) + { + _path = _path + ".gz"; + addHeader("Content-Encoding", "gzip"); + _callback = nullptr; // Unable to process zipped templates + _sendContentLength = true; + _chunked = false; + } + + _content = fs.open(_path, "r"); + _contentLength = _content.size(); + + if (contentType == "") + _setContentType(path); + else + _contentType = contentType; + + int filenameStart = path.lastIndexOf('/') + 1; + char buf[26 + path.length() - filenameStart]; + char* filename = (char*)path.c_str() + filenameStart; + + if (download) + { + // set filename and force download + snprintf(buf, sizeof (buf), "attachment; filename=\"%s\"", filename); + } + else + { + // set filename and force rendering + snprintf(buf, sizeof (buf), "inline; filename=\"%s\"", filename); + } + + addHeader("Content-Disposition", buf); +} + +///////////////////////////////////////////////// + +AsyncFileResponse::AsyncFileResponse(File content, const String& path, const String& contentType, bool download, + AwsTemplateProcessor callback): AsyncAbstractResponse(callback) +{ + _code = 200; + _path = path; + + if (!download && String(content.name()).endsWith(".gz") && !path.endsWith(".gz")) + { + addHeader("Content-Encoding", "gzip"); + _callback = nullptr; // Unable to process gzipped templates + _sendContentLength = true; + _chunked = false; + } + + _content = content; + _contentLength = _content.size(); + + if (contentType == "") + _setContentType(path); + else + _contentType = contentType; + + int filenameStart = path.lastIndexOf('/') + 1; + char buf[26 + path.length() - filenameStart]; + char* filename = (char*)path.c_str() + filenameStart; + + if (download) + { + snprintf(buf, sizeof (buf), "attachment; filename=\"%s\"", filename); + } + else + { + snprintf(buf, sizeof (buf), "inline; filename=\"%s\"", filename); + } + + addHeader("Content-Disposition", buf); +} + +///////////////////////////////////////////////// + +size_t AsyncFileResponse::_fillBuffer(uint8_t *data, size_t len) +{ + return _content.read(data, len); +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Stream Response + * */ + +AsyncStreamResponse::AsyncStreamResponse(Stream &stream, const String& contentType, size_t len, + AwsTemplateProcessor callback): AsyncAbstractResponse(callback) +{ + _code = 200; + _content = &stream; + _contentLength = len; + _contentType = contentType; +} + +///////////////////////////////////////////////// + +size_t AsyncStreamResponse::_fillBuffer(uint8_t *data, size_t len) +{ + size_t available = _content->available(); + size_t outLen = (available > len) ? len : available; + size_t i; + + for (i = 0; i < outLen; i++) + data[i] = _content->read(); + + return outLen; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Callback Response + * */ + +AsyncCallbackResponse::AsyncCallbackResponse(const String& contentType, size_t len, AwsResponseFiller callback, + AwsTemplateProcessor templateCallback): AsyncAbstractResponse(templateCallback) +{ + _code = 200; + _content = callback; + _contentLength = len; + + if (!len) + _sendContentLength = false; + + _contentType = contentType; + _filledLength = 0; +} + +///////////////////////////////////////////////// + +size_t AsyncCallbackResponse::_fillBuffer(uint8_t *data, size_t len) +{ + size_t ret = _content(data, len, _filledLength); + + if (ret != RESPONSE_TRY_AGAIN) + { + _filledLength += ret; + } + + return ret; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Chunked Response + * */ + +AsyncChunkedResponse::AsyncChunkedResponse(const String& contentType, AwsResponseFiller callback, + AwsTemplateProcessor processorCallback): AsyncAbstractResponse(processorCallback) +{ + _code = 200; + _content = callback; + _contentLength = 0; + _contentType = contentType; + _sendContentLength = false; + _chunked = true; + _filledLength = 0; +} + +///////////////////////////////////////////////// + +size_t AsyncChunkedResponse::_fillBuffer(uint8_t *data, size_t len) +{ + size_t ret = _content(data, len, _filledLength); + + if (ret != RESPONSE_TRY_AGAIN) + { + _filledLength += ret; + } + + return ret; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Progmem Response + * */ + +AsyncProgmemResponse::AsyncProgmemResponse(int code, const String& contentType, const uint8_t * content, size_t len, + AwsTemplateProcessor callback): AsyncAbstractResponse(callback) +{ + _code = code; + _content = content; + _contentType = contentType; + _contentLength = len; + _readLength = 0; +} + +///////////////////////////////////////////////// + +size_t AsyncProgmemResponse::_fillBuffer(uint8_t *data, size_t len) +{ + size_t left = _contentLength - _readLength; + + if (left > len) + { + memcpy_P(data, _content + _readLength, len); + _readLength += len; + return len; + } + + memcpy_P(data, _content + _readLength, left); + _readLength += left; + + return left; +} + +///////////////////////////////////////////////// +///////////////////////////////////////////////// + +/* + Response Stream (You can print/write/printf to it, up to the contentLen bytes) + * */ + +AsyncResponseStream::AsyncResponseStream(const String& contentType, size_t bufferSize) +{ + _code = 200; + _contentLength = 0; + _contentType = contentType; + _content = new cbuf(bufferSize); +} + +///////////////////////////////////////////////// + +AsyncResponseStream::~AsyncResponseStream() +{ + delete _content; +} + +///////////////////////////////////////////////// + +size_t AsyncResponseStream::_fillBuffer(uint8_t *buf, size_t maxLen) +{ + return _content->read((char*)buf, maxLen); +} + +///////////////////////////////////////////////// + +size_t AsyncResponseStream::write(const uint8_t *data, size_t len) +{ + if (_started()) + return 0; + + if (len > _content->room()) + { + size_t needed = len - _content->room(); + _content->resizeAdd(needed); + } + + size_t written = _content->write((const char*)data, len); + _contentLength += written; + + return written; +} + +///////////////////////////////////////////////// + +size_t AsyncResponseStream::write(uint8_t data) +{ + return write(&data, 1); +} + +///////////////////////////////////////////////// + diff --git a/src/WebServer.cpp b/src/WebServer.cpp new file mode 100644 index 0000000..caf4ea5 --- /dev/null +++ b/src/WebServer.cpp @@ -0,0 +1,313 @@ +/**************************************************************************************************************************** + WebServer.cpp - Dead simple Ethernet AsyncWebServer. + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ + +#include "AsyncWebServer_ESP32_ENC.h" +#include "WebHandlerImpl.h" + +///////////////////////////////////////////////// + +bool ON_STA_FILTER(AsyncWebServerRequest *request) +{ + return ETH.localIP() == request->client()->localIP(); +} + +///////////////////////////////////////////////// + +bool ON_AP_FILTER(AsyncWebServerRequest *request) +{ + return ETH.localIP() != request->client()->localIP(); +} + +///////////////////////////////////////////////// + +AsyncWebServer::AsyncWebServer(uint16_t port) + : _server(port), + _rewrites(LinkedList([](AsyncWebRewrite * r) +{ + delete r; +})), +_handlers(LinkedList([](AsyncWebHandler* h) +{ + delete h; +})) +{ + _catchAllHandler = new AsyncCallbackWebHandler(); + + if (_catchAllHandler == NULL) + return; + + _server.onClient([](void *s, AsyncClient * c) + { + if (c == NULL) + return; + + c->setRxTimeout(3); + AsyncWebServerRequest *r = new AsyncWebServerRequest((AsyncWebServer*)s, c); + + if (r == NULL) + { + c->close(true); + c->free(); + delete c; + } + }, this); +} + +///////////////////////////////////////////////// + +AsyncWebServer::~AsyncWebServer() +{ + reset(); + end(); + + if (_catchAllHandler) + delete _catchAllHandler; +} + +///////////////////////////////////////////////// + +AsyncWebRewrite& AsyncWebServer::addRewrite(AsyncWebRewrite* rewrite) +{ + _rewrites.add(rewrite); + + return *rewrite; +} + +///////////////////////////////////////////////// + +bool AsyncWebServer::removeRewrite(AsyncWebRewrite *rewrite) +{ + return _rewrites.remove(rewrite); +} + +///////////////////////////////////////////////// + +AsyncWebRewrite& AsyncWebServer::rewrite(const char* from, const char* to) +{ + return addRewrite(new AsyncWebRewrite(from, to)); +} + +///////////////////////////////////////////////// + +AsyncWebHandler& AsyncWebServer::addHandler(AsyncWebHandler* handler) +{ + _handlers.add(handler); + + return *handler; +} + +///////////////////////////////////////////////// + +bool AsyncWebServer::removeHandler(AsyncWebHandler *handler) +{ + return _handlers.remove(handler); +} + +///////////////////////////////////////////////// + +void AsyncWebServer::begin() +{ + _server.setNoDelay(true); + _server.begin(); +} + +///////////////////////////////////////////////// + +void AsyncWebServer::end() +{ + _server.end(); +} + +///////////////////////////////////////////////// + +#if ASYNC_TCP_SSL_ENABLED + +void AsyncWebServer::onSslFileRequest(AcSSlFileHandler cb, void* arg) +{ + _server.onSslFileRequest(cb, arg); +} + +///////////////////////////////////////////////// + +void AsyncWebServer::beginSecure(const char *cert, const char *key, const char *password) +{ + _server.beginSecure(cert, key, password); +} + +#endif + +///////////////////////////////////////////////// + +void AsyncWebServer::_handleDisconnect(AsyncWebServerRequest *request) +{ + delete request; +} + +///////////////////////////////////////////////// + +void AsyncWebServer::_rewriteRequest(AsyncWebServerRequest *request) +{ + for (const auto& r : _rewrites) + { + if (r->match(request)) + { + request->_url = r->toUrl(); + request->_addGetParams(r->params()); + } + } +} + +///////////////////////////////////////////////// + +void AsyncWebServer::_attachHandler(AsyncWebServerRequest *request) +{ + for (const auto& h : _handlers) + { + if (h->filter(request) && h->canHandle(request)) + { + request->setHandler(h); + return; + } + } + + request->addInterestingHeader("ANY"); + request->setHandler(_catchAllHandler); +} + +///////////////////////////////////////////////// + +AsyncCallbackWebHandler& AsyncWebServer::on(const char* uri, WebRequestMethodComposite method, + ArRequestHandlerFunction onRequest, + ArUploadHandlerFunction onUpload, ArBodyHandlerFunction onBody) +{ + AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); + handler->setUri(uri); + handler->setMethod(method); + handler->onRequest(onRequest); + handler->onUpload(onUpload); + handler->onBody(onBody); + addHandler(handler); + + return *handler; +} + +///////////////////////////////////////////////// + +AsyncCallbackWebHandler& AsyncWebServer::on(const char* uri, WebRequestMethodComposite method, + ArRequestHandlerFunction onRequest, + ArUploadHandlerFunction onUpload) +{ + AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); + handler->setUri(uri); + handler->setMethod(method); + handler->onRequest(onRequest); + handler->onUpload(onUpload); + addHandler(handler); + + return *handler; +} + +///////////////////////////////////////////////// + +AsyncCallbackWebHandler& AsyncWebServer::on(const char* uri, WebRequestMethodComposite method, + ArRequestHandlerFunction onRequest) +{ + AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); + handler->setUri(uri); + handler->setMethod(method); + handler->onRequest(onRequest); + addHandler(handler); + + return *handler; +} + +///////////////////////////////////////////////// + +AsyncCallbackWebHandler& AsyncWebServer::on(const char* uri, ArRequestHandlerFunction onRequest) +{ + AsyncCallbackWebHandler* handler = new AsyncCallbackWebHandler(); + handler->setUri(uri); + handler->onRequest(onRequest); + addHandler(handler); + + return *handler; +} + +///////////////////////////////////////////////// + +AsyncStaticWebHandler& AsyncWebServer::serveStatic(const char* uri, fs::FS& fs, const char* path, + const char* cache_control) +{ + AsyncStaticWebHandler* handler = new AsyncStaticWebHandler(uri, fs, path, cache_control); + addHandler(handler); + + return *handler; +} + +///////////////////////////////////////////////// + +void AsyncWebServer::onNotFound(ArRequestHandlerFunction fn) +{ + _catchAllHandler->onRequest(fn); +} + +///////////////////////////////////////////////// + +void AsyncWebServer::onFileUpload(ArUploadHandlerFunction fn) +{ + _catchAllHandler->onUpload(fn); +} + +///////////////////////////////////////////////// + +void AsyncWebServer::onRequestBody(ArBodyHandlerFunction fn) +{ + _catchAllHandler->onBody(fn); +} + +///////////////////////////////////////////////// + +void AsyncWebServer::reset() +{ + _rewrites.free(); + _handlers.free(); + + if (_catchAllHandler != NULL) + { + _catchAllHandler->onRequest(NULL); + _catchAllHandler->onUpload(NULL); + _catchAllHandler->onBody(NULL); + } +} + +///////////////////////////////////////////////// + + diff --git a/src/edit.htm b/src/edit.htm new file mode 100644 index 0000000..43d4984 --- /dev/null +++ b/src/edit.htm @@ -0,0 +1,627 @@ + + + + +ESP Editor + + + + + + +

+
+
+
+ + + + diff --git a/src/enc28j60/esp32_enc28j60.cpp b/src/enc28j60/esp32_enc28j60.cpp new file mode 100644 index 0000000..b7039c8 --- /dev/null +++ b/src/enc28j60/esp32_enc28j60.cpp @@ -0,0 +1,427 @@ +/**************************************************************************************************************************** + esp32_enc28j60.cpp + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ +/* + Based on ETH.h from arduino-esp32 and esp-idf + and Tobozo ESP32-ENC28J60 library +*/ + +#include "AsyncWebServer_ESP32_ENC_Debug.h" +#include "esp32_enc28j60.h" + +extern "C" +{ + esp_eth_mac_t* enc28j60_begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, + int SPI_HOST); +#include "extmod/esp_eth_enc28j60.h" +} + +#include "esp_event.h" +#include "esp_eth_phy.h" +#include "esp_eth_mac.h" +#include "esp_eth_com.h" + +#if CONFIG_IDF_TARGET_ESP32 + #include "soc/emac_ext_struct.h" + #include "soc/rtc.h" +#endif + +#include "lwip/err.h" +#include "lwip/dns.h" + +extern void tcpipInit(); + +//////////////////////////////////////// + +ESP32_ENC::ESP32_ENC() + : initialized(false) + , staticIP(false) + , eth_handle(NULL) + , started(false) + , eth_link(ETH_LINK_DOWN) +{ +} + +//////////////////////////////////////// + +ESP32_ENC::~ESP32_ENC() +{} + +//////////////////////////////////////// + +bool ESP32_ENC::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 *ENC28J60_Mac) +{ + tcpipInit(); + + esp_base_mac_addr_set( ENC28J60_Mac ); + + tcpip_adapter_set_default_eth_handlers(); + + esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH(); + esp_netif_t *eth_netif = esp_netif_new(&cfg); + + esp_eth_mac_t *eth_mac = enc28j60_begin(MISO_GPIO, MOSI_GPIO, SCLK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST); + + if (eth_mac == NULL) + { + AWS_LOGERROR("esp_eth_mac_new_esp32 failed"); + + return false; + } + + eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); + phy_config.autonego_timeout_ms = 0; // ENC28J60 doesn't support auto-negotiation + phy_config.reset_gpio_num = -1; // ENC28J60 doesn't have a pin to reset internal PHY + esp_eth_phy_t *eth_phy = esp_eth_phy_new_enc28j60(&phy_config); + + if (eth_phy == NULL) + { + AWS_LOGERROR("esp_eth_phy_new failed"); + + return false; + } + + eth_handle = NULL; + esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(eth_mac, eth_phy); + + if (esp_eth_driver_install(ð_config, ð_handle) != ESP_OK || eth_handle == NULL) + { + AWS_LOG("esp_eth_driver_install failed"); + + return false; + } + + eth_mac->set_addr(eth_mac, ENC28J60_Mac); + + if (emac_enc28j60_get_chip_info(eth_mac) < ENC28J60_REV_B5 && SPI_CLOCK_MHZ < 8) + { + AWS_LOGERROR("SPI Clock must be >= 8 MHz for ENC28J60_REV_B5"); + ESP_ERROR_CHECK(ESP_FAIL); + } + + /* attach Ethernet driver to TCP/IP stack */ + if (esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)) != ESP_OK) + { + AWS_LOGERROR("esp_netif_attach failed"); + + return false; + } + + if (esp_eth_start(eth_handle) != ESP_OK) + { + AWS_LOG("esp_eth_start failed"); + + return false; + } + + // holds a few microseconds to let DHCP start and enter into a good state + // FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733 + delay(50); + + return true; +} + +//////////////////////////////////////// + +bool ESP32_ENC::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) +{ + esp_err_t err = ESP_OK; + tcpip_adapter_ip_info_t info; + + if (static_cast(local_ip) != 0) + { + info.ip.addr = static_cast(local_ip); + info.gw.addr = static_cast(gateway); + info.netmask.addr = static_cast(subnet); + } + else + { + info.ip.addr = 0; + info.gw.addr = 0; + info.netmask.addr = 0; + } + + err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH); + + if (err != ESP_OK && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED) + { + AWS_LOGERROR1("DHCP could not be stopped! Error =", err); + return false; + } + + err = tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info); + + if (err != ERR_OK) + { + AWS_LOGERROR1("STA IP could not be configured! Error = ", err); + return false; + } + + if (info.ip.addr) + { + staticIP = true; + } + else + { + err = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH); + + if (err != ESP_OK && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STARTED) + { + AWS_LOGWARN1("DHCP could not be started! Error =", err); + return false; + } + + staticIP = false; + } + + ip_addr_t d; + d.type = IPADDR_TYPE_V4; + + if (static_cast(dns1) != 0) + { + // Set DNS1-Server + d.u_addr.ip4.addr = static_cast(dns1); + dns_setserver(0, &d); + } + + if (static_cast(dns2) != 0) + { + // Set DNS2-Server + d.u_addr.ip4.addr = static_cast(dns2); + dns_setserver(1, &d); + } + + return true; +} + +//////////////////////////////////////// + +IPAddress ESP32_ENC::localIP() +{ + tcpip_adapter_ip_info_t ip; + + if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) + { + return IPAddress(); + } + + return IPAddress(ip.ip.addr); +} + +//////////////////////////////////////// + +IPAddress ESP32_ENC::subnetMask() +{ + tcpip_adapter_ip_info_t ip; + + if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) + { + return IPAddress(); + } + + return IPAddress(ip.netmask.addr); +} + +//////////////////////////////////////// + +IPAddress ESP32_ENC::gatewayIP() +{ + tcpip_adapter_ip_info_t ip; + + if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) + { + return IPAddress(); + } + + return IPAddress(ip.gw.addr); +} + +//////////////////////////////////////// + +IPAddress ESP32_ENC::dnsIP(uint8_t dns_no) +{ + const ip_addr_t * dns_ip = dns_getserver(dns_no); + + return IPAddress(dns_ip->u_addr.ip4.addr); +} + +//////////////////////////////////////// + +IPAddress ESP32_ENC::broadcastIP() +{ + tcpip_adapter_ip_info_t ip; + + if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) + { + return IPAddress(); + } + + return WiFiGenericClass::calculateBroadcast(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr)); +} + +//////////////////////////////////////// + +IPAddress ESP32_ENC::networkID() +{ + tcpip_adapter_ip_info_t ip; + + if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) + { + return IPAddress(); + } + + return WiFiGenericClass::calculateNetworkID(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr)); +} + +//////////////////////////////////////// + +uint8_t ESP32_ENC::subnetCIDR() +{ + tcpip_adapter_ip_info_t ip; + + if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) + { + return (uint8_t)0; + } + + return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr)); +} + +//////////////////////////////////////// + +const char * ESP32_ENC::getHostname() +{ + const char * hostname; + + if (tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_ETH, &hostname)) + { + return NULL; + } + + return hostname; +} + +//////////////////////////////////////// + +bool ESP32_ENC::setHostname(const char * hostname) +{ + return tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_ETH, hostname) == 0; +} + +//////////////////////////////////////// + +bool ESP32_ENC::fullDuplex() +{ +#ifdef ESP_IDF_VERSION_MAJOR + return true;//todo: do not see an API for this +#else + return eth_config.phy_get_duplex_mode(); +#endif +} + +//////////////////////////////////////// + +bool ESP32_ENC::linkUp() +{ +#ifdef ESP_IDF_VERSION_MAJOR + return eth_link == ETH_LINK_UP; +#else + return eth_config.phy_check_link(); +#endif +} + +//////////////////////////////////////// + +uint8_t ESP32_ENC::linkSpeed() +{ +#ifdef ESP_IDF_VERSION_MAJOR + eth_speed_t link_speed; + esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &link_speed); + return (link_speed == ETH_SPEED_10M) ? 10 : 100; +#else + return eth_config.phy_get_speed_mode() ? 100 : 10; +#endif +} + +//////////////////////////////////////// + +bool ESP32_ENC::enableIpV6() +{ + return tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_ETH) == 0; +} + +//////////////////////////////////////// + +IPv6Address ESP32_ENC::localIPv6() +{ + static ip6_addr_t addr; + + if (tcpip_adapter_get_ip6_linklocal(TCPIP_ADAPTER_IF_ETH, &addr)) + { + return IPv6Address(); + } + + return IPv6Address(addr.addr); +} + +//////////////////////////////////////// + +uint8_t * ESP32_ENC::macAddress(uint8_t* mac) +{ + if (!mac) + { + return NULL; + } + +#ifdef ESP_IDF_VERSION_MAJOR + esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac); +#else + esp_eth_get_mac(mac); +#endif + + return mac; +} + +//////////////////////////////////////// + +String ESP32_ENC::macAddress() +{ + uint8_t mac[6] = {0, 0, 0, 0, 0, 0}; + char macStr[18] = { 0 }; + macAddress(mac); + sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + + return String(macStr); +} + +//////////////////////////////////////// + +ESP32_ENC ETH; diff --git a/src/enc28j60/esp32_enc28j60.h b/src/enc28j60/esp32_enc28j60.h new file mode 100644 index 0000000..1d62d16 --- /dev/null +++ b/src/enc28j60/esp32_enc28j60.h @@ -0,0 +1,118 @@ +/**************************************************************************************************************************** + esp32_enc28j60.h + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + + Original author: Hristo Gochkov + + Copyright (c) 2016 Hristo Gochkov. All rights reserved. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; + if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version: 1.6.2 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.6.2 K Hoang 27/11/2022 Initial porting for ENC28J60 + ESP32. Sync with AsyncWebServer_WT32_ETH01 v1.6.2 + *****************************************************************************************************************************/ +/* + esp32_enc28j60.h - ETH PHY support for ENC28J60 + Based on ETH.h from arduino-esp32 and esp-idf + and Tobozo ESP32-ENC28J60 library +*/ + +#ifndef _ESP32_ENC_H_ +#define _ESP32_ENC_H_ + +#include "WiFi.h" +#include "esp_system.h" +#include "esp_eth.h" + +//////////////////////////////////////// + +#if ESP_IDF_VERSION_MAJOR < 4 || ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4,4,0) + #error "This version of Arduino is too old" +#endif + +//////////////////////////////////////// + +static uint8_t ENC28J60_Default_Mac[] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + +//////////////////////////////////////// + +class ESP32_ENC +{ + private: + bool initialized; + bool staticIP; + + //static uint8_t ENC28J60_Default_Mac[6] = { 0x02, 0x00, 0xDE, 0xAD, 0xBE, 0xEF }; + +#if ESP_IDF_VERSION_MAJOR > 3 + esp_eth_handle_t eth_handle; + + protected: + bool started; + eth_link_t eth_link; + static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data); +#else + bool started; + eth_config_t eth_config; +#endif + + public: + ESP32_ENC(); + ~ESP32_ENC(); + + 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 *ENC28J60_Mac = ENC28J60_Default_Mac); + + bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, + IPAddress dns2 = (uint32_t)0x00000000); + + const char * getHostname(); + bool setHostname(const char * hostname); + + bool fullDuplex(); + bool linkUp(); + uint8_t linkSpeed(); + + bool enableIpV6(); + IPv6Address localIPv6(); + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsIP(uint8_t dns_no = 0); + + IPAddress broadcastIP(); + IPAddress networkID(); + uint8_t subnetCIDR(); + + uint8_t * macAddress(uint8_t* mac); + String macAddress(); + + friend class WiFiClient; + friend class WiFiServer; +}; + +//////////////////////////////////////// + +extern ESP32_ENC ETH; + +//////////////////////////////////////// + +#endif /* _ESP32_ENC_H_ */ diff --git a/src/enc28j60/extmod/enc28j60.h b/src/enc28j60/extmod/enc28j60.h new file mode 100644 index 0000000..68d98aa --- /dev/null +++ b/src/enc28j60/extmod/enc28j60.h @@ -0,0 +1,238 @@ +// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + @brief SPI Instruction Set + +*/ +#define ENC28J60_SPI_CMD_RCR (0x00) // Read Control Register +#define ENC28J60_SPI_CMD_RBM (0x01) // Read Buffer Memory +#define ENC28J60_SPI_CMD_WCR (0x02) // Write Control Register +#define ENC28J60_SPI_CMD_WBM (0x03) // Write Buffer Memory +#define ENC28J60_SPI_CMD_BFS (0x04) // Bit Field Set +#define ENC28J60_SPI_CMD_BFC (0x05) // Bit Field Clear +#define ENC28J60_SPI_CMD_SRC (0x07) // Soft Reset + +/** + @brief Shared Registers in ENC28J60 (accessible on each bank) + +*/ +#define ENC28J60_EIE (0x1B) // Ethernet Interrupt Enable +#define ENC28J60_EIR (0x1C) // Ethernet Interrupt flags +#define ENC28J60_ESTAT (0x1D) // Ethernet Status +#define ENC28J60_ECON2 (0x1E) // Ethernet Control Register2 +#define ENC28J60_ECON1 (0x1F) // Ethernet Control Register1 + +/** + @brief Per-bank Registers in ENC28J60 + @note Address[15:12]: Register Type, 0 -> ETH, 1 -> MII/MAC + Address[11:8] : Bank address + Address[7:0] : Register Index +*/ +// Bank 0 Registers +#define ENC28J60_ERDPTL (0x0000) // Read Pointer Low Byte ERDPT<7:0>) +#define ENC28J60_ERDPTH (0x0001) // Read Pointer High Byte (ERDPT<12:8>) +#define ENC28J60_EWRPTL (0x0002) // Write Pointer Low Byte (EWRPT<7:0>) +#define ENC28J60_EWRPTH (0x0003) // Write Pointer High Byte (EWRPT<12:8>) +#define ENC28J60_ETXSTL (0x0004) // TX Start Low Byte (ETXST<7:0>) +#define ENC28J60_ETXSTH (0x0005) // TX Start High Byte (ETXST<12:8>) +#define ENC28J60_ETXNDL (0x0006) // TX End Low Byte (ETXND<7:0>) +#define ENC28J60_ETXNDH (0x0007) // TX End High Byte (ETXND<12:8>) +#define ENC28J60_ERXSTL (0x0008) // RX Start Low Byte (ERXST<7:0>) +#define ENC28J60_ERXSTH (0x0009) // RX Start High Byte (ERXST<12:8>) +#define ENC28J60_ERXNDL (0x000A) // RX End Low Byte (ERXND<7:0>) +#define ENC28J60_ERXNDH (0x000B) // RX End High Byte (ERXND<12:8>) +#define ENC28J60_ERXRDPTL (0x000C) // RX RD Pointer Low Byte (ERXRDPT<7:0>) +#define ENC28J60_ERXRDPTH (0x000D) // RX RD Pointer High Byte (ERXRDPT<12:8>) +#define ENC28J60_ERXWRPTL (0x000E) // RX WR Pointer Low Byte (ERXWRPT<7:0>) +#define ENC28J60_ERXWRPTH (0x000F) // RX WR Pointer High Byte (ERXWRPT<12:8>) +#define ENC28J60_EDMASTL (0x0010) // DMA Start Low Byte (EDMAST<7:0>) +#define ENC28J60_EDMASTH (0x0011) // DMA Start High Byte (EDMAST<12:8>) +#define ENC28J60_EDMANDL (0x0012) // DMA End Low Byte (EDMAND<7:0>) +#define ENC28J60_EDMANDH (0x0013) // DMA End High Byte (EDMAND<12:8>) +#define ENC28J60_EDMADSTL (0x0014) // DMA Destination Low Byte (EDMADST<7:0>) +#define ENC28J60_EDMADSTH (0x0015) // DMA Destination High Byte (EDMADST<12:8>) +#define ENC28J60_EDMACSL (0x0016) // DMA Checksum Low Byte (EDMACS<7:0>) +#define ENC28J60_EDMACSH (0x0017) // DMA Checksum High Byte (EDMACS<15:8>) + +// Bank 1 Registers +#define ENC28J60_EHT0 (0x0100) // Hash Table Byte 0 (EHT<7:0>) +#define ENC28J60_EHT1 (0x0101) // Hash Table Byte 1 (EHT<15:8>) +#define ENC28J60_EHT2 (0x0102) // Hash Table Byte 2 (EHT<23:16>) +#define ENC28J60_EHT3 (0x0103) // Hash Table Byte 3 (EHT<31:24>) +#define ENC28J60_EHT4 (0x0104) // Hash Table Byte 4 (EHT<39:32>) +#define ENC28J60_EHT5 (0x0105) // Hash Table Byte 5 (EHT<47:40>) +#define ENC28J60_EHT6 (0x0106) // Hash Table Byte 6 (EHT<55:48>) +#define ENC28J60_EHT7 (0x0107) // Hash Table Byte 7 (EHT<63:56>) +#define ENC28J60_EPMM0 (0x0108) // Pattern Match Mask Byte 0 (EPMM<7:0>) +#define ENC28J60_EPMM1 (0x0109) // Pattern Match Mask Byte 1 (EPMM<15:8>) +#define ENC28J60_EPMM2 (0x010A) // Pattern Match Mask Byte 2 (EPMM<23:16>) +#define ENC28J60_EPMM3 (0x010B) // Pattern Match Mask Byte 3 (EPMM<31:24>) +#define ENC28J60_EPMM4 (0x010C) // Pattern Match Mask Byte 4 (EPMM<39:32>) +#define ENC28J60_EPMM5 (0x010D) // Pattern Match Mask Byte 5 (EPMM<47:40>) +#define ENC28J60_EPMM6 (0x010E) // Pattern Match Mask Byte 6 (EPMM<55:48>) +#define ENC28J60_EPMM7 (0x010F) // Pattern Match Mask Byte 7 (EPMM<63:56>) +#define ENC28J60_EPMCSL (0x0110) // Pattern Match Checksum Low Byte (EPMCS<7:0>) +#define ENC28J60_EPMCSH (0x0111) // Pattern Match Checksum High Byte (EPMCS<15:0>) +#define ENC28J60_EPMOL (0x0114) // Pattern Match Offset Low Byte (EPMO<7:0>) +#define ENC28J60_EPMOH (0x0115) // Pattern Match Offset High Byte (EPMO<12:8>) +#define ENC28J60_ERXFCON (0x0118) // Receive Fileter Control +#define ENC28J60_EPKTCNT (0x0119) // Ethernet Packet Count + +// Bank 2 Register +#define ENC28J60_MACON1 (0x1200) // MAC Control Register 1 +#define ENC28J60_MACON2 (0x1201) // MAC Control Register 2 +#define ENC28J60_MACON3 (0x1202) // MAC Control Register 3 +#define ENC28J60_MACON4 (0x1203) // MAC Control Register 4 +#define ENC28J60_MABBIPG (0x1204) // Back-to-Back Inter-Packet Gap (BBIPG<6:0>) +#define ENC28J60_MAIPGL (0x1206) // Non-Back-to-Back Inter-Packet Gap Low Byte (MAIPGL<6:0>) +#define ENC28J60_MAIPGH (0x1207) // Non-Back-to-Back Inter-Packet Gap High Byte (MAIPGH<6:0>) +#define ENC28J60_MACLCON1 (0x1208) // Retransmission Maximum (RETMAX<3:0>) +#define ENC28J60_MACLCON2 (0x1209) // Collision Window (COLWIN<5:0>) +#define ENC28J60_MAMXFLL (0x120A) // Maximum Frame Length Low Byte (MAMXFL<7:0>) +#define ENC28J60_MAMXFLH (0x120B) // Maximum Frame Length High Byte (MAMXFL<15:8>) +#define ENC28J60_MICMD (0x1212) // MII Command Register +#define ENC28J60_MIREGADR (0x1214) // MII Register Address (MIREGADR<4:0>) +#define ENC28J60_MIWRL (0x1216) // MII Write Data Low Byte (MIWR<7:0>) +#define ENC28J60_MIWRH (0x1217) // MII Write Data High Byte (MIWR<15:8>) +#define ENC28J60_MIRDL (0x1218) // MII Read Data Low Byte (MIRD<7:0>) +#define ENC28J60_MIRDH (0x1219) // MII Read Data High Byte(MIRD<15:8>) + +// Bank 3 Registers +#define ENC28J60_MAADR5 (0x1300) // MAC Address Byte 5 (MAADR<15:8>) +#define ENC28J60_MAADR6 (0x1301) // MAC Address Byte 6 (MAADR<7:0>) +#define ENC28J60_MAADR3 (0x1302) // MAC Address Byte 3 (MAADR<31:24>), OUI Byte 3 +#define ENC28J60_MAADR4 (0x1303) // MAC Address Byte 4 (MAADR<23:16>) +#define ENC28J60_MAADR1 (0x1304) // MAC Address Byte 1 (MAADR<47:40>), OUI Byte 1 +#define ENC28J60_MAADR2 (0x1305) // MAC Address Byte 2 (MAADR<39:32>), OUI Byte 2 +#define ENC28J60_EBSTSD (0x0306) // Built-in Self-Test Fill Seed (EBSTSD<7:0>) +#define ENC28J60_EBSTCON (0x0307) // Built-in Self-Test Control +#define ENC28J60_EBSTCSL (0x0308) // Built-in Self-Test Checksum Low Byte (EBSTCS<7:0>) +#define ENC28J60_EBSTCSH (0x0309) // Built-in Self-Test Checksum High Byte (EBSTCS<15:8>) +#define ENC28J60_MISTAT (0x130A) // MII Status Register +#define ENC28J60_EREVID (0x0312) // Ethernet Revision ID (EREVID<4:0>) +#define ENC28J60_ECOCON (0x0315) // Clock Output Control Register +#define ENC28J60_EFLOCON (0x0317) // Ethernet Flow Control +#define ENC28J60_EPAUSL (0x0318) // Pause Timer Value Low Byte (EPAUS<7:0>) +#define ENC28J60_EPAUSH (0x0319) // Pause Timer Value High Byte (EPAUS<15:8>) + +/** + @brief status and flag of ENC28J60 specific registers + +*/ +// EIE bit definitions +#define EIE_INTIE (1<<7) // Global INT Interrupt Enable +#define EIE_PKTIE (1<<6) // Receive Packet Pending Interrupt Enable +#define EIE_DMAIE (1<<5) // DMA Interrupt Enable +#define EIE_LINKIE (1<<4) // Link Status Change Interrupt Enable +#define EIE_TXIE (1<<3) // Transmit Enable +#define EIE_TXERIE (1<<1) // Transmit Error Interrupt Enable +#define EIE_RXERIE (1<<0) // Receive Error Interrupt Enable + +// EIR bit definitions +#define EIR_PKTIF (1<<6) // Receive Packet Pending Interrupt Flag +#define EIR_DMAIF (1<<5) // DMA Interrupt Flag +#define EIR_LINKIF (1<<4) // Link Change Interrupt Flag +#define EIR_TXIF (1<<3) // Transmit Interrupt Flag +#define EIR_TXERIF (1<<1) // Transmit Error Interrupt Flag +#define EIR_RXERIF (1<<0) // Receive Error Interrupt Flag + +// ESTAT bit definitions +#define ESTAT_INT (1<<7) // INT Interrupt Flag +#define ESTAT_BUFER (1<<6) // Buffer Error Status +#define ESTAT_LATECOL (1<<4) // Late Collision Error +#define ESTAT_RXBUSY (1<<2) // Receive Busy +#define ESTAT_TXABRT (1<<1) // Transmit Abort Error +#define ESTAT_CLKRDY (1<<0) // Clock Ready + +// ECON2 bit definitions +#define ECON2_AUTOINC (1<<7) // Automatic Buffer Pointer Increment Enable +#define ECON2_PKTDEC (1<<6) // Packet Decrement +#define ECON2_PWRSV (1<<5) // Power Save Enable +#define ECON2_VRPS (1<<3) // Voltage Regulator Power Save Enable + +// ECON1 bit definitions +#define ECON1_TXRST (1<<7) // Transmit Logic Reset +#define ECON1_RXRST (1<<6) // Receive Logic Reset +#define ECON1_DMAST (1<<5) // DMA Start and Busy Status +#define ECON1_CSUMEN (1<<4) // DMA Checksum Enable +#define ECON1_TXRTS (1<<3) // Transmit Request to Send +#define ECON1_RXEN (1<<2) // Receive Enable +#define ECON1_BSEL1 (1<<1) // Bank Select1 +#define ECON1_BSEL0 (1<<0) // Bank Select0 + +// ERXFCON bit definitions +#define ERXFCON_UCEN (1<<7) // Unicast Filter Enable +#define ERXFCON_ANDOR (1<<6) // AND/OR Filter Select +#define ERXFCON_CRCEN (1<<5) // Post-Filter CRC Check Enable +#define ERXFCON_PMEN (1<<4) // Pattern Match Filter Enable +#define ERXFCON_MPEN (1<<3) // Magic Packet Filter Enable +#define ERXFCON_HTEN (1<<2) // Hash Table Filter Enable +#define ERXFCON_MCEN (1<<1) // Multicast Filter Enable +#define ERXFCON_BCEN (1<<0) // Broadcast Filter Enable + +// MACON1 bit definitions +#define MACON1_TXPAUS (1<<3) // Pause Control Frame Transmission Enable +#define MACON1_RXPAUS (1<<2) // Pause Control Frame Reception Enable +#define MACON1_PASSALL (1<<1) // Pass All Received Frames Enable +#define MACON1_MARXEN (1<<0) // MAC Receive Enable + +// MACON3 bit definitions +#define MACON3_PADCFG2 (1<<7) // Automatic Pad and CRC Configuration bit 2 +#define MACON3_PADCFG1 (1<<6) // Automatic Pad and CRC Configuration bit 1 +#define MACON3_PADCFG0 (1<<5) // Automatic Pad and CRC Configuration bit 0 +#define MACON3_TXCRCEN (1<<4) // Transmit CRC Enable +#define MACON3_PHDRLEN (1<<3) // Proprietary Header Enable +#define MACON3_HFRMLEN (1<<2) // Huge Frame Enable +#define MACON3_FRMLNEN (1<<1) // Frame Length Checking Enable +#define MACON3_FULDPX (1<<0) // MAC Full-Duplex Enable + +// MACON4 bit definitions +#define MACON4_DEFER (1<<6) // Defer Transmission Enable +#define MACON4_BPEN (1<<5) // No Backoff During Backpressure Enable +#define MACON4_NOBKFF (1<<4) // No Backoff Enable + +// MICMD bit definitions +#define MICMD_MIISCAN (1<<1) // MII Scan Enable +#define MICMD_MIIRD (1<<0) // MII Read Enable + +// EBSTCON bit definitions +#define EBSTCON_PSV2 (1<<7) // Pattern Shift Value 2 +#define EBSTCON_PSV1 (1<<6) // Pattern Shift Value 1 +#define EBSTCON_PSV0 (1<<5) // Pattern Shift Value 0 +#define EBSTCON_PSEL (1<<4) // Port Select +#define EBSTCON_TMSEL1 (1<<3) // Test Mode Select 1 +#define EBSTCON_TMSEL0 (1<<2) // Test Mode Select 0 +#define EBSTCON_TME (1<<1) // Test Mode Enable +#define EBSTCON_BISTST (1<<0) // Built-in Self-Test Start/Busy + +// MISTAT bit definitions +#define MISTAT_NVALID (1<<2) // MII Management Read Data Not Valid +#define MISTAT_SCAN (1<<1) // MII Management Scan Operation in Progress +#define MISTAT_BUSY (1<<0) // MII Management Busy + +// EFLOCON bit definitions +#define EFLOCON_FULDPXS (1<<2) // Full-Duplex Shadown +#define EFLOCON_FCEN1 (1<<1) // Flow Control Enable 1 +#define EFLOCON_FCEN0 (1<<0) // Flow Control Enable 0 + +#ifdef __cplusplus +} +#endif diff --git a/src/enc28j60/extmod/esp_eth_enc28j60.h b/src/enc28j60/extmod/esp_eth_enc28j60.h new file mode 100644 index 0000000..37a3c56 --- /dev/null +++ b/src/enc28j60/extmod/esp_eth_enc28j60.h @@ -0,0 +1,150 @@ +// Copyright 2021 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////// + +#include "esp_eth_phy.h" +#include "esp_eth_mac.h" +#include "driver/spi_master.h" + +//////////////////////////////////////// + +#define CS_HOLD_TIME_MIN_NS 210 + +//////////////////////////////////////// + +/** + @brief ENC28J60 specific configuration + +*/ +typedef struct +{ + spi_device_handle_t spi_hdl; /*!< Handle of SPI device driver */ + int int_gpio_num; /*!< Interrupt GPIO number */ +} eth_enc28j60_config_t; + +/** + @brief ENC28J60 Supported Revisions + +*/ +typedef enum +{ + ENC28J60_REV_B1 = 0b00000010, + ENC28J60_REV_B4 = 0b00000100, + ENC28J60_REV_B5 = 0b00000101, + ENC28J60_REV_B7 = 0b00000110 +} eth_enc28j60_rev_t; + +/** + @brief Default ENC28J60 specific configuration + +*/ +#define ETH_ENC28J60_DEFAULT_CONFIG(spi_device) \ + { \ + .spi_hdl = spi_device, \ + .int_gpio_num = 4, \ + } + +//////////////////////////////////////// + +/** + @brief Compute amount of SPI bit-cycles the CS should stay active after the transmission + to meet ENC28J60 CS Hold Time specification. + + @param clock_speed_mhz SPI Clock frequency in MHz (valid range is <1, 20>) + @return uint8_t +*/ +static inline uint8_t enc28j60_cal_spi_cs_hold_time(int clock_speed_mhz) +{ + if (clock_speed_mhz <= 0 || clock_speed_mhz > 20) + { + return 0; + } + + int temp = clock_speed_mhz * CS_HOLD_TIME_MIN_NS; + uint8_t cs_posttrans = temp / 1000; + + if (temp % 1000) + { + cs_posttrans += 1; + } + + return cs_posttrans; +} + +//////////////////////////////////////// + +/** + @brief Create ENC28J60 Ethernet MAC instance + + @param[in] enc28j60_config: ENC28J60 specific configuration + @param[in] mac_config: Ethernet MAC configuration + + @return + - instance: create MAC instance successfully + - NULL: create MAC instance failed because some error occurred +*/ +esp_eth_mac_t *esp_eth_mac_new_enc28j60(const eth_enc28j60_config_t *enc28j60_config, + const eth_mac_config_t *mac_config); + +//////////////////////////////////////// + +/** + @brief Create a PHY instance of ENC28J60 + + @param[in] config: configuration of PHY + + @return + - instance: create PHY instance successfully + - NULL: create PHY instance failed because some error occurred +*/ +esp_eth_phy_t *esp_eth_phy_new_enc28j60(const eth_phy_config_t *config); + +//////////////////////////////////////// + +// todo: the below functions should be accessed through ioctl in the future +/** + @brief Set ENC28J60 Duplex mode. It sets Duplex mode first to the PHY and then + MAC is set based on what PHY indicates. + + @param phy ENC28J60 PHY Handle + @param duplex Duplex mode + + @return esp_err_t + - ESP_OK when PHY registers were correctly written. +*/ +esp_err_t enc28j60_set_phy_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex); + +//////////////////////////////////////// + +/** + @brief Get ENC28J60 silicon revision ID + + @param mac ENC28J60 MAC Handle + @return eth_enc28j60_rev_t + - returns silicon revision ID read during initialization +*/ +eth_enc28j60_rev_t emac_enc28j60_get_chip_info(esp_eth_mac_t *mac); + +//////////////////////////////////////// + +#ifdef __cplusplus +} +#endif diff --git a/src/enc28j60/extmod/esp_eth_mac_enc28j60.c b/src/enc28j60/extmod/esp_eth_mac_enc28j60.c new file mode 100644 index 0000000..a1fa1e0 --- /dev/null +++ b/src/enc28j60/extmod/esp_eth_mac_enc28j60.c @@ -0,0 +1,1375 @@ +// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//////////////////////////////////////// + +#include +#include +#include +#include "driver/gpio.h" +#include "esp_attr.h" +#include "esp_log.h" +#include "esp_eth.h" +#include "esp_system.h" +#include "esp_intr_alloc.h" +#include "esp_heap_caps.h" +#include "esp_rom_sys.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#include "hal/cpu_hal.h" +#include "esp_eth_enc28j60.h" +#include "enc28j60.h" +#include "sdkconfig.h" + +//////////////////////////////////////// + +static const char *TAG = "enc28j60"; +#define MAC_CHECK(a, str, goto_tag, ret_value, ...) \ + do \ + { \ + if (!(a)) \ + { \ + ESP_LOGE(TAG, "%s(%d): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + ret = ret_value; \ + goto goto_tag; \ + } \ + } while (0) + +#define MAC_CHECK_NO_RET(a, str, goto_tag, ...) \ + do \ + { \ + if (!(a)) \ + { \ + ESP_LOGE(TAG, "%s(%d): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + goto goto_tag; \ + } \ + } while (0) + +//////////////////////////////////////// + +#define ENC28J60_SPI_LOCK_TIMEOUT_MS (50) +#define ENC28J60_REG_TRANS_LOCK_TIMEOUT_MS (150) +#define ENC28J60_PHY_OPERATION_TIMEOUT_US (150) +#define ENC28J60_SYSTEM_RESET_ADDITION_TIME_US (1000) +#define ENC28J60_TX_READY_TIMEOUT_MS (2000) + +//////////////////////////////////////// + +#define ENC28J60_BUFFER_SIZE (0x2000) // 8KB built-in buffer +/** + ______ + |__TX__| TX: 2 KB : [0x1800, 0x2000) + | | + | RX | RX: 6 KB : [0x0000, 0x1800) + |______| + +*/ +#define ENC28J60_BUF_RX_START (0) +#define ENC28J60_BUF_RX_END (ENC28J60_BUF_TX_START - 1) +#define ENC28J60_BUF_TX_START ((ENC28J60_BUFFER_SIZE / 4) * 3) +#define ENC28J60_BUF_TX_END (ENC28J60_BUFFER_SIZE - 1) + +#define ENC28J60_RSV_SIZE (6) // Receive Status Vector Size +#define ENC28J60_TSV_SIZE (6) // Transmit Status Vector Size + +//////////////////////////////////////// + +typedef struct +{ + uint8_t next_packet_low; + uint8_t next_packet_high; + uint8_t length_low; + uint8_t length_high; + uint8_t status_low; + uint8_t status_high; +} enc28j60_rx_header_t; + +//////////////////////////////////////// + +typedef struct +{ + uint16_t byte_cnt; + + uint8_t collision_cnt: 4; + uint8_t crc_err: 1; + uint8_t len_check_err: 1; + uint8_t len_out_range: 1; + uint8_t tx_done: 1; + + uint8_t multicast: 1; + uint8_t broadcast: 1; + uint8_t pkt_defer: 1; + uint8_t excessive_defer: 1; + uint8_t excessive_collision: 1; + uint8_t late_collision: 1; + uint8_t giant: 1; + uint8_t underrun: 1; + + uint16_t bytes_on_wire; + + uint8_t ctrl_frame: 1; + uint8_t pause_ctrl_frame: 1; + uint8_t backpressure_app: 1; + uint8_t vlan_frame: 1; +} enc28j60_tsv_t; + +//////////////////////////////////////// + +typedef struct +{ + esp_eth_mac_t parent; + esp_eth_mediator_t *eth; + spi_device_handle_t spi_hdl; + SemaphoreHandle_t spi_lock; + SemaphoreHandle_t reg_trans_lock; + SemaphoreHandle_t tx_ready_sem; + TaskHandle_t rx_task_hdl; + uint32_t sw_reset_timeout_ms; + uint32_t next_packet_ptr; + uint32_t last_tsv_addr; + int int_gpio_num; + uint8_t addr[6]; + uint8_t last_bank; + bool packets_remain; + eth_enc28j60_rev_t revision; +} emac_enc28j60_t; + +//////////////////////////////////////// + +static inline bool enc28j60_spi_lock(emac_enc28j60_t *emac) +{ + return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(ENC28J60_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; +} + +//////////////////////////////////////// + +static inline bool enc28j60_spi_unlock(emac_enc28j60_t *emac) +{ + return xSemaphoreGive(emac->spi_lock) == pdTRUE; +} + +//////////////////////////////////////// + +static inline bool enc28j60_reg_trans_lock(emac_enc28j60_t *emac) +{ + return xSemaphoreTake(emac->reg_trans_lock, pdMS_TO_TICKS(ENC28J60_REG_TRANS_LOCK_TIMEOUT_MS)) == pdTRUE; +} + +//////////////////////////////////////// + +static inline bool enc28j60_reg_trans_unlock(emac_enc28j60_t *emac) +{ + return xSemaphoreGive(emac->reg_trans_lock) == pdTRUE; +} + +//////////////////////////////////////// + +/** + @brief ERXRDPT need to be set always at odd addresses +*/ +static inline uint32_t enc28j60_next_ptr_align_odd(uint32_t next_packet_ptr, uint32_t start, uint32_t end) +{ + uint32_t erxrdpt; + + if ((next_packet_ptr - 1 < start) || (next_packet_ptr - 1 > end)) + { + erxrdpt = end; + } + else + { + erxrdpt = next_packet_ptr - 1; + } + + return erxrdpt; +} + +//////////////////////////////////////// + +/** + @brief Calculate wrap around when reading beyond the end of the RX buffer +*/ +static inline uint32_t enc28j60_rx_packet_start(uint32_t start_addr, uint32_t off) +{ + if (start_addr + off > ENC28J60_BUF_RX_END) + { + return (start_addr + off) - (ENC28J60_BUF_RX_END - ENC28J60_BUF_RX_START + 1); + } + else + { + return start_addr + off; + } +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for writing ENC28J60 internal register +*/ +static esp_err_t enc28j60_do_register_write(emac_enc28j60_t *emac, uint8_t reg_addr, uint8_t value) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_WCR, // Write control register + .addr = reg_addr, + .length = 8, + .flags = SPI_TRANS_USE_TXDATA, + .tx_data = { + [0] = value + } + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for reading ENC28J60 internal register +*/ +static esp_err_t enc28j60_do_register_read(emac_enc28j60_t *emac, bool is_eth_reg, uint8_t reg_addr, uint8_t *value) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_RCR, // Read control register + .addr = reg_addr, + .length = is_eth_reg ? 8 : 16, // read operation is different for ETH register and non-ETH register + .flags = SPI_TRANS_USE_RXDATA + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + else + { + *value = is_eth_reg ? trans.rx_data[0] : trans.rx_data[1]; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for bitwise setting ENC28J60 internal register + @note can only be used for ETH registers +*/ +static esp_err_t enc28j60_do_bitwise_set(emac_enc28j60_t *emac, uint8_t reg_addr, uint8_t mask) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_BFS, // Bit field set + .addr = reg_addr, + .length = 8, + .flags = SPI_TRANS_USE_TXDATA, + .tx_data = { + [0] = mask + } + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for bitwise clearing ENC28J60 internal register + @note can only be used for ETH registers +*/ +static esp_err_t enc28j60_do_bitwise_clr(emac_enc28j60_t *emac, uint8_t reg_addr, uint8_t mask) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_BFC, // Bit field clear + .addr = reg_addr, + .length = 8, + .flags = SPI_TRANS_USE_TXDATA, + .tx_data = { + [0] = mask + } + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for writing ENC28J60 internal memory +*/ +static esp_err_t enc28j60_do_memory_write(emac_enc28j60_t *emac, uint8_t *buffer, uint32_t len) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_WBM, // Write buffer memory + .addr = 0x1A, + .length = len * 8, + .tx_buffer = buffer + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for reading ENC28J60 internal memory +*/ +static esp_err_t enc28j60_do_memory_read(emac_enc28j60_t *emac, uint8_t *buffer, uint32_t len) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_RBM, // Read buffer memory + .addr = 0x1A, + .length = len * 8, + .rx_buffer = buffer + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +} + +//////////////////////////////////////// + +/** + @brief SPI operation wrapper for resetting ENC28J60 +*/ +static esp_err_t enc28j60_do_reset(emac_enc28j60_t *emac) +{ + esp_err_t ret = ESP_OK; + spi_transaction_t trans = + { + .cmd = ENC28J60_SPI_CMD_SRC, // Soft reset + .addr = 0x1F, + }; + + if (enc28j60_spi_lock(emac)) + { + if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) + { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } + + enc28j60_spi_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + // After reset, wait at least 1ms for the device to be ready + esp_rom_delay_us(ENC28J60_SYSTEM_RESET_ADDITION_TIME_US); + + return ret; +} + +//////////////////////////////////////// + +/** + @brief Switch ENC28J60 register bank +*/ +static esp_err_t enc28j60_switch_register_bank(emac_enc28j60_t *emac, uint8_t bank) +{ + esp_err_t ret = ESP_OK; + + if (bank != emac->last_bank) + { + MAC_CHECK(enc28j60_do_bitwise_clr(emac, ENC28J60_ECON1, 0x03) == ESP_OK, + "clear ECON1[1:0] failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_bitwise_set(emac, ENC28J60_ECON1, bank & 0x03) == ESP_OK, + "set ECON1[1:0] failed", out, ESP_FAIL); + emac->last_bank = bank; + } + +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Write ENC28J60 register +*/ +static esp_err_t enc28j60_register_write(emac_enc28j60_t *emac, uint16_t reg_addr, uint8_t value) +{ + esp_err_t ret = ESP_OK; + + if (enc28j60_reg_trans_lock(emac)) + { + MAC_CHECK(enc28j60_switch_register_bank(emac, (reg_addr & 0xF00) >> 8) == ESP_OK, + "switch bank failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_register_write(emac, reg_addr & 0xFF, value) == ESP_OK, + "write register failed", out, ESP_FAIL); + enc28j60_reg_trans_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +out: + enc28j60_reg_trans_unlock(emac); + return ret; +} + +//////////////////////////////////////// + +/** + @brief Read ENC28J60 register +*/ +static esp_err_t enc28j60_register_read(emac_enc28j60_t *emac, uint16_t reg_addr, uint8_t *value) +{ + esp_err_t ret = ESP_OK; + + if (enc28j60_reg_trans_lock(emac)) + { + MAC_CHECK(enc28j60_switch_register_bank(emac, (reg_addr & 0xF00) >> 8) == ESP_OK, + "switch bank failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_register_read(emac, !(reg_addr & 0xF000), reg_addr & 0xFF, value) == ESP_OK, + "read register failed", out, ESP_FAIL); + enc28j60_reg_trans_unlock(emac); + } + else + { + ret = ESP_ERR_TIMEOUT; + } + + return ret; +out: + enc28j60_reg_trans_unlock(emac); + return ret; +} + +//////////////////////////////////////// + +/** + @brief Read ENC28J60 internal memroy +*/ +static esp_err_t enc28j60_read_packet(emac_enc28j60_t *emac, uint32_t addr, uint8_t *packet, uint32_t len) +{ + esp_err_t ret = ESP_OK; + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERDPTL, addr & 0xFF) == ESP_OK, + "write ERDPTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERDPTH, (addr & 0xFF00) >> 8) == ESP_OK, + "write ERDPTH failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_memory_read(emac, packet, len) == ESP_OK, + "read memory failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Write ENC28J60 internal PHY register +*/ +static esp_err_t emac_enc28j60_write_phy_reg(esp_eth_mac_t *mac, uint32_t phy_addr, + uint32_t phy_reg, uint32_t reg_value) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + uint8_t mii_status; + + /* check if phy access is in progress */ + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MISTAT, &mii_status) == ESP_OK, + "read MISTAT failed", out, ESP_FAIL); + MAC_CHECK(!(mii_status & MISTAT_BUSY), "phy is busy", out, ESP_ERR_INVALID_STATE); + + /* tell the PHY address to write */ + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MIREGADR, phy_reg & 0xFF) == ESP_OK, + "write MIREGADR failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MIWRL, reg_value & 0xFF) == ESP_OK, + "write MIWRL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MIWRH, (reg_value & 0xFF00) >> 8) == ESP_OK, + "write MIWRH failed", out, ESP_FAIL); + + /* polling the busy flag */ + uint32_t to = 0; + + do + { + esp_rom_delay_us(15); + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MISTAT, &mii_status) == ESP_OK, + "read MISTAT failed", out, ESP_FAIL); + to += 15; + } while ((mii_status & MISTAT_BUSY) && to < ENC28J60_PHY_OPERATION_TIMEOUT_US); + + MAC_CHECK(!(mii_status & MISTAT_BUSY), "phy is busy", out, ESP_ERR_TIMEOUT); +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Read ENC28J60 internal PHY register +*/ +static esp_err_t emac_enc28j60_read_phy_reg(esp_eth_mac_t *mac, uint32_t phy_addr, + uint32_t phy_reg, uint32_t *reg_value) +{ + esp_err_t ret = ESP_OK; + MAC_CHECK(reg_value, "can't set reg_value to null", out, ESP_ERR_INVALID_ARG); + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + uint8_t mii_status; + uint8_t mii_cmd; + + /* check if phy access is in progress */ + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MISTAT, &mii_status) == ESP_OK, + "read MISTAT failed", out, ESP_FAIL); + MAC_CHECK(!(mii_status & MISTAT_BUSY), "phy is busy", out, ESP_ERR_INVALID_STATE); + + /* tell the PHY address to read */ + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MIREGADR, phy_reg & 0xFF) == ESP_OK, + "write MIREGADR failed", out, ESP_FAIL); + mii_cmd = MICMD_MIIRD; + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MICMD, mii_cmd) == ESP_OK, + "write MICMD failed", out, ESP_FAIL); + + /* polling the busy flag */ + uint32_t to = 0; + + do + { + esp_rom_delay_us(15); + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MISTAT, &mii_status) == ESP_OK, + "read MISTAT failed", out, ESP_FAIL); + to += 15; + } while ((mii_status & MISTAT_BUSY) && to < ENC28J60_PHY_OPERATION_TIMEOUT_US); + + MAC_CHECK(!(mii_status & MISTAT_BUSY), "phy is busy", out, ESP_ERR_TIMEOUT); + + mii_cmd &= (~MICMD_MIIRD); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MICMD, mii_cmd) == ESP_OK, + "write MICMD failed", out, ESP_FAIL); + + uint8_t value_l = 0; + uint8_t value_h = 0; + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MIRDL, &value_l) == ESP_OK, + "read MIRDL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MIRDH, &value_h) == ESP_OK, + "read MIRDH failed", out, ESP_FAIL); + *reg_value = (value_h << 8) | value_l; +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Set mediator for Ethernet MAC +*/ +static esp_err_t emac_enc28j60_set_mediator(esp_eth_mac_t *mac, esp_eth_mediator_t *eth) +{ + esp_err_t ret = ESP_OK; + MAC_CHECK(eth, "can't set mac's mediator to null", out, ESP_ERR_INVALID_ARG); + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + emac->eth = eth; +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Verify chip revision ID +*/ +static esp_err_t enc28j60_verify_id(emac_enc28j60_t *emac) +{ + esp_err_t ret = ESP_OK; + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_EREVID, (uint8_t *)&emac->revision) == ESP_OK, + "read EREVID failed", out, ESP_FAIL); + ESP_LOGI(TAG, "revision: %d", emac->revision); + MAC_CHECK(emac->revision >= ENC28J60_REV_B1 + && emac->revision <= ENC28J60_REV_B7, "wrong chip ID", out, ESP_ERR_INVALID_VERSION); +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Write mac address to internal registers +*/ +static esp_err_t enc28j60_set_mac_addr(emac_enc28j60_t *emac) +{ + esp_err_t ret = ESP_OK; + + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAADR6, emac->addr[5]) == ESP_OK, + "write MAADR6 failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAADR5, emac->addr[4]) == ESP_OK, + "write MAADR5 failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAADR4, emac->addr[3]) == ESP_OK, + "write MAADR4 failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAADR3, emac->addr[2]) == ESP_OK, + "write MAADR3 failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAADR2, emac->addr[1]) == ESP_OK, + "write MAADR2 failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAADR1, emac->addr[0]) == ESP_OK, + "write MAADR1 failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Clear multicast hash table +*/ +static esp_err_t enc28j60_clear_multicast_table(emac_enc28j60_t *emac) +{ + esp_err_t ret = ESP_OK; + + for (int i = 0; i < 7; i++) + { + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_EHT0 + i, 0x00) == ESP_OK, + "write ENC28J60_EHT%d failed", out, ESP_FAIL, i); + } + +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Default setup for ENC28J60 internal registers +*/ +static esp_err_t enc28j60_setup_default(emac_enc28j60_t *emac) +{ + esp_err_t ret = ESP_OK; + + // set up receive buffer start + end + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXSTL, ENC28J60_BUF_RX_START & 0xFF) == ESP_OK, + "write ERXSTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXSTH, (ENC28J60_BUF_RX_START & 0xFF00) >> 8) == ESP_OK, + "write ERXSTH failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXNDL, ENC28J60_BUF_RX_END & 0xFF) == ESP_OK, + "write ERXNDL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXNDH, (ENC28J60_BUF_RX_END & 0xFF00) >> 8) == ESP_OK, + "write ERXNDH failed", out, ESP_FAIL); + uint32_t erxrdpt = enc28j60_next_ptr_align_odd(ENC28J60_BUF_RX_START, ENC28J60_BUF_RX_START, ENC28J60_BUF_RX_END); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXRDPTL, erxrdpt & 0xFF) == ESP_OK, + "write ERXRDPTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXRDPTH, (erxrdpt & 0xFF00) >> 8) == ESP_OK, + "write ERXRDPTH failed", out, ESP_FAIL); + + // set up transmit buffer start + end + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ETXSTL, ENC28J60_BUF_TX_START & 0xFF) == ESP_OK, + "write ETXSTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ETXSTH, (ENC28J60_BUF_TX_START & 0xFF00) >> 8) == ESP_OK, + "write ETXSTH failed", out, ESP_FAIL); + + // set up default filter mode: (unicast OR broadcast) AND crc valid + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXFCON, ERXFCON_UCEN | ERXFCON_CRCEN | ERXFCON_BCEN) == ESP_OK, + "write ERXFCON failed", out, ESP_FAIL); + + // enable MAC receive, enable pause control frame on Tx and Rx path + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MACON1, MACON1_MARXEN | MACON1_RXPAUS | MACON1_TXPAUS) == ESP_OK, + "write MACON1 failed", out, ESP_FAIL); + // enable automatic padding, append CRC, check frame length, half duplex by default (can update at runtime) + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MACON3, MACON3_PADCFG0 | MACON3_TXCRCEN | MACON3_FRMLNEN) == ESP_OK, + "write MACON3 failed", out, ESP_FAIL); + // enable defer transmission (effective only in half duplex) + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MACON4, MACON4_DEFER) == ESP_OK, + "write MACON4 failed", out, ESP_FAIL); + // set inter-frame gap (back-to-back) + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MABBIPG, 0x12) == ESP_OK, + "write MABBIPG failed", out, ESP_FAIL); + // set inter-frame gap (non-back-to-back) + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAIPGL, 0x12) == ESP_OK, + "write MAIPGL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MAIPGH, 0x0C) == ESP_OK, + "write MAIPGH failed", out, ESP_FAIL); + +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Start enc28j60: enable interrupt and start receive +*/ +static esp_err_t emac_enc28j60_start(esp_eth_mac_t *mac) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + /* enable interrupt */ + MAC_CHECK(enc28j60_do_bitwise_clr(emac, ENC28J60_EIR, 0xFF) == ESP_OK, + "clear EIR failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_bitwise_set(emac, ENC28J60_EIE, EIE_PKTIE | EIE_INTIE | EIE_TXERIE) == ESP_OK, + "set EIE.[PKTIE|INTIE] failed", out, ESP_FAIL); + /* enable rx logic */ + MAC_CHECK(enc28j60_do_bitwise_set(emac, ENC28J60_ECON1, ECON1_RXEN) == ESP_OK, + "set ECON1.RXEN failed", out, ESP_FAIL); + + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERDPTL, 0x00) == ESP_OK, + "write ERDPTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERDPTH, 0x00) == ESP_OK, + "write ERDPTH failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Stop enc28j60: disable interrupt and stop receiving packets +*/ +static esp_err_t emac_enc28j60_stop(esp_eth_mac_t *mac) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + /* disable interrupt */ + MAC_CHECK(enc28j60_do_bitwise_clr(emac, ENC28J60_EIE, 0xFF) == ESP_OK, + "clear EIE failed", out, ESP_FAIL); + /* disable rx */ + MAC_CHECK(enc28j60_do_bitwise_clr(emac, ENC28J60_ECON1, ECON1_RXEN) == ESP_OK, + "clear ECON1.RXEN failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_set_addr(esp_eth_mac_t *mac, uint8_t *addr) +{ + esp_err_t ret = ESP_OK; + MAC_CHECK(addr, "can't set mac addr to null", out, ESP_ERR_INVALID_ARG); + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + memcpy(emac->addr, addr, 6); + MAC_CHECK(enc28j60_set_mac_addr(emac) == ESP_OK, "set mac address failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_get_addr(esp_eth_mac_t *mac, uint8_t *addr) +{ + esp_err_t ret = ESP_OK; + MAC_CHECK(addr, "can't set mac addr to null", out, ESP_ERR_INVALID_ARG); + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + memcpy(addr, emac->addr, 6); +out: + return ret; +} + +//////////////////////////////////////// + +static inline esp_err_t emac_enc28j60_get_tsv(emac_enc28j60_t *emac, enc28j60_tsv_t *tsv) +{ + return enc28j60_read_packet(emac, emac->last_tsv_addr, (uint8_t *)tsv, ENC28J60_TSV_SIZE); +} + +//////////////////////////////////////// + +static void enc28j60_isr_handler(void *arg) +{ + emac_enc28j60_t *emac = (emac_enc28j60_t *)arg; + BaseType_t high_task_wakeup = pdFALSE; + /* notify enc28j60 task */ + vTaskNotifyGiveFromISR(emac->rx_task_hdl, &high_task_wakeup); + + if (high_task_wakeup != pdFALSE) + { + portYIELD_FROM_ISR(); + } +} + +//////////////////////////////////////// + +/** + @brief Main ENC28J60 Task. Mainly used for Rx processing. However, it also handles other interrupts. + +*/ +static void emac_enc28j60_task(void *arg) +{ + emac_enc28j60_t *emac = (emac_enc28j60_t *)arg; + uint8_t status = 0; + uint8_t mask = 0; + uint8_t *buffer = NULL; + uint32_t length = 0; + + while (1) + { +loop_start: + + // block until some task notifies me or check the gpio by myself + if (ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(1000)) == 0 && // if no notification ... + gpio_get_level(emac->int_gpio_num) != 0) // ...and no interrupt asserted + { + continue; // -> just continue to check again + } + + // the host controller should clear the global enable bit for the interrupt pin before servicing the interrupt + MAC_CHECK_NO_RET(enc28j60_do_bitwise_clr(emac, ENC28J60_EIR, EIE_INTIE) == ESP_OK, + "clear EIE_INTIE failed", loop_start); + // read interrupt status + MAC_CHECK_NO_RET(enc28j60_do_register_read(emac, true, ENC28J60_EIR, &status) == ESP_OK, + "read EIR failed", loop_end); + MAC_CHECK_NO_RET(enc28j60_do_register_read(emac, true, ENC28J60_EIE, &mask) == ESP_OK, + "read EIE failed", loop_end); + status &= mask; + + // When source of interrupt is unknown, try to check if there is packet waiting (Errata #6 workaround) + if (status == 0) + { + uint8_t pk_counter; + MAC_CHECK_NO_RET(enc28j60_register_read(emac, ENC28J60_EPKTCNT, &pk_counter) == ESP_OK, + "read EPKTCNT failed", loop_end); + + if (pk_counter > 0) + { + status = EIR_PKTIF; + } + else + { + goto loop_end; + } + } + + // packet received + if (status & EIR_PKTIF) + { + do + { + length = ETH_MAX_PACKET_SIZE; + buffer = heap_caps_malloc(length, MALLOC_CAP_DMA); + + if (!buffer) + { + ESP_LOGE(TAG, "no mem for receive buffer"); + } + else if (emac->parent.receive(&emac->parent, buffer, &length) == ESP_OK) + { + /* pass the buffer to stack (e.g. TCP/IP layer) */ + if (length) + { + emac->eth->stack_input(emac->eth, buffer, length); + } + else + { + free(buffer); + } + } + else + { + free(buffer); + } + } while (emac->packets_remain); + } + + // transmit error + if (status & EIR_TXERIF) + { + // Errata #12/#13 workaround - reset Tx state machine + MAC_CHECK_NO_RET(enc28j60_do_bitwise_set(emac, ENC28J60_ECON1, ECON1_TXRST) == ESP_OK, + "set TXRST failed", loop_end); + MAC_CHECK_NO_RET(enc28j60_do_bitwise_clr(emac, ENC28J60_ECON1, ECON1_TXRST) == ESP_OK, + "clear TXRST failed", loop_end); + + // Clear Tx Error Interrupt Flag + MAC_CHECK_NO_RET(enc28j60_do_bitwise_clr(emac, ENC28J60_EIR, EIR_TXERIF) == ESP_OK, + "clear TXERIF failed", loop_end); + + // Errata #13 workaround (applicable only to B5 and B7 revisions) + if (emac->revision == ENC28J60_REV_B5 || emac->revision == ENC28J60_REV_B7) + { + __attribute__((aligned(4))) enc28j60_tsv_t tx_status; // SPI driver needs the rx buffer 4 byte align + MAC_CHECK_NO_RET(emac_enc28j60_get_tsv(emac, &tx_status) == ESP_OK, + "get Tx Status Vector failed", loop_end); + + // Try to retransmit when late collision is indicated + if (tx_status.late_collision) + { + // Clear Tx Interrupt status Flag (it was set along with the error) + MAC_CHECK_NO_RET(enc28j60_do_bitwise_clr(emac, ENC28J60_EIR, EIR_TXIF) == ESP_OK, + "clear TXIF failed", loop_end); + // Enable global interrupt flag and try to retransmit + MAC_CHECK_NO_RET(enc28j60_do_bitwise_set(emac, ENC28J60_EIE, EIE_INTIE) == ESP_OK, + "set INTIE failed", loop_end); + MAC_CHECK_NO_RET(enc28j60_do_bitwise_set(emac, ENC28J60_ECON1, ECON1_TXRTS) == ESP_OK, + "set TXRTS failed", loop_end); + continue; // no need to handle Tx ready interrupt nor to enable global interrupt at this point + } + } + } + + // transmit ready + if (status & EIR_TXIF) + { + MAC_CHECK_NO_RET(enc28j60_do_bitwise_clr(emac, ENC28J60_EIR, EIR_TXIF) == ESP_OK, + "clear TXIF failed", loop_end); + MAC_CHECK_NO_RET(enc28j60_do_bitwise_clr(emac, ENC28J60_EIE, EIE_TXIE) == ESP_OK, + "clear TXIE failed", loop_end); + + xSemaphoreGive(emac->tx_ready_sem); + } + +loop_end: + // restore global enable interrupt bit + MAC_CHECK_NO_RET(enc28j60_do_bitwise_set(emac, ENC28J60_EIE, EIE_INTIE) == ESP_OK, + "clear INTIE failed", loop_start); + // Note: Interrupt flag PKTIF is cleared when PKTDEC is set (in receive function) + } + + vTaskDelete(NULL); +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_set_link(esp_eth_mac_t *mac, eth_link_t link) +{ + esp_err_t ret = ESP_OK; + + switch (link) + { + case ETH_LINK_UP: + MAC_CHECK(mac->start(mac) == ESP_OK, "enc28j60 start failed", out, ESP_FAIL); + break; + + case ETH_LINK_DOWN: + MAC_CHECK(mac->stop(mac) == ESP_OK, "enc28j60 stop failed", out, ESP_FAIL); + break; + + default: + MAC_CHECK(false, "unknown link status", out, ESP_ERR_INVALID_ARG); + break; + } + +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_set_speed(esp_eth_mac_t *mac, eth_speed_t speed) +{ + esp_err_t ret = ESP_OK; + + switch (speed) + { + case ETH_SPEED_10M: + ESP_LOGI(TAG, "working in 10Mbps"); + break; + + default: + MAC_CHECK(false, "100Mbps unsupported", out, ESP_ERR_NOT_SUPPORTED); + break; + } + +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_set_duplex(esp_eth_mac_t *mac, eth_duplex_t duplex) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + uint8_t mac3 = 0; + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_MACON3, &mac3) == ESP_OK, + "read MACON3 failed", out, ESP_FAIL); + + switch (duplex) + { + case ETH_DUPLEX_HALF: + mac3 &= ~MACON3_FULDPX; + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MABBIPG, 0x12) == ESP_OK, + "write MABBIPG failed", out, ESP_FAIL); + ESP_LOGI(TAG, "working in half duplex"); + break; + + case ETH_DUPLEX_FULL: + mac3 |= MACON3_FULDPX; + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MABBIPG, 0x15) == ESP_OK, + "write MABBIPG failed", out, ESP_FAIL); + ESP_LOGI(TAG, "working in full duplex"); + break; + + default: + MAC_CHECK(false, "unknown duplex", out, ESP_ERR_INVALID_ARG); + break; + } + + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_MACON3, mac3) == ESP_OK, + "write MACON3 failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_set_promiscuous(esp_eth_mac_t *mac, bool enable) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + + if (enable) + { + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXFCON, 0x00) == ESP_OK, + "write ERXFCON failed", out, ESP_FAIL); + } + +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint32_t length) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + uint8_t econ1 = 0; + + /* ENC28J60 may be a bottle neck in Eth communication. Hence we need to check if it is ready. */ + if (xSemaphoreTake(emac->tx_ready_sem, pdMS_TO_TICKS(ENC28J60_TX_READY_TIMEOUT_MS)) == pdFALSE) + { + ESP_LOGW(TAG, "tx_ready_sem expired"); + } + + MAC_CHECK(enc28j60_do_register_read(emac, true, ENC28J60_ECON1, &econ1) == ESP_OK, + "read ECON1 failed", out, ESP_FAIL); + MAC_CHECK(!(econ1 & ECON1_TXRTS), "last transmit still in progress", out, ESP_ERR_INVALID_STATE); + + /* Set the write pointer to start of transmit buffer area */ + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_EWRPTL, ENC28J60_BUF_TX_START & 0xFF) == ESP_OK, + "write EWRPTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_EWRPTH, (ENC28J60_BUF_TX_START & 0xFF00) >> 8) == ESP_OK, + "write EWRPTH failed", out, ESP_FAIL); + + /* Set the end pointer to correspond to the packet size given */ + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ETXNDL, (ENC28J60_BUF_TX_START + length) & 0xFF) == ESP_OK, + "write ETXNDL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ETXNDH, ((ENC28J60_BUF_TX_START + length) & 0xFF00) >> 8) == ESP_OK, + "write ETXNDH failed", out, ESP_FAIL); + + /* copy data to tx memory */ + uint8_t per_pkt_control = 0; // MACON3 will be used to determine how the packet will be transmitted + MAC_CHECK(enc28j60_do_memory_write(emac, &per_pkt_control, 1) == ESP_OK, + "write packet control byte failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_memory_write(emac, buf, length) == ESP_OK, + "buffer memory write failed", out, ESP_FAIL); + emac->last_tsv_addr = ENC28J60_BUF_TX_START + length + 1; + + /* enable Tx Interrupt to indicate next Tx ready state */ + MAC_CHECK(enc28j60_do_bitwise_clr(emac, ENC28J60_EIR, EIR_TXIF) == ESP_OK, + "set EIR_TXIF failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_do_bitwise_set(emac, ENC28J60_EIE, EIE_TXIE) == ESP_OK, + "set EIE_TXIE failed", out, ESP_FAIL); + + /* issue tx polling command */ + MAC_CHECK(enc28j60_do_bitwise_set(emac, ENC28J60_ECON1, ECON1_TXRTS) == ESP_OK, + "set ECON1.TXRTS failed", out, ESP_FAIL); +out: + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_receive(esp_eth_mac_t *mac, uint8_t *buf, uint32_t *length) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + uint8_t pk_counter = 0; + uint16_t rx_len = 0; + uint32_t next_packet_addr = 0; + __attribute__((aligned(4))) enc28j60_rx_header_t header; // SPI driver needs the rx buffer 4 byte align + + // read packet header + MAC_CHECK(enc28j60_read_packet(emac, emac->next_packet_ptr, (uint8_t *)&header, sizeof(header)) == ESP_OK, + "read header failed", out, ESP_FAIL); + + // get packets' length, address + rx_len = header.length_low + (header.length_high << 8); + next_packet_addr = header.next_packet_low + (header.next_packet_high << 8); + + // read packet content + MAC_CHECK(enc28j60_read_packet(emac, enc28j60_rx_packet_start(emac->next_packet_ptr, ENC28J60_RSV_SIZE), buf, + rx_len) == ESP_OK, + "read packet content failed", out, ESP_FAIL); + + // free receive buffer space + uint32_t erxrdpt = enc28j60_next_ptr_align_odd(next_packet_addr, ENC28J60_BUF_RX_START, ENC28J60_BUF_RX_END); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXRDPTL, (erxrdpt & 0xFF)) == ESP_OK, + "write ERXRDPTL failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_write(emac, ENC28J60_ERXRDPTH, (erxrdpt & 0xFF00) >> 8) == ESP_OK, + "write ERXRDPTH failed", out, ESP_FAIL); + emac->next_packet_ptr = next_packet_addr; + + MAC_CHECK(enc28j60_do_bitwise_set(emac, ENC28J60_ECON2, ECON2_PKTDEC) == ESP_OK, + "set ECON2.PKTDEC failed", out, ESP_FAIL); + MAC_CHECK(enc28j60_register_read(emac, ENC28J60_EPKTCNT, &pk_counter) == ESP_OK, + "read EPKTCNT failed", out, ESP_FAIL); + + *length = rx_len - 4; // substract the CRC length + emac->packets_remain = pk_counter > 0; +out: + return ret; +} + +//////////////////////////////////////// + +/** + @brief Get chip info +*/ +eth_enc28j60_rev_t emac_enc28j60_get_chip_info(esp_eth_mac_t *mac) +{ + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + return emac->revision; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_init(esp_eth_mac_t *mac) +{ + esp_err_t ret = ESP_OK; + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + esp_eth_mediator_t *eth = emac->eth; + + /* init gpio used for reporting enc28j60 interrupt */ + gpio_reset_pin(emac->int_gpio_num); + gpio_set_direction(emac->int_gpio_num, GPIO_MODE_INPUT); + gpio_set_pull_mode(emac->int_gpio_num, GPIO_PULLUP_ONLY); + gpio_set_intr_type(emac->int_gpio_num, GPIO_INTR_NEGEDGE); + gpio_intr_enable(emac->int_gpio_num); + gpio_isr_handler_add(emac->int_gpio_num, enc28j60_isr_handler, emac); + MAC_CHECK(eth->on_state_changed(eth, ETH_STATE_LLINIT, NULL) == ESP_OK, + "lowlevel init failed", out, ESP_FAIL); + + /* reset enc28j60 */ + MAC_CHECK(enc28j60_do_reset(emac) == ESP_OK, "reset enc28j60 failed", out, ESP_FAIL); + /* verify chip id */ + MAC_CHECK(enc28j60_verify_id(emac) == ESP_OK, "vefiry chip ID failed", out, ESP_FAIL); + /* default setup of internal registers */ + MAC_CHECK(enc28j60_setup_default(emac) == ESP_OK, "enc28j60 default setup failed", out, ESP_FAIL); + /* clear multicast hash table */ + MAC_CHECK(enc28j60_clear_multicast_table(emac) == ESP_OK, "clear multicast table failed", out, ESP_FAIL); + + return ESP_OK; +out: + gpio_isr_handler_remove(emac->int_gpio_num); + gpio_reset_pin(emac->int_gpio_num); + eth->on_state_changed(eth, ETH_STATE_DEINIT, NULL); + return ret; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_deinit(esp_eth_mac_t *mac) +{ + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + esp_eth_mediator_t *eth = emac->eth; + mac->stop(mac); + gpio_isr_handler_remove(emac->int_gpio_num); + gpio_reset_pin(emac->int_gpio_num); + eth->on_state_changed(eth, ETH_STATE_DEINIT, NULL); + return ESP_OK; +} + +//////////////////////////////////////// + +static esp_err_t emac_enc28j60_del(esp_eth_mac_t *mac) +{ + emac_enc28j60_t *emac = __containerof(mac, emac_enc28j60_t, parent); + vTaskDelete(emac->rx_task_hdl); + vSemaphoreDelete(emac->spi_lock); + vSemaphoreDelete(emac->reg_trans_lock); + vSemaphoreDelete(emac->tx_ready_sem); + free(emac); + return ESP_OK; +} + +//////////////////////////////////////// + +esp_eth_mac_t *esp_eth_mac_new_enc28j60(const eth_enc28j60_config_t *enc28j60_config, + const eth_mac_config_t *mac_config) +{ + esp_eth_mac_t *ret = NULL; + emac_enc28j60_t *emac = NULL; + MAC_CHECK(enc28j60_config, "can't set enc28j60 specific config to null", err, NULL); + MAC_CHECK(mac_config, "can't set mac config to null", err, NULL); + emac = calloc(1, sizeof(emac_enc28j60_t)); + MAC_CHECK(emac, "calloc emac failed", err, NULL); + /* enc28j60 driver is interrupt driven */ + MAC_CHECK(enc28j60_config->int_gpio_num >= 0, "error interrupt gpio number", err, NULL); + emac->last_bank = 0xFF; + emac->next_packet_ptr = ENC28J60_BUF_RX_START; + /* bind methods and attributes */ + emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; + emac->int_gpio_num = enc28j60_config->int_gpio_num; + emac->spi_hdl = enc28j60_config->spi_hdl; + emac->parent.set_mediator = emac_enc28j60_set_mediator; + emac->parent.init = emac_enc28j60_init; + emac->parent.deinit = emac_enc28j60_deinit; + emac->parent.start = emac_enc28j60_start; + emac->parent.stop = emac_enc28j60_stop; + emac->parent.del = emac_enc28j60_del; + emac->parent.write_phy_reg = emac_enc28j60_write_phy_reg; + emac->parent.read_phy_reg = emac_enc28j60_read_phy_reg; + emac->parent.set_addr = emac_enc28j60_set_addr; + emac->parent.get_addr = emac_enc28j60_get_addr; + emac->parent.set_speed = emac_enc28j60_set_speed; + emac->parent.set_duplex = emac_enc28j60_set_duplex; + emac->parent.set_link = emac_enc28j60_set_link; + emac->parent.set_promiscuous = emac_enc28j60_set_promiscuous; + emac->parent.transmit = emac_enc28j60_transmit; + emac->parent.receive = emac_enc28j60_receive; + /* create mutex */ + emac->spi_lock = xSemaphoreCreateMutex(); + MAC_CHECK(emac->spi_lock, "create spi lock failed", err, NULL); + emac->reg_trans_lock = xSemaphoreCreateMutex(); + MAC_CHECK(emac->reg_trans_lock, "create register transaction lock failed", err, NULL); + emac->tx_ready_sem = xSemaphoreCreateBinary(); + MAC_CHECK(emac->tx_ready_sem, "create pkt transmit ready semaphore failed", err, NULL); + xSemaphoreGive(emac->tx_ready_sem); // ensures the first transmit is performed without waiting + /* create enc28j60 task */ + BaseType_t core_num = tskNO_AFFINITY; + + if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) + { + core_num = cpu_hal_get_core_id(); + } + + BaseType_t xReturned = xTaskCreatePinnedToCore(emac_enc28j60_task, "enc28j60_tsk", mac_config->rx_task_stack_size, emac, + mac_config->rx_task_prio, &emac->rx_task_hdl, core_num); + MAC_CHECK(xReturned == pdPASS, "create enc28j60 task failed", err, NULL); + + return &(emac->parent); + +err: + + if (emac) + { + if (emac->rx_task_hdl) + { + vTaskDelete(emac->rx_task_hdl); + } + + if (emac->spi_lock) + { + vSemaphoreDelete(emac->spi_lock); + } + + if (emac->reg_trans_lock) + { + vSemaphoreDelete(emac->reg_trans_lock); + } + + if (emac->tx_ready_sem) + { + vSemaphoreDelete(emac->tx_ready_sem); + } + + free(emac); + } + + return ret; +} diff --git a/src/enc28j60/extmod/esp_eth_phy_enc28j60.c b/src/enc28j60/extmod/esp_eth_phy_enc28j60.c new file mode 100644 index 0000000..6d6402f --- /dev/null +++ b/src/enc28j60/extmod/esp_eth_phy_enc28j60.c @@ -0,0 +1,390 @@ +// Copyright 2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include +#include +#include +#include "esp_log.h" +#include "esp_eth.h" +#include "eth_phy_regs_struct.h" +#include "esp_eth_enc28j60.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "driver/gpio.h" + +static const char *TAG = "enc28j60"; +#define PHY_CHECK(a, str, goto_tag, ...) \ + do \ + { \ + if (!(a)) \ + { \ + ESP_LOGE(TAG, "%s(%d): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + goto goto_tag; \ + } \ + } while (0) + +/***************Vendor Specific Register***************/ + +/** + @brief PHCON2(PHY Control Register 2) + +*/ +typedef union +{ + struct + { + uint32_t reserved_7_0 : 8; // Reserved + uint32_t pdpxmd : 1; // PHY Duplex Mode bit + uint32_t reserved_10_9: 2; // Reserved + uint32_t ppwrsv: 1; // PHY Power-Down bit + uint32_t reserved_13_12: 2; // Reserved + uint32_t ploopbk: 1; // PHY Loopback bit + uint32_t prst: 1; // PHY Software Reset bit + }; + uint32_t val; +} phcon1_reg_t; +#define ETH_PHY_PHCON1_REG_ADDR (0x00) + +/** + @brief PHCON2(PHY Control Register 2) + +*/ +typedef union +{ + struct + { + uint32_t reserved_7_0 : 8; // Reserved + uint32_t hdldis : 1; // Half-Duplex Loopback Disable + uint32_t reserved_9: 1; // Reserved + uint32_t jabber: 1; // Disable Jabber Correction + uint32_t reserved_12_11: 2; // Reserved + uint32_t txdis: 1; // Disable Twist-Pair Transmitter + uint32_t frclnk: 1; // Force Linkup + uint32_t reserved_15: 1; //Reserved + }; + uint32_t val; +} phcon2_reg_t; +#define ETH_PHY_PHCON2_REG_ADDR (0x10) + +/** + @brief PHSTAT2(PHY Status Register 2) + +*/ +typedef union +{ + struct + { + uint32_t reserved_4_0 : 5; // Reserved + uint32_t plrity : 1; // Polarity Status + uint32_t reserved_8_6 : 3; // Reserved + uint32_t dpxstat : 1; // PHY Duplex Status + uint32_t lstat : 1; // PHY Link Status (non-latching) + uint32_t colstat : 1; // PHY Collision Status + uint32_t rxstat : 1; // PHY Receive Status + uint32_t txstat : 1; // PHY Transmit Status + uint32_t reserved_15_14 : 2; // Reserved + }; + uint32_t val; +} phstat2_reg_t; +#define ETH_PHY_PHSTAT2_REG_ADDR (0x11) + +typedef struct +{ + esp_eth_phy_t parent; + esp_eth_mediator_t *eth; + uint32_t addr; + uint32_t reset_timeout_ms; + eth_link_t link_status; + int reset_gpio_num; +} phy_enc28j60_t; + +static esp_err_t enc28j60_update_link_duplex_speed(phy_enc28j60_t *enc28j60) +{ + esp_eth_mediator_t *eth = enc28j60->eth; + eth_speed_t speed = ETH_SPEED_10M; // enc28j60 speed is fixed to 10Mbps + eth_duplex_t duplex = ETH_DUPLEX_HALF; + phstat2_reg_t phstat; + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_PHSTAT2_REG_ADDR, &(phstat.val)) == ESP_OK, + "read PHSTAT2 failed", err); + eth_link_t link = phstat.lstat ? ETH_LINK_UP : ETH_LINK_DOWN; + + /* check if link status changed */ + if (enc28j60->link_status != link) + { + /* when link up, read result */ + if (link == ETH_LINK_UP) + { + if (phstat.dpxstat) + { + duplex = ETH_DUPLEX_FULL; + } + else + { + duplex = ETH_DUPLEX_HALF; + } + + PHY_CHECK(eth->on_state_changed(eth, ETH_STATE_SPEED, (void *)speed) == ESP_OK, + "change speed failed", err); + PHY_CHECK(eth->on_state_changed(eth, ETH_STATE_DUPLEX, (void *)duplex) == ESP_OK, + "change duplex failed", err); + } + + PHY_CHECK(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)link) == ESP_OK, + "change link failed", err); + enc28j60->link_status = link; + } + + return ESP_OK; +err: + return ESP_FAIL; +} + +static esp_err_t enc28j60_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) +{ + PHY_CHECK(eth, "can't set mediator for enc28j60 to null", err); + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + enc28j60->eth = eth; + return ESP_OK; +err: + return ESP_ERR_INVALID_ARG; +} + +static esp_err_t enc28j60_get_link(esp_eth_phy_t *phy) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + /* Updata information about link, speed, duplex */ + PHY_CHECK(enc28j60_update_link_duplex_speed(enc28j60) == ESP_OK, "update link duplex speed failed", err); + return ESP_OK; +err: + return ESP_FAIL; +} + +static esp_err_t enc28j60_reset(esp_eth_phy_t *phy) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + enc28j60->link_status = ETH_LINK_DOWN; + esp_eth_mediator_t *eth = enc28j60->eth; + bmcr_reg_t bmcr = {.reset = 1}; + PHY_CHECK(eth->phy_reg_write(eth, enc28j60->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val) == ESP_OK, + "write BMCR failed", err); + /* Wait for reset complete */ + uint32_t to = 0; + + for (to = 0; to < enc28j60->reset_timeout_ms / 10; to++) + { + vTaskDelay(pdMS_TO_TICKS(10)); + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)) == ESP_OK, + "read BMCR failed", err); + + if (!bmcr.reset) + { + break; + } + } + + PHY_CHECK(to < enc28j60->reset_timeout_ms / 10, "PHY reset timeout", err); + return ESP_OK; +err: + return ESP_FAIL; +} + +static esp_err_t enc28j60_reset_hw(esp_eth_phy_t *phy) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + + // set reset_gpio_num minus zero can skip hardware reset phy chip + if (enc28j60->reset_gpio_num >= 0) + { + gpio_reset_pin(enc28j60->reset_gpio_num); + gpio_set_direction(enc28j60->reset_gpio_num, GPIO_MODE_OUTPUT); + gpio_set_level(enc28j60->reset_gpio_num, 0); + gpio_set_level(enc28j60->reset_gpio_num, 1); + } + + return ESP_OK; +} + +static esp_err_t enc28j60_negotiate(esp_eth_phy_t *phy) +{ + /** + ENC28J60 does not support automatic duplex negotiation. + If it is connected to an automatic duplex negotiation enabled network switch, + ENC28J60 will be detected as a half-duplex device. + To communicate in Full-Duplex mode, ENC28J60 and the remote node + must be manually configured for full-duplex operation. + */ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + /* Updata information about link, speed, duplex */ + PHY_CHECK(enc28j60_update_link_duplex_speed(enc28j60) == ESP_OK, "update link duplex speed failed", err); + return ESP_OK; +err: + return ESP_FAIL; +} + +esp_err_t enc28j60_set_phy_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + esp_eth_mediator_t *eth = enc28j60->eth; + phcon1_reg_t phcon1; + + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, 0, &phcon1.val) == ESP_OK, + "read PHCON1 failed", err); + + switch (duplex) + { + case ETH_DUPLEX_HALF: + phcon1.pdpxmd = 0; + break; + + case ETH_DUPLEX_FULL: + phcon1.pdpxmd = 1; + break; + + default: + PHY_CHECK(false, "unknown duplex", err); + break; + } + + PHY_CHECK(eth->phy_reg_write(eth, enc28j60->addr, 0, phcon1.val) == ESP_OK, + "write PHCON1 failed", err); + + PHY_CHECK(enc28j60_update_link_duplex_speed(enc28j60) == ESP_OK, "update link duplex speed failed", err); + return ESP_OK; +err: + return ESP_FAIL; +} + +static esp_err_t enc28j60_pwrctl(esp_eth_phy_t *phy, bool enable) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + esp_eth_mediator_t *eth = enc28j60->eth; + bmcr_reg_t bmcr; + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)) == ESP_OK, + "read BMCR failed", err); + + if (!enable) + { + /* Enable IEEE Power Down Mode */ + bmcr.power_down = 1; + } + else + { + /* Disable IEEE Power Down Mode */ + bmcr.power_down = 0; + } + + PHY_CHECK(eth->phy_reg_write(eth, enc28j60->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val) == ESP_OK, + "write BMCR failed", err); + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)) == ESP_OK, + "read BMCR failed", err); + + if (!enable) + { + PHY_CHECK(bmcr.power_down == 1, "power down failed", err); + } + else + { + PHY_CHECK(bmcr.power_down == 0, "power up failed", err); + } + + return ESP_OK; +err: + return ESP_FAIL; +} + +static esp_err_t enc28j60_set_addr(esp_eth_phy_t *phy, uint32_t addr) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + enc28j60->addr = addr; + return ESP_OK; +} + +static esp_err_t enc28j60_get_addr(esp_eth_phy_t *phy, uint32_t *addr) +{ + PHY_CHECK(addr, "addr can't be null", err); + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + *addr = enc28j60->addr; + return ESP_OK; +err: + return ESP_ERR_INVALID_ARG; +} + +static esp_err_t enc28j60_del(esp_eth_phy_t *phy) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + free(enc28j60); + return ESP_OK; +} + +static esp_err_t enc28j60_init(esp_eth_phy_t *phy) +{ + phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent); + esp_eth_mediator_t *eth = enc28j60->eth; + /* Power on Ethernet PHY */ + PHY_CHECK(enc28j60_pwrctl(phy, true) == ESP_OK, "power control failed", err); + /* Reset Ethernet PHY */ + PHY_CHECK(enc28j60_reset(phy) == ESP_OK, "reset failed", err); + /* Check PHY ID */ + phyidr1_reg_t id1; + phyidr2_reg_t id2; + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)) == ESP_OK, + "read ID1 failed", err); + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)) == ESP_OK, + "read ID2 failed", err); + PHY_CHECK(id1.oui_msb == 0x0083 && id2.oui_lsb == 0x05 && id2.vendor_model == 0x00, + "wrong chip ID", err); + /* Disable half duplex loopback */ + phcon2_reg_t phcon2; + PHY_CHECK(eth->phy_reg_read(eth, enc28j60->addr, ETH_PHY_PHCON2_REG_ADDR, &(phcon2.val)) == ESP_OK, + "read PHCON2 failed", err); + phcon2.hdldis = 1; + PHY_CHECK(eth->phy_reg_write(eth, enc28j60->addr, ETH_PHY_PHCON2_REG_ADDR, phcon2.val) == ESP_OK, + "write PHCON2 failed", err); + return ESP_OK; +err: + return ESP_FAIL; +} + +static esp_err_t enc28j60_deinit(esp_eth_phy_t *phy) +{ + /* Power off Ethernet PHY */ + PHY_CHECK(enc28j60_pwrctl(phy, false) == ESP_OK, "power off Ethernet PHY failed", err); + return ESP_OK; +err: + return ESP_FAIL; +} + +esp_eth_phy_t *esp_eth_phy_new_enc28j60(const eth_phy_config_t *config) +{ + PHY_CHECK(config, "can't set phy config to null", err); + phy_enc28j60_t *enc28j60 = calloc(1, sizeof(phy_enc28j60_t)); + PHY_CHECK(enc28j60, "calloc enc28j60 failed", err); + enc28j60->addr = config->phy_addr; // although PHY addr is meaningless to ENC28J60 + enc28j60->reset_timeout_ms = config->reset_timeout_ms; + enc28j60->reset_gpio_num = config->reset_gpio_num; + enc28j60->link_status = ETH_LINK_DOWN; + enc28j60->parent.reset = enc28j60_reset; + enc28j60->parent.reset_hw = enc28j60_reset_hw; + enc28j60->parent.init = enc28j60_init; + enc28j60->parent.deinit = enc28j60_deinit; + enc28j60->parent.set_mediator = enc28j60_set_mediator; + enc28j60->parent.negotiate = enc28j60_negotiate; + enc28j60->parent.get_link = enc28j60_get_link; + enc28j60->parent.pwrctl = enc28j60_pwrctl; + enc28j60->parent.get_addr = enc28j60_get_addr; + enc28j60->parent.set_addr = enc28j60_set_addr; + enc28j60->parent.del = enc28j60_del; + return &(enc28j60->parent); +err: + return NULL; +} diff --git a/src/enc28j60/extmod/esp_eth_spi_enc28j60.c b/src/enc28j60/extmod/esp_eth_spi_enc28j60.c new file mode 100644 index 0000000..7f208f1 --- /dev/null +++ b/src/enc28j60/extmod/esp_eth_spi_enc28j60.c @@ -0,0 +1,69 @@ + +#include +#include +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_netif.h" +#include "esp_eth.h" +#include "esp_event.h" +#include "driver/gpio.h" +#include "esp_eth_enc28j60.h" +#include "driver/spi_master.h" + +//////////////////////////////////////// + +esp_eth_mac_t* enc28j60_new_mac( spi_device_handle_t *spi_handle, int INT_GPIO ) +{ + eth_enc28j60_config_t enc28j60_config = ETH_ENC28J60_DEFAULT_CONFIG( *spi_handle ); + enc28j60_config.int_gpio_num = INT_GPIO; + + eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); + mac_config.smi_mdc_gpio_num = -1; // ENC28J60 doesn't have SMI interface + mac_config.smi_mdio_gpio_num = -1; + // mac_config.rx_task_prio = 1; + return esp_eth_mac_new_enc28j60( &enc28j60_config, &mac_config ); +} + +//////////////////////////////////////// + +esp_eth_mac_t* enc28j60_begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, + int SPI_HOST) +{ + if (ESP_OK != gpio_install_isr_service(0)) + return NULL; + + /* ENC28J60 ethernet driver is based on spi driver */ + spi_bus_config_t buscfg = + { + .miso_io_num = MISO_GPIO, + .mosi_io_num = MOSI_GPIO, + .sclk_io_num = SCLK_GPIO, + .quadwp_io_num = -1, + .quadhd_io_num = -1, + }; + + if ( ESP_OK != spi_bus_initialize( SPI_HOST, &buscfg, SPI_DMA_CH_AUTO )) + return NULL; + + spi_device_interface_config_t devcfg = + { + .command_bits = 3, + .address_bits = 5, + .mode = 0, + .clock_speed_hz = SPI_CLOCK_MHZ * 1000 * 1000, + .spics_io_num = CS_GPIO, + .queue_size = 1, + .cs_ena_posttrans = enc28j60_cal_spi_cs_hold_time(SPI_CLOCK_MHZ), + }; + + spi_device_handle_t spi_handle = NULL; + + if (ESP_OK != spi_bus_add_device( SPI_HOST, &devcfg, &spi_handle )) + return NULL; + + return enc28j60_new_mac( &spi_handle, INT_GPIO ); +} + +//////////////////////////////////////// + diff --git a/src/libb64/cdecode.c b/src/libb64/cdecode.c new file mode 100644 index 0000000..55258ef --- /dev/null +++ b/src/libb64/cdecode.c @@ -0,0 +1,150 @@ +/**************************************************************************************************************************** + cdecode.c - c source to a base64 decoding algorithm implementation + + This is part of the libb64 project, and has been placed in the public domain. + For details, see http://sourceforge.net/projects/libb64 + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#include "cdecode.h" + +///////////////////////////////////////////////// + +int base64_decode_value(int value_in) +{ + static const char decoding[] = + { + 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 1, 2, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, + -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51 + }; + + static const char decoding_size = sizeof(decoding); + value_in -= 43; + + if (value_in < 0 || value_in > decoding_size) + return -1; + + return decoding[(int)value_in]; +} + +///////////////////////////////////////////////// + +void base64_init_decodestate(base64_decodestate* state_in) +{ + state_in->step = step_a; + state_in->plainchar = 0; +} + +///////////////////////////////////////////////// + +int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in) +{ + const char* codechar = code_in; + char* plainchar = plaintext_out; + int fragment; + + *plainchar = state_in->plainchar; + + switch (state_in->step) + { + while (1) + { + case step_a: + do + { + if (codechar == code_in + length_in) + { + state_in->step = step_a; + state_in->plainchar = *plainchar; + return plainchar - plaintext_out; + } + + fragment = base64_decode_value(*codechar++); + } while (fragment < 0); + + *plainchar = (fragment & 0x03f) << 2; + + // fall through + + case step_b: + do + { + if (codechar == code_in + length_in) + { + state_in->step = step_b; + state_in->plainchar = *plainchar; + return plainchar - plaintext_out; + } + + fragment = base64_decode_value(*codechar++); + } while (fragment < 0); + + *plainchar++ |= (fragment & 0x030) >> 4; + *plainchar = (fragment & 0x00f) << 4; + + // fall through + + case step_c: + do + { + if (codechar == code_in + length_in) + { + state_in->step = step_c; + state_in->plainchar = *plainchar; + return plainchar - plaintext_out; + } + + fragment = base64_decode_value(*codechar++); + } while (fragment < 0); + + *plainchar++ |= (fragment & 0x03c) >> 2; + *plainchar = (fragment & 0x003) << 6; + + // fall through + + case step_d: + do + { + if (codechar == code_in + length_in) + { + state_in->step = step_d; + state_in->plainchar = *plainchar; + return plainchar - plaintext_out; + } + + fragment = base64_decode_value(*codechar++); + } while (fragment < 0); + + *plainchar++ |= (fragment & 0x03f); + + // fall through + } + } + + /* control should not reach here */ + return plainchar - plaintext_out; +} + +///////////////////////////////////////////////// + +int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out) +{ + + base64_decodestate _state; + base64_init_decodestate(&_state); + int len = base64_decode_block(code_in, length_in, plaintext_out, &_state); + + if (len > 0) + plaintext_out[len] = 0; + + return len; +} diff --git a/src/libb64/cdecode.h b/src/libb64/cdecode.h new file mode 100644 index 0000000..203f847 --- /dev/null +++ b/src/libb64/cdecode.h @@ -0,0 +1,62 @@ +/**************************************************************************************************************************** + cdecode.h - c header for a base64 decoding algorithm + + This is part of the libb64 project, and has been placed in the public domain. + For details, see http://sourceforge.net/projects/libb64 + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#pragma once + +// Reintroduce to prevent duplication compile error if other lib/core already has LIB64 +// pragma once can't prevent that +#ifndef BASE64_CDECODE_H +#define BASE64_CDECODE_H + +#define base64_decode_expected_len(n) ((n * 3) / 4) + +///////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +///////////////////////////////////////////////// + +typedef enum +{ + step_a, step_b, step_c, step_d +} base64_decodestep; + +typedef struct +{ + base64_decodestep step; + char plainchar; +} base64_decodestate; + +///////////////////////////////////////////////// + +void base64_init_decodestate(base64_decodestate* state_in); + +int base64_decode_value(int value_in); + +int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in); + +int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out); + +///////////////////////////////////////////////// + +#ifdef __cplusplus +} // extern "C" +#endif + +///////////////////////////////////////////////// + +#endif /* BASE64_CDECODE_H */ diff --git a/src/libb64/cencode.c b/src/libb64/cencode.c new file mode 100644 index 0000000..5adaeaa --- /dev/null +++ b/src/libb64/cencode.c @@ -0,0 +1,154 @@ +/**************************************************************************************************************************** + cencode.c - c source to a base64 encoding algorithm implementation + + This is part of the libb64 project, and has been placed in the public domain. + For details, see http://sourceforge.net/projects/libb64 + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#include "cencode.h" + +const int CHARS_PER_LINE = 72; + +///////////////////////////////////////////////// + +void base64_init_encodestate(base64_encodestate* state_in) +{ + state_in->step = step_A; + state_in->result = 0; + state_in->stepcount = 0; +} + +///////////////////////////////////////////////// + +char base64_encode_value(char value_in) +{ + static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + if (value_in > 63) + return '='; + + return encoding[(unsigned int)value_in]; +} + +///////////////////////////////////////////////// + +int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in) +{ + const char* plainchar = plaintext_in; + const char* const plaintextend = plaintext_in + length_in; + char* codechar = code_out; + char result; + char fragment; + + result = state_in->result; + + switch (state_in->step) + { + while (1) + { + case step_A: + if (plainchar == plaintextend) + { + state_in->result = result; + state_in->step = step_A; + return codechar - code_out; + } + + fragment = *plainchar++; + result = (fragment & 0x0fc) >> 2; + *codechar++ = base64_encode_value(result); + result = (fragment & 0x003) << 4; + + // fall through + + case step_B: + if (plainchar == plaintextend) + { + state_in->result = result; + state_in->step = step_B; + return codechar - code_out; + } + + fragment = *plainchar++; + result |= (fragment & 0x0f0) >> 4; + *codechar++ = base64_encode_value(result); + result = (fragment & 0x00f) << 2; + + // fall through + + case step_C: + if (plainchar == plaintextend) + { + state_in->result = result; + state_in->step = step_C; + return codechar - code_out; + } + + fragment = *plainchar++; + result |= (fragment & 0x0c0) >> 6; + *codechar++ = base64_encode_value(result); + result = (fragment & 0x03f) >> 0; + *codechar++ = base64_encode_value(result); + + ++(state_in->stepcount); + + if (state_in->stepcount == CHARS_PER_LINE / 4) + { + *codechar++ = '\n'; + state_in->stepcount = 0; + } + + // fall through + } + } + + /* control should not reach here */ + return codechar - code_out; +} + +///////////////////////////////////////////////// + +int base64_encode_blockend(char* code_out, base64_encodestate* state_in) +{ + char* codechar = code_out; + + switch (state_in->step) + { + case step_B: + *codechar++ = base64_encode_value(state_in->result); + *codechar++ = '='; + *codechar++ = '='; + break; + + case step_C: + *codechar++ = base64_encode_value(state_in->result); + *codechar++ = '='; + break; + + case step_A: + break; + } + + *codechar = 0x00; + + return codechar - code_out; +} + +///////////////////////////////////////////////// + +int base64_encode_chars(const char* plaintext_in, int length_in, char* code_out) +{ + base64_encodestate _state; + base64_init_encodestate(&_state); + int len = base64_encode_block(plaintext_in, length_in, code_out, &_state); + + return len + base64_encode_blockend((code_out + len), &_state); +} diff --git a/src/libb64/cencode.h b/src/libb64/cencode.h new file mode 100644 index 0000000..84ba1bf --- /dev/null +++ b/src/libb64/cencode.h @@ -0,0 +1,65 @@ +/**************************************************************************************************************************** + cencode.h - c header for a base64 encoding algorithm + + This is part of the libb64 project, and has been placed in the public domain. + For details, see http://sourceforge.net/projects/libb64 + + For ENC28J60 Ethernet in ESP32 (ESP32 + ENC28J60) + + AsyncWebServer_ESP32_ENC is a library for the Ethernet ENC28J60 in ESSP32 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_ENC + Licensed under GPLv3 license + *****************************************************************************************************************************/ + +#pragma once + +// Reintroduce to prevent duplication compile error if other lib/core already has LIB64 +// pragma once can't prevent that +#ifndef BASE64_CENCODE_H +#define BASE64_CENCODE_H + +#define base64_encode_expected_len(n) ((((4 * n) / 3) + 3) & ~3) + +///////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +///////////////////////////////////////////////// + +typedef enum +{ + step_A, step_B, step_C +} base64_encodestep; + +typedef struct +{ + base64_encodestep step; + char result; + int stepcount; +} base64_encodestate; + +///////////////////////////////////////////////// + +void base64_init_encodestate(base64_encodestate* state_in); + +char base64_encode_value(char value_in); + +int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in); + +int base64_encode_blockend(char* code_out, base64_encodestate* state_in); + +int base64_encode_chars(const char* plaintext_in, int length_in, char* code_out); + +///////////////////////////////////////////////// + +#ifdef __cplusplus +} // extern "C" +#endif + +///////////////////////////////////////////////// + +#endif /* BASE64_CENCODE_H */ diff --git a/utils/astyle_library.conf b/utils/astyle_library.conf new file mode 100644 index 0000000..8a73bc2 --- /dev/null +++ b/utils/astyle_library.conf @@ -0,0 +1,70 @@ +# Code formatting rules for Arduino libraries, modified from for KH libraries: +# +# https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf +# + +# astyle --style=allman -s2 -t2 -C -S -xW -Y -M120 -f -p -xg -H -xb -c --xC120 -xL *.h *.cpp *.ino + +--mode=c +--lineend=linux +--style=allman + +# -r or -R +#--recursive + +# -c => Converts tabs into spaces +convert-tabs + +# -s2 => 2 spaces indentation +--indent=spaces=2 + +# -t2 => tab =2 spaces +#--indent=tab=2 + +# -C +--indent-classes + +# -S +--indent-switches + +# -xW +--indent-preproc-block + +# -Y => indent classes, switches (and cases), comments starting at column 1 +--indent-col1-comments + +# -M120 => maximum of 120 spaces to indent a continuation line +--max-continuation-indent=120 + +# -xC120 => max‑code‑length will break a line if the code exceeds # characters +--max-code-length=120 + +# -f => +--break-blocks + +# -p => put a space around operators +--pad-oper + +# -xg => Insert space padding after commas +--pad-comma + +# -H => put a space after if/for/while +pad-header + +# -xb => Break one line headers (e.g. if/for/while) +--break-one-line-headers + +# -c => Converts tabs into spaces +#--convert-tabs + +# if you like one-liners, keep them +#keep-one-line-statements + +# -xV +--attach-closing-while + +#unpad-paren + +# -xp +remove-comment-prefix + diff --git a/utils/restyle.sh b/utils/restyle.sh new file mode 100644 index 0000000..bcd846f --- /dev/null +++ b/utils/restyle.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for dir in . ; do + find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.ino" \) -exec astyle --suffix=none --options=./utils/astyle_library.conf \{\} \; +done +