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

Commit 496ec11

Browse files
authored
v1.2.0 to add ESP32 + LwIP Ethernet
#### Releases v1.2.0 1. Initial coding to port [esp32_https_server](https://github.com/fhessel/esp32_https_server) and [ESP32_HTTPS_Server](https://github.com/khoih-prog/ESP32_HTTPS_Server) to ESP32 boards, WT32_ETH01, (ESP32 + LwIP W5500) and (ESP32 + LwIP ENC28J60) Ethernet 2. Use `allman astyle` and restyle library.
1 parent f4edfb5 commit 496ec11

File tree

81 files changed

+13046
-0
lines changed

Some content is hidden

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

81 files changed

+13046
-0
lines changed

CONTRIBUTING.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## Contributing to AsyncWebServer_ESP32_W5500
2+
3+
### Reporting Bugs
4+
5+
Please report bugs in AsyncWebServer_ESP32_W5500 if you find them.
6+
7+
However, before reporting a bug please check through the following:
8+
9+
* [Existing Open Issues](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500/issues) - someone might have already encountered this.
10+
11+
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/AsyncWebServer_ESP32_W5500/issues/new).
12+
13+
### How to submit a bug report
14+
15+
Please ensure to specify the following:
16+
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* Board Core Version (e.g. ESP32 core v2.0.5)
19+
* Contextual information (e.g. what you were trying to achieve)
20+
* Simplest possible steps to reproduce
21+
* Anything that might be relevant in your opinion, such as:
22+
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
23+
* Network configuration
24+
25+
26+
### Example
27+
28+
```
29+
Arduino IDE version: 1.8.19
30+
ESP32_DEV board
31+
ESP32 core v2.0.5
32+
OS: Ubuntu 20.04 LTS
33+
Linux xy-Inspiron-3593 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
35+
Context:
36+
I encountered a crash while using this library
37+
Steps to reproduce:
38+
1. ...
39+
2. ...
40+
3. ...
41+
4. ...
42+
```
43+
44+
### Additional context
45+
46+
Add any other context about the problem here.
47+
48+
---
49+
50+
### Sending Feature Requests
51+
52+
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
53+
54+
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/HTTPS_Server_Generic/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
55+
56+
---
57+
58+
### Sending Pull Requests
59+
60+
Pull Requests with changes and fixes are also welcome!
61+
62+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
63+
64+
1. Change directory to the library GitHub
65+
66+
```
67+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/HTTPS_Server_Generic_GitHub/
68+
xy@xy-Inspiron-3593:~/Arduino/xy/HTTPS_Server_Generic_GitHub$
69+
```
70+
71+
2. Issue astyle command
72+
73+
```
74+
xy@xy-Inspiron-3593:~/Arduino/xy/HTTPS_Server_Generic_GitHub$ bash utils/restyle.sh
75+
```
76+
77+

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MIT License
22

3+
Copyright (c) 2017 Frank Hessel
34
Copyright (c) 2022 Khoi Hoang
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
doc:
2+
"$(MAKE)" -BC extras doc

README_orig.md

+323
Large diffs are not rendered by default.

