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

Commit 46d82f1

Browse files
authored
v1.3.0 to reduce String usage
### Major Releases v1.3.0 1. Reduce usage of Arduino String with std::string 2. Optimize library code and examples by using **reference-passing instead of value-passing**. 3. Update `Packages' Patches`
1 parent 72e877d commit 46d82f1

26 files changed

+1054
-2640
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
17+
* Arduino IDE version (e.g. 1.8.18) or Platform.io version
1818
* Board Core Version (e.g. STM32F7 Nucleo-144 NUCLEO_F767ZI, STM32 core v2.1.0, etc.)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
@@ -26,10 +26,10 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.16
29+
Arduino IDE version: 1.8.18
3030
STM32F7 Nucleo-144 NUCLEO_F767ZI, STM32 core v2.1.0
3131
OS: Ubuntu 20.04 LTS
32-
Linux xy-Inspiron-3593 5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
32+
Linux xy-Inspiron-3593 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
3535
I encountered a crash while trying to use the Timer Interrupt.

README.md

Lines changed: 94 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ Check [`EthernetWebServer Library Issue: Support for STM32F Series`](https://git
267267

268268
## Prerequisites
269269

270-
1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
270+
1. [`Arduino IDE 1.8.18+` for Arduino](https://www.arduino.cc/en/Main/Software)
271271
2. [`Arduino Core for STM32 v2.1.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
272272
3. [`Functional-VLPP library v1.0.2+`](https://github.com/khoih-prog/functional-vlpp) to use server's lambda function. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Functional-Vlpp.svg?)](https://www.ardu-badge.com/Functional-Vlpp)
273273
4. For built-in LAN8742A or LAN8720 Ethernet:
@@ -367,6 +367,8 @@ To fix [`Ethernet library`](https://www.arduino.cc/en/Reference/Ethernet), just
367367
- [w5100.h](LibraryPatches/Ethernet/src/utility/w5100.h)
368368
- [w5100.cpp](LibraryPatches/Ethernet/src/utility/w5100.cpp)
369369

370+
You can also use the forked and modified library at [Patched Ethernet](https://github.com/khoih-prog/Ethernet)
371+
370372
#### 3. For EthernetLarge library
371373

372374
To fix [`EthernetLarge library`](https://github.com/OPEnSLab-OSU/EthernetLarge), just copy these following files into the [`EthernetLarge library`](https://github.com/OPEnSLab-OSU/EthernetLarge) directory to overwrite the old files:
@@ -376,6 +378,7 @@ To fix [`EthernetLarge library`](https://github.com/OPEnSLab-OSU/EthernetLarge),
376378
- [w5100.h](LibraryPatches/EthernetLarge/src/utility/w5100.h)
377379
- [w5100.cpp](LibraryPatches/EthernetLarge/src/utility/w5100.cpp)
378380

381+
You can also use the forked and modified library at [Patched EthernetLarge](https://github.com/khoih-prog/EthernetLarge)
379382

380383
#### 4. For Ethernet2 library
381384

@@ -389,12 +392,16 @@ To add UDP Multicast support, necessary for the [**UPnP_Generic library**](https
389392
- [EthernetUdp2.h](LibraryPatches/Ethernet2/src/EthernetUdp2.h)
390393
- [EthernetUdp2.cpp](LibraryPatches/Ethernet2/src/EthernetUdp2.cpp)
391394

395+
You can also use the forked and modified library at [Patched Ethernet2](https://github.com/khoih-prog/Ethernet2)
396+
392397
#### 5. For Ethernet3 library
393398

394-
To fix [`Ethernet3 library`](https://github.com/sstaub/Ethernet3), just copy these following files into the [`Ethernet3 library`](https://github.com/sstaub/Ethernet3) directory to overwrite the old files:
399+
5. To fix [`Ethernet3 library`](https://github.com/sstaub/Ethernet3), just copy these following files into the [`Ethernet3 library`](https://github.com/sstaub/Ethernet3) directory to overwrite the old files:
395400
- [Ethernet3.h](LibraryPatches/Ethernet3/src/Ethernet3.h)
396401
- [Ethernet3.cpp](LibraryPatches/Ethernet3/src/Ethernet3.cpp)
397402

403+
You can also use the forked and modified library at [Patched Ethernet3](https://github.com/khoih-prog/Ethernet3)
404+
398405
#### 6. For UIPEthernet library
399406

400407
***To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library***, you have to copy these following files into the UIPEthernet `utility` directory to overwrite the old files:
@@ -1025,6 +1032,37 @@ void handleNotFound()
10251032
digitalWrite(led, 0);
10261033
}
10271034

1035+
#if (defined(ETHERNET_WEBSERVER_STM32_VERSION_INT) && (ETHERNET_WEBSERVER_STM32_VERSION_INT >= 1003000))
1036+
1037+
EWString initHeader = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n" \
1038+
"<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
1039+
"<g stroke=\"blue\">\n";
1040+
1041+
void drawGraph()
1042+
{
1043+
EWString out;
1044+
1045+
out.reserve(3000);
1046+
char temp[70];
1047+
1048+
out += initHeader;
1049+
1050+
int y = rand() % 130;
1051+
1052+
for (int x = 10; x < 300; x += 10)
1053+
{
1054+
int y2 = rand() % 130;
1055+
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 140 - y, x + 10, 140 - y2);
1056+
out += temp;
1057+
y = y2;
1058+
}
1059+
out += "</g>\n</svg>\n";
1060+
1061+
server.send(200, "image/svg+xml", fromEWString(out));
1062+
}
1063+
1064+
#else
1065+
10281066
void drawGraph()
10291067
{
10301068
String out;
@@ -1047,7 +1085,9 @@ void drawGraph()
10471085
server.send(200, "image/svg+xml", out);
10481086
}
10491087

1050-
void setup(void)
1088+
#endif
1089+
1090+
void setup()
10511091
{
10521092
pinMode(led, OUTPUT);
10531093
digitalWrite(led, 0);
@@ -1109,9 +1149,41 @@ void setup(void)
11091149
Serial.println(Ethernet.localIP());
11101150
}
11111151

1112-
void loop(void)
1152+
void heartBeatPrint()
1153+
{
1154+
static int num = 1;
1155+
1156+
Serial.print(F("."));
1157+
1158+
if (num == 80)
1159+
{
1160+
Serial.println();
1161+
num = 1;
1162+
}
1163+
else if (num++ % 10 == 0)
1164+
{
1165+
Serial.print(F(" "));
1166+
}
1167+
}
1168+
1169+
void check_status()
1170+
{
1171+
static unsigned long checkstatus_timeout = 0;
1172+
1173+
#define STATUS_CHECK_INTERVAL 10000L
1174+
1175+
// Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
1176+
if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
1177+
{
1178+
heartBeatPrint();
1179+
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
1180+
}
1181+
}
1182+
1183+
void loop()
11131184
{
11141185
server.handleClient();
1186+
check_status();
11151187
}
11161188
```
11171189
@@ -1135,8 +1207,8 @@ void loop(void)
11351207
// If USE_BUILTIN_ETHERNET == false and USE_UIP_ETHERNET == false =>
11361208
// either use W5x00 with EthernetXYZ library
11371209
// or ENC28J60 with EthernetENC library
1138-
//#define USE_BUILTIN_ETHERNET true
1139-
#define USE_BUILTIN_ETHERNET false
1210+
#define USE_BUILTIN_ETHERNET true
1211+
//#define USE_BUILTIN_ETHERNET false
11401212
11411213
//#define USE_UIP_ETHERNET true
11421214
#define USE_UIP_ETHERNET false
@@ -1303,7 +1375,7 @@ Following is debug terminal output and screen shot when running example [Advance
13031375

13041376
```
13051377
Start AdvancedWebServer on NUCLEO_F767ZI, using LAN8742A Ethernet & STM32Ethernet Library
1306-
EthernetWebServer_STM32 v1.2.1
1378+
EthernetWebServer_STM32 v1.3.0
13071379
HTTP EthernetWebServer is @ IP : 192.168.2.117
13081380
EthernetWebServer::handleClient: New Client
13091381
method: GET
@@ -1427,7 +1499,7 @@ The following is debug terminal output when running example [WebClientRepeating]
14271499

14281500
```
14291501
Start WebClientRepeating on NUCLEO_F767ZI, using ENC28J60 & EthernetENC Library
1430-
EthernetWebServer_STM32 v1.2.1
1502+
EthernetWebServer_STM32 v1.3.0
14311503
[ETHERNET_WEBSERVER] Board : NUCLEO_F767ZI , setCsPin: 10
14321504
[ETHERNET_WEBSERVER] Default SPI pinout:
14331505
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1502,7 +1574,7 @@ The following is debug terminal output when running example [UdpNTPClient](examp
15021574

15031575
```
15041576
Start UdpNTPClient on NUCLEO_F767ZI, using W5x00 & Ethernet2 Library
1505-
EthernetWebServer_STM32 v1.2.1
1577+
EthernetWebServer_STM32 v1.3.0
15061578
[ETHERNET_WEBSERVER] Board : NUCLEO_F767ZI , setCsPin: 10
15071579
[ETHERNET_WEBSERVER] Default SPI pinout:
15081580
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1526,7 +1598,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet
15261598

15271599
```
15281600
Starting SimpleWebSocket on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
1529-
EthernetWebServer_STM32 v1.2.1
1601+
EthernetWebServer_STM32 v1.3.0
15301602
[ETHERNET_WEBSERVER] =========================
15311603
[ETHERNET_WEBSERVER] Default SPI pinout:
15321604
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1571,7 +1643,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with W5x00 & Ethernet3
15711643

15721644
```
15731645
Starting SimpleWebSocket on NUCLEO_F767ZI with W5x00 & Ethernet3 Library
1574-
EthernetWebServer_STM32 v1.2.1
1646+
EthernetWebServer_STM32 v1.3.0
15751647
[ETHERNET_WEBSERVER] =========== USE_ETHERNET3 ===========
15761648
[ETHERNET_WEBSERVER] Default SPI pinout:
15771649
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1623,7 +1695,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet
16231695

16241696
```
16251697
Starting SimpleHTTPExample on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
1626-
EthernetWebServer_STM32 v1.2.1
1698+
EthernetWebServer_STM32 v1.3.0
16271699
[ETHERNET_WEBSERVER] =========================
16281700
[ETHERNET_WEBSERVER] Default SPI pinout:
16291701
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1696,7 +1768,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet
16961768

16971769
```
16981770
Start MQTTClient_Auth on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
1699-
EthernetWebServer_STM32 v1.2.1
1771+
EthernetWebServer_STM32 v1.3.0
17001772
[ETHERNET_WEBSERVER] =========================
17011773
[ETHERNET_WEBSERVER] Default SPI pinout:
17021774
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1735,7 +1807,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with ENC28J60 & Ethern
17351807

17361808
```
17371809
Start MQTTClient_Auth on NUCLEO_F767ZI with ENC28J60 & EthernetENC Library
1738-
EthernetWebServer_STM32 v1.2.1
1810+
EthernetWebServer_STM32 v1.3.0
17391811
[ETHERNET_WEBSERVER] =========== USE_ETHERNET_ENC ===========
17401812
[ETHERNET_WEBSERVER] Default SPI pinout:
17411813
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1774,7 +1846,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with W5x00 & Ethernet2
17741846

17751847
```
17761848
Start MQTTClient_Auth on NUCLEO_F767ZI with W5x00 & Ethernet2 Library
1777-
EthernetWebServer_STM32 v1.2.1
1849+
EthernetWebServer_STM32 v1.3.0
17781850
[ETHERNET_WEBSERVER] =========== USE_ETHERNET2 ===========
17791851
[ETHERNET_WEBSERVER] Default SPI pinout:
17801852
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1808,7 +1880,7 @@ The terminal output of **STM32F4 BLACK_F407VE with LAN8720 Ethernet and STM32Eth
18081880

18091881
```
18101882
Starting SimpleWebSocket_LAN8720 on BLACK_F407VE with LAN8720 Ethernet & STM32Ethernet Library
1811-
EthernetWebServer_STM32 v1.2.1
1883+
EthernetWebServer_STM32 v1.3.0
18121884
Using mac index = 6
18131885
Connected! IP address: 192.168.2.138
18141886
starting WebSocket client
@@ -1833,7 +1905,7 @@ The terminal output of **BLACK_F407VE using LAN8720 Ethernet and STM32Ethernet L
18331905

18341906
```
18351907
Start WebClient_LAN8720 on BLACK_F407VE, using LAN8720 Ethernet & STM32Ethernet Library
1836-
EthernetWebServer_STM32 v1.2.1
1908+
EthernetWebServer_STM32 v1.3.0
18371909
You're connected to the network, IP = 192.168.2.139
18381910
18391911
Starting connection to server...
@@ -1906,7 +1978,7 @@ Following is debug terminal output and screen shot when running example [Advance
19061978

19071979
```
19081980
Start AdvancedWebServer_LAN8720 on BLACK_F407VE, using LAN8720 Ethernet & STM32Ethernet Library
1909-
EthernetWebServer_STM32 v1.2.1
1981+
EthernetWebServer_STM32 v1.3.0
19101982
HTTP EthernetWebServer is @ IP : 192.168.2.138
19111983
19121984
```
@@ -1972,7 +2044,10 @@ Submit issues to: [EthernetWebServer_STM32 issues](https://github.com/khoih-prog
19722044
6. Add **High-level HTTP (GET, POST, PUT, PATCH, DELETE) and WebSocket Client**
19732045
7. Add SSL/TLS Server support in [EthernetWebServer_SSL_STM32](https://github.com/khoih-prog/EthernetWebServer_SSL_STM32)
19742046
8. Add support to **Ethernet LAN8720** using [STM32Ethernet library](https://github.com/stm32duino/STM32Ethernet), for boards such as **Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG), Discovery (DISCO_F746NG)** and **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)**
1975-
2047+
9. Reduce usage of Arduino String with std::string
2048+
10. Optimize library code and examples by using **reference-passing instead of value-passing**
2049+
2050+
19762051
---
19772052

19782053
### Contributions and Thanks

0 commit comments

Comments
 (0)