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

Commit 2e7eb28

Browse files
authored
v1.0.4
#### New in v1.0.4 1. Add support to all STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash.
1 parent e9e96f9 commit 2e7eb28

30 files changed

+756
-493
lines changed

README.md

Lines changed: 81 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
---
1010

11+
#### New in v1.0.4
12+
13+
1. Add support to all STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash.
14+
1115
#### New in v1.0.3
1216

1317
1. Fix bug not closing client and releasing socket.
@@ -24,14 +28,31 @@
2428

2529
1. Add support to ***W5x00*** Ethernet shields to all STM32 boards having 64+K bytes Flash.
2630

31+
---
32+
2733
This library currently supports
28-
1. STM32 boards with built-in Ethernet such as :
34+
1. ***STM32 boards with built-in Ethernet LAN8742A*** such as :
2935
- ***Nucleo-144 (F429ZI, F767ZI)***
3036
- ***Discovery (STM32F746G-DISCOVERY)***
31-
- ***All STM32 Boards with Built-in Ethernet***, See [How To Use Built-in Ethernet](https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
32-
2. ***STM32 boards (with 64+K Flash) running ENC28J60 shields***
33-
3. ***STM32 boards (with 64+K Flash) running W5x00 shields***
34-
4. See [EthernetWebServer Library Issue 1](https://github.com/khoih-prog/EthernetWebServer/issues/1) for reason to create this separate library from [EthernetWebServer library](https://github.com/khoih-prog/EthernetWebServer)
37+
- ***All STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet***
38+
- See [How To Use Built-in Ethernet](https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
39+
40+
2. ***STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 or ENC28J60 shields)***
41+
- Nucleo-144
42+
- Nucleo-64
43+
- Discovery
44+
- Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
45+
- STM32L0, STM32L1, STM32L4
46+
- STM32G0, STM32G4
47+
- STM32H7
48+
- STM32WB
49+
- STM32MP1
50+
- LoRa boards
51+
- 3-D printer boards
52+
- Generic Flight Controllers
53+
- Midatronics boards
54+
55+
3. See [EthernetWebServer Library Issue 1](https://github.com/khoih-prog/EthernetWebServer/issues/1) for reason to create this separate library from [EthernetWebServer library](https://github.com/khoih-prog/EthernetWebServer)
3556

3657
---
3758

@@ -333,24 +354,26 @@ Please take a look at other examples, as well.
333354
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
334355
- Nucleo-144 (F429ZI, F767ZI)
335356
- Discovery (STM32F746G-DISCOVERY)
336-
- All STM32 Boards with Built-in Ethernet, See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
337-
2) STM32 boards (with 64+K Flash) running EMC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
338-
3) STM32 boards (with 32+K Flash) running W5x00 Ethernet shields
339-
357+
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
358+
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
359+
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
360+
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
340361
*/
341362

342-
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) )
343-
#error This code is designed to run on STM32F platform! Please check your Tools->Board setting.
363+
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
364+
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
365+
defined(STM32WB) || defined(STM32MP1) )
366+
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
344367
#endif
345368

346369
#define DEBUG_ETHERNET_WEBSERVER_PORT Serial
347370

348371
// Debug Level from 0 to 4
349-
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 4
372+
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
350373

351-
#define USE_BUILTIN_ETHERNET true
374+
#define USE_BUILTIN_ETHERNET false
352375
// If don't use USE_BUILTIN_ETHERNET, and USE_UIP_ETHERNET => use W5x00 with Ethernet library
353-
#define USE_UIP_ETHERNET true //false
376+
#define USE_UIP_ETHERNET false //false
354377