changelog.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# HTTPS_Server_Generic Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/HTTPS_Server_Generic.svg?)](https://www.ardu-badge.com/HTTPS_Server_Generic)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/HTTPS_Server_Generic.svg)](https://github.com/khoih-prog/HTTPS_Server_Generic/releases)
5+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
6+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/HTTPS_Server_Generic.svg)](http://github.com/khoih-prog/HTTPS_Server_Generic/issues)
7+
8+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
9+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
10+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
11+
<a href="https://profile-counter.glitch.me/khoih-prog-HTTPS_Server_Generic/count.svg" title="HTTPS_Server_Generic Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-HTTPS_Server_Generic/count.svg" style="height: 30px;width: 200px;"></a>
12+
13+
---
14+
---
15+
16+
## Table of contents
17+
18+
* [Changelog](#changelog)
19+
* [Releases v1.2.0](#releases-v120)
20+
21+
22+
23+
---
24+
---
25+
26+
## Changelog
27+
28+
#### Releases v1.2.0
29+
30+
1. Initial coding to port [esp32_https_server](https://github.com/fhessel/esp32_https_server) and [ESP32_HTTPS_Server](https://github.com/khoih-prog/ESP32_HTTPS_Server) to ESP32 boards, WT32_ETH01, (ESP32 + LwIP W5500) and (ESP32 + LwIP ENC28J60) Ethernet
31+
2. Use `allman astyle` and restyle library.
32+

extras/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: doc
2+
doc:
3+
doxygen esp32_https_server.doxyfile

extras/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Extras
2+
3+
This folder contains files that are not directly part of the library.
4+
5+
## CI – Continuous Integration
6+
7+
The [ci](ci) folder contains scripts and data used for automated testing.
8+
9+
## Documentation
10+
11+
The [docs](docs/) folder contains documentation about the internal structure
12+
of the library.
13+
14+
## Legacy folder
15+
16+
Before the repository has been converted to follow the Arduino library
17+
structure, the main documentation consisted of a large example sketch.
18+
For reference, this sketch is archieved here.
19+
20+
## create_cert.sh
21+
22+
The script will create a CA and a server certificate that can be used to
23+
run the example sketches. It requires OpenSSL and the xxd tool to convert
24+
the DER-certificate data to C header files.
25+
26+
The certificate will not be trusted by any client, so you need to add a
27+
security exception in your browser or use eg. the `--insecure` flag when
28+
using tools like curl to test the server.
29+
30+
You should **not use this CA and certificates for production**. Make sure
31+
that you know what you're doing.
32+
33+
The header files `cert.h` and `private_key.h` have been copied in every
34+
example in the examples folder if the script terminated successfully, so you
35+
don't need to care about any imports if you open the examples in the Arduino IDE
36+
afterwards. The files should look like this:
37+
38+
```C++
39+
40+
/* cert.h */
41+
42+
unsigned char example_crt_DER[] = {
43+
0x30, 0x82, 0x02, 0x19, 0x30, 0x82, 0x01, 0x82, 0x02, 0x01,
44+
// ...
45+
};
46+
unsigned int example_crt_DER_len = 541;
47+
48+
/* private_key.h */
49+
50+
unsigned char example_key_DER[] = {
51+
0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xe1,
52+
// ...
53+
};
54+
unsigned int example_key_DER_len = 608;
55+
56+
```

extras/ci/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Testing and Continuous Integration
2+
3+
This folder contains the scripts and data that is used to run the tests that are specified in the GitHub Action workflows.
4+
5+
The structure of this folder is as follows:
6+
7+
- **apps** contains applications that are used during CI testing
8+
- **scripts** contains scripts and tools that are part of the workflows
9+
- **templates** contains project skeletons etc. used for testing
10+
- **tests** contains test suites written in Python which run against real hardware
11+
12+
## Run Tests Locally
13+
14+
You can (and should) run tests on your local machine before submitting an PR.
15+
16+
System Requirements
17+
18+
- A recent, Linux-based OS (it might work on macOS, too)
19+
- Python 3 installed (`sudo apt-get install python3` on Debian or Ubuntu)
20+
- Platform IO on your `PATH` (`source ~/.platformio/penv/bin/activate` if you're using an IDE like VSCode)
21+
- For the hardware checks: An ESP32 development board connected to your machine and a WiFi access point shared between you and the ESP32
22+
23+
### Build Examples
24+
25+
You can use `extras/ci/scripts/build-example.sh <"wroom"|"wrover"> <example-name>` to build a specific example.
26+
The main purpose of this is to check that everything still compiles as intended.
27+
The script will only try to build the example, but it will not flash it.
28+
The project folder is created in `tmp/<example-name>-<board-name>` in the root of the repositry.
29+
If you want, you can run `pio run -t upload -e <"wroom"|"wrover">` in these project directories to upload the example to a board.
30+
31+
To build all examples (and to check that everything works), there is a script for manual testing: `extras/ci/scripts/build-example.sh`
32+
33+
### Run Tests on Hardware
34+
35+
(tbd)
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Find the script and repository location based on the current script location
4+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
REPODIR=$(cd "$(dirname $SCRIPTDIR/../../../..)" && pwd)
6+
7+
TOTAL_TESTS=0
8+
FAILED_TESTS=0
9+
OK_TESTS=0
10+
11+
EXAMPLES_SUCCESS=()
12+
EXAMPLES_FAILURE=()
13+
for BOARD in wrover wroom; do
14+
for EXAMPLENAME in $(ls "$REPODIR/examples"); do
15+
if [ -d "$REPODIR/examples/$EXAMPLENAME" ] && [ -f "$REPODIR/examples/$EXAMPLENAME/$EXAMPLENAME.ino" ]; then
16+
$SCRIPTDIR/build-example.sh "$BOARD" "$EXAMPLENAME"
17+
RC=$?
18+
TOTAL_TESTS=$[ TOTAL_TESTS + 1 ]
19+
if [[ "$RC" == "0" ]]; then
20+
OK_TESTS=$[ OK_TESTS + 1 ]
21+
EXAMPLES_SUCCESS+=("$EXAMPLENAME ($BOARD)")
22+
else
23+
FAILED_TESTS=$[ FAILED_TESTS + 1 ]
24+
EXAMPLES_FAILURE+=("$EXAMPLENAME ($BOARD)")
25+
fi
26+
fi
27+
done # example loop
28+
done # board loop
29+
30+
echo "Summary: $OK_TESTS/$TOTAL_TESTS succeeded"
31+
echo "-----------------------------------------"
32+
for exmpl in "${EXAMPLES_SUCCESS[@]}"; do
33+
printf " \u2714 $exmpl\n"
34+
done
35+
for exmpl in "${EXAMPLES_FAILURE[@]}"; do
36+
printf " \u274c $exmpl\n"
37+
done
38+
if [[ "$FAILED_TESTS" != "0" ]]; then
39+
echo "$FAILED_TESTS Tests failed."
40+
exit 1
41+
else
42+
echo "Success."
43+
fi

extras/ci/scripts/build-example.sh

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
# This script verifies that every example in the examples directory can be built
4+
5+
# Check that PlatformIO is on the path
6+
if [[ "$(which pio)" == "" ]]; then
7+
echo "::error::PlatformIO executable (pio) not found on PATH. Stop."
8+
echo "::error::PATH=$PATH"
9+
exit 1
10+
fi
11+
12+
# Parse parameters
13+
BOARD="$1"
14+
if [[ "$BOARD" == "" ]]; then
15+
echo "::error::No board specified. Stop."
16+
exit 1
17+
fi
18+
EXAMPLENAME="$2"
19+
if [[ "$EXAMPLENAME" == "" ]]; then
20+
echo "::error::No example specified. Stop."
21+
exit 1
22+
fi
23+
24+
# In general, we want the script to fail if something unexpected happens.
25+
# This flag gets only revoked for the actual build process.
26+
set -e
27+
28+
# Find the script and repository location based on the current script location
29+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
30+
REPODIR=$(cd "$(dirname $SCRIPTDIR/../../../..)" && pwd)
31+
32+
# Some other directory definitions
33+
TMPDIR="$REPODIR/tmp"
34+
CIDIR="$REPODIR/extras/ci"
35+
EXAMPLEDIR="$REPODIR/examples"
36+
37+
# Re-create build directory
38+
if [ -d "$TMPDIR" ]; then
39+
rm -r "$TMPDIR"
40+
fi
41+
mkdir -p "$TMPDIR"
42+
43+
# Check that an .ino file exists
44+
if [ ! -d "$EXAMPLEDIR/$EXAMPLENAME" ]; then
45+
echo "::error::Example directory does not exist: $EXAMPLENAME"
46+
exit 1
47+
fi
48+
if [ ! -f "$EXAMPLEDIR/$EXAMPLENAME/$EXAMPLENAME.ino" ]; then
49+
echo "::error::Example sketch does not exist: $EXAMPLENAME.ino"
50+
exit 1
51+
fi
52+
53+
# We take the .ino file, rename it as main.cpp and add an Arduino.h include at the top
54+
PROJECTDIR="$TMPDIR/$EXAMPLENAME-$BOARD"
55+
MAINCPP="$PROJECTDIR/src/main.cpp"
56+
INOFILE="$PROJECTDIR/src/$EXAMPLENAME.ino"
57+
58+
# (re-)create the project directory under tmp/
59+
if [ -d "$PROJECTDIR" ] && [ "$PROJECTDIR" != "" ]; then
60+
rm -r "$PROJECTDIR"
61+
fi
62+
63+
# Create the lib folder to link the current version of the library
64+
mkdir -p "$PROJECTDIR/lib"
65+
# Copy the project folder template from ci/templates/example-project
66+
cp -r "$CIDIR/templates/example-project"/* "$PROJECTDIR/"
67+
# Copy the source files
68+
cp -r "$EXAMPLEDIR/$EXAMPLENAME/." "$PROJECTDIR/src"
69+
# Create the library link
70+
ln -s "$REPODIR" "$PROJECTDIR/lib/esp32_https_server"
71+
# Convert .ino to main.cpp
72+
echo "#include <Arduino.h>" > "$MAINCPP"
73+
cat "$INOFILE" >> "$MAINCPP"
74+
rm "$INOFILE"
75+
76+
# If the example has dependencies, rewrite platformio.ini
77+
if [[ -f "$EXAMPLEDIR/$EXAMPLENAME/.ci_lib_deps" ]]; then
78+
LIB_DEPS=$(head -n1 "$EXAMPLEDIR/$EXAMPLENAME/.ci_lib_deps")
79+
sed "s#\\#lib_deps#lib_deps = $LIB_DEPS#" "$PROJECTDIR/platformio.ini" > "$PROJECTDIR/platformio.ini.tmp"
80+
mv "$PROJECTDIR/platformio.ini.tmp" "$PROJECTDIR/platformio.ini"
81+
fi
82+
83+
# Try building the application (+e as we want to test every example and get a
84+
# summary on what is working)
85+
set +e
86+
pio --no-ansi run -d "$PROJECTDIR" -e "$BOARD" 2>&1 | \
87+
"$CIDIR/scripts/pio-to-gh-log.py" \
88+
"src/main.cpp:examples/$EXAMPLENAME/$EXAMPLENAME.ino:-1" \
89+
"lib/esp32_https_server/:src/" \
90+
"$REPODIR/:"
91+
RC=${PIPESTATUS[0]}
92+
if [[ "$RC" != "0" ]]; then
93+
echo "::error::pio returned with RC=$RC"
94+
fi
95+
exit $RC

extras/ci/scripts/pio-to-gh-log.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import re
4+
5+
# Simple Python script that takes PlatformIO's compiler errors and maps them to
6+
# output that can be understood by the Actions runner.
7+
8+
re_err = re.compile(r"^([^:]+):([0-9]+):([0-9]+): error: (.*)$")
9+
10+
# Parameters are strings of the form
11+
# path_prefix:replacement_prefix:line_offset
12+
# Where all paths starting with path_prefix will be replced with replacement_prefix,
13+
# and if such a replacement takes place, the line number will be shifted by line_offset.
14+
# That allows taking care for inserted code like the #include <Arduino.h>
15+
mappings = []
16+
for arg in sys.argv[1:]:
17+
parts = arg.split(":", 2)
18+
mappings.append((*parts[0:2], 0 if len(parts)==2 else int(parts[2])))
19+
20+
for line in sys.stdin:
21+
print(line, end="")
22+
m = re_err.match(line.strip())
23+
if m is not None:
24+
name = m.group(1)
25+
lineno = int(m.group(2))
26+
for mapping in mappings:
27+
if name.startswith(mapping[0]):
28+
name = mapping[1] + name[len(mapping[0]):]
29+
lineno += mapping[2]
30+
print("::error file={name},line={line},col={col}::{message}".format(
31+
name=name, line=lineno, col=m.group(3), message=m.group(4)
32+
))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Name, Type, SubType, Offset, Size, Flags
2+
nvs, data, nvs, 0x9000, 0x5000,
3+
otadata, data, ota, 0xe000, 0x2000,
4+
app0, app, ota_0, 0x10000, 0x1E0000,
5+
spiffs, data, spiffs, 0x1F0000,0x1E0000,

0 commit comments

Comments
 (0)