355378
#if (USE_BUILTIN_ETHERNET)
356379
#define ETHERNET_NAME "Built-in LAN8742A Ethernet"
@@ -378,13 +401,37 @@ Please take a look at other examples, as well.
378401
#elif defined(STM32F7)
379402
#warning STM32F7 board selected
380403
#define BOARD_TYPE "STM32F7"
404+
#elif defined(STM32L0)
405+
#warning STM32L0 board selected
406+
#define BOARD_TYPE "STM32L0"
407+
#elif defined(STM32L1)
408+
#warning STM32L1 board selected
409+
#define BOARD_TYPE "STM32L1"
410+
#elif defined(STM32L4)
411+
#warning STM32L4 board selected
412+
#define BOARD_TYPE "STM32L4"
413+
#elif defined(STM32H7)
414+
#warning STM32H7 board selected
415+
#define BOARD_TYPE "STM32H7"
416+
#elif defined(STM32G0)
417+
#warning STM32G0 board selected
418+
#define BOARD_TYPE "STM32G0"
419+
#elif defined(STM32G4)
420+
#warning STM32G4 board selected
421+
#define BOARD_TYPE "STM32G4"
422+
#elif defined(STM32WB)
423+
#warning STM32WB board selected
424+
#define BOARD_TYPE "STM32WB"
425+
#elif defined(STM32MP1)
426+
#warning STM32MP1 board selected
427+
#define BOARD_TYPE "STM32MP1"
381428
#else
382429
#warning STM32 unknown board selected
383430
#define BOARD_TYPE "STM32 Unknown"
384431
#endif
385432

386433
#ifndef BOARD_NAME
387-
#define BOARD_NAME BOARD_TYPE
434+
#define BOARD_NAME BOARD_TYPE
388435
#endif
389436

390437
#include <EthernetWebServer_STM32.h>
@@ -427,9 +474,9 @@ const int led = 13;
427474
void handleRoot()
428475
{
429476
digitalWrite(led, 1);
430-
431-
#define BUFFER_SIZE 400
432-
477+
478+
#define BUFFER_SIZE 400
479+
433480
char temp[BUFFER_SIZE];
434481
int sec = millis() / 1000;
435482
int min = sec / 60;
@@ -440,7 +487,7 @@ void handleRoot()
440487
"<html>\
441488
<head>\
442489
<meta http-equiv='refresh' content='5'/>\
443-
<title>AdvancedServer %s</title>\
490+
<title>AdvancedWebServer %s</title>\
444491
<style>\
445492
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
446493
</style>\
@@ -454,7 +501,7 @@ body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Col
454501
</html>", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60);
455502

456503
server.send(200, "text/html", temp);
457-
504+
458505
digitalWrite(led, 0);
459506
}
460507

@@ -754,20 +801,24 @@ Disconnecting from server...
754801
755802
This is simple yet complete WebServer library for `STM32` boards running built-in Ethernet (Nucleo-144, Discovery) or EMC28J60 Ethernet shields. ***The functions are similar and compatible to ESP8266/ESP32 WebServer libraries*** to make life much easier to port sketches from ESP8266/ESP32.
756803
804+
---
805+
757806
This library currently supports
758-
1. ***STM32 boards with built-in Ethernet*** such as :
807+
1. ***STM32 boards with built-in Ethernet LAN8742A*** such as :
759808
- Nucleo-144 (F429ZI, F767ZI)
760809
- Discovery (STM32F746G-DISCOVERY)
761810
- All STM32 Boards with Built-in Ethernet, See [How To Use Built-in Ethernet](https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
762811
763-
2. ***STM32 boards (with 64+K Flash) running EMC28J60 shields***
812+
2. ***STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 or ENC28J60 shields)***
764813
- Nucleo-144
765814
- Nucleo-64
766815
- Discovery
816+
- Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
817+
- STM32L0, STM32L1, STM32L4
818+
- STM32G0, STM32G4
819+
- STM32H7
820+
- STM32WB
767821
- STM32MP1
768-
- Generic STM32F1 (with 64+K Flash): C8 and up
769-
- Generic STM32F4
770-
- STM32L0
771822
- LoRa boards
772823
- 3-D printer boards
773824
- Generic Flight Controllers
@@ -791,17 +842,17 @@ and these boards are not supported:
791842
792843
1. Bug Searching and Killing
793844
2. Add SSL/TLS Client and Server support
794-
3. Support more types of Ethernet shields such as W5x00, etc.
795-
4. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
796-
5. Add mDNS features.
797-
6. Use AsyncTCP features from [Phil Bowles' STM32AsyncTCP](https://github.com/philbowles/STM32AsyncTCP).
845+
3. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
846+
4. Add mDNS features.
847+
5. Use AsyncTCP features from [Phil Bowles' STM32AsyncTCP](https://github.com/philbowles/STM32AsyncTCP).
798848
799849
### DONE
800850
801851
1. Add support to ***STM32F1,2,3,4,7 boards*** with 64K+ Flash.
802852
2. Add support to ***built-in Ethernet LAN8742A*** using [STM32Ethernet library](https://github.com/stm32duino/STM32Ethernet) , for boards such as Nucleo-144 NUCLEO_F767ZI.
803853
3. Add support to ***Ethernet W5x00***, using either [`Ethernet`](https://www.arduino.cc/en/Reference/Ethernet), [`Ethernet2`](https://github.com/khoih-prog/Ethernet2), [`Ethernet3`](https://github.com/sstaub/Ethernet3) or [`EthernetLarge`](https://github.com/OPEnSLab-OSU/EthernetLarge) library
804-
4. Add support to Ethernet ***ENC28J60***, using [`UIPEthernet`](https://github.com/UIPEthernet/UIPEthernet) library
854+
4. Add support to Ethernet ***ENC28J60***, using [`UIPEthernet`](https://github.com/UIPEthernet/UIPEthernet) library
855+
5. Add support to all STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash.
805856
806857
---
807858

examples/AdvancedWebServer/AdvancedWebServer.ino

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
/****************************************************************************************************************************
22
AdvancedWebServer.h - Dead simple web-server for Ethernet shields
3-
4-
For STM32 with built-in Ethernet (Nucleo-144, DISCOVERY, etc)
5-
3+
4+
For STM32 with built-in Ethernet (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 Ethernet
5+
66
EthernetWebServer_STM32 is a library for the STM32 run built-in Ethernet WebServer
77
8-
Forked and modified from ESP8266 https://github.com/esp8266/Arduino/releases
9-
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_AT_WebServer
8+
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
9+
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_STM32
1010
Licensed under MIT license
11-
Version: 1.0.3
12-
11+
1312
Copyright (c) 2015, Majenko Technologies
1413
All rights reserved.
15-
14+
1615
Redistribution and use in source and binary forms, with or without modification,
1716
are permitted provided that the following conditions are met:
18-
17+
1918
Redistributions of source code must retain the above copyright notice, this
2019
list of conditions and the following disclaimer.
21-
20+
2221
Redistributions in binary form must reproduce the above copyright notice, this
2322
list of conditions and the following disclaimer in the documentation and/or
2423
other materials provided with the distribution.
25-
24+
2625
Neither the name of Majenko Technologies nor the names of its
2726
contributors may be used to endorse or promote products derived from
2827
this software without specific prior written permission.
29-
28+
3029
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3130
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3231
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -37,41 +36,42 @@
3736
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3837
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3938
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40-
41-
Original author:
42-
@file Esp8266WebServer.h
43-
@author Ivan Grokhotkov
44-
45-
Version Modified By Date Comments
46-
------- ----------- ---------- -----------
39+
40+
Version: 1.0.4
41+
42+
Version Modified By Date Comments
43+
------- ----------- ---------- -----------
4744
1.0.0 K Hoang 26/02/2020 Initial coding for STM32 with built-in Ethernet (Nucleo-144, DISCOVERY, etc) and ENC28J60
4845
1.0.1 K Hoang 28/02/2020 Add W5x00 Ethernet shields using Ethernet library
4946
1.0.2 K Hoang 05/03/2020 Remove dependency on functional-vlpp
50-
1.0.3 K Hoang 22/07/2020 Fix bug not closing client & releasing socket. Add features & dependency on functional-vlpp
47+
1.0.3 K Hoang 22/07/2020 Fix bug not closing client and releasing socket. Add features.
48+
1.0.4 K Hoang 23/07/2020 Add support to all STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash.
5149
*****************************************************************************************************************************/
5250
/*
5351
Currently support
5452
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
5553
- Nucleo-144 (F429ZI, F767ZI)
5654
- Discovery (STM32F746G-DISCOVERY)
57-
- All STM32 Boards with Built-in Ethernet, See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
58-
2) STM32 boards (with 64+K Flash) running EMC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
59-
3) STM32 boards (with 32+K Flash) running W5x00 Ethernet shields
60-
55+
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
56+
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
57+
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
58+
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
6159
*/
6260

63-
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) )
64-
#error This code is designed to run on STM32F platform! Please check your Tools->Board setting.
61+
#if !( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
62+
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
63+
defined(STM32WB) || defined(STM32MP1) )
64+
#error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting.
6565
#endif
6666

6767
#define DEBUG_ETHERNET_WEBSERVER_PORT Serial
6868

6969
// Debug Level from 0 to 4
70-
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 4
70+
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
7171

72-
#define USE_BUILTIN_ETHERNET true
72+
#define USE_BUILTIN_ETHERNET false
7373
// If don't use USE_BUILTIN_ETHERNET, and USE_UIP_ETHERNET => use W5x00 with Ethernet library
74-
#define USE_UIP_ETHERNET true //false
74+
#define USE_UIP_ETHERNET false //false
7575

7676
#if (USE_BUILTIN_ETHERNET)
7777
#define ETHERNET_NAME "Built-in LAN8742A Ethernet"
@@ -99,13 +99,37 @@
9999
#elif defined(STM32F7)
100100
#warning STM32F7 board selected
101101
#define BOARD_TYPE "STM32F7"
102+
#elif defined(STM32L0)
103+
#warning STM32L0 board selected
104+
#define BOARD_TYPE "STM32L0"
105+
#elif defined(STM32L1)
106+
#warning STM32L1 board selected
107+
#define BOARD_TYPE "STM32L1"
108+
#elif defined(STM32L4)
109+
#warning STM32L4 board selected
110+
#define BOARD_TYPE "STM32L4"
111+
#elif defined(STM32H7)
112+
#warning STM32H7 board selected
113+
#define BOARD_TYPE "STM32H7"
114+
#elif defined(STM32G0)
115+
#warning STM32G0 board selected
116+
#define BOARD_TYPE "STM32G0"
117+
#elif defined(STM32G4)
118+
#warning STM32G4 board selected
119+
#define BOARD_TYPE "STM32G4"
120+
#elif defined(STM32WB)
121+
#warning STM32WB board selected
122+
#define BOARD_TYPE "STM32WB"
123+
#elif defined(STM32MP1)
124+
#warning STM32MP1 board selected
125+
#define BOARD_TYPE "STM32MP1"
102126
#else
103127
#warning STM32 unknown board selected
104128
#define BOARD_TYPE "STM32 Unknown"
105129
#endif
106130

107131
#ifndef BOARD_NAME
108-
#define BOARD_NAME BOARD_TYPE
132+
#define BOARD_NAME BOARD_TYPE
109133
#endif
110134

111135
#include <EthernetWebServer_STM32.h>
@@ -148,9 +172,9 @@ const int led = 13;
148172
void handleRoot()
149173
{
150174
digitalWrite(led, 1);
151-
152-
#define BUFFER_SIZE 400
153-
175+
176+
#define BUFFER_SIZE 400
177+
154178
char temp[BUFFER_SIZE];
155179
int sec = millis() / 1000;
156180
int min = sec / 60;
@@ -175,7 +199,7 @@ body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Col
175199
</html>", BOARD_NAME, BOARD_NAME, day, hr % 24, min % 60, sec % 60);
176200

177201
server.send(200, "text/html", temp);
178-
202+
179203
digitalWrite(led, 0);
180204
}
181205

0 commit comments

Comments
 (0)