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

Commit 46242ff

Browse files
authored
v1.3.1 to fix String-related bug
### Releases v1.3.1 1. Fix bug related to String in examples
1 parent 9e939da commit 46242ff

25 files changed

+94
-86
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 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.18) or Platform.io version
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
1818
* Board Core Version (e.g. STM32F7 Nucleo-144 NUCLEO_F767ZI, STM32 core v2.2.0, etc.)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
@@ -26,7 +26,7 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.18
29+
Arduino IDE version: 1.8.19
3030
STM32F7 Nucleo-144 NUCLEO_F767ZI, STM32 core v2.2.0
3131
OS: Ubuntu 20.04 LTS
3232
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

README.md

Lines changed: 42 additions & 50 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.18+` for Arduino](https://www.arduino.cc/en/Main/Software)
270+
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)
271271
2. [`Arduino Core for STM32 v2.2.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:
@@ -979,7 +979,7 @@ void handleRoot()
979979
{
980980
digitalWrite(led, 1);
981981

982-
#define BUFFER_SIZE 400
982+
#define BUFFER_SIZE 512
983983

984984
char temp[BUFFER_SIZE];
985985
int sec = millis() / 1000;
@@ -1032,21 +1032,25 @@ void handleNotFound()
10321032
digitalWrite(led, 0);
10331033
}
10341034

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";
1035+
#define ORIGINAL_STR_LEN 2048
10401036

10411037
void drawGraph()
10421038
{
1043-
EWString out;
1044-
1045-
out.reserve(3000);
1039+
static String out;
1040+
static uint16_t previousStrLen = ORIGINAL_STR_LEN;
1041+
1042+
if (out.length() == 0)
1043+
{
1044+
ET_LOGWARN1(F("String Len = 0, extend to"), ORIGINAL_STR_LEN);
1045+
out.reserve(ORIGINAL_STR_LEN);
1046+
}
1047+
1048+
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n" \
1049+
"<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
1050+
"<g stroke=\"blue\">\n");
1051+
10461052
char temp[70];
10471053

1048-
out += initHeader;
1049-
10501054
int y = rand() % 130;
10511055

10521056
for (int x = 10; x < 300; x += 10)
@@ -1056,37 +1060,25 @@ void drawGraph()
10561060
out += temp;
10571061
y = y2;
10581062
}
1059-
out += "</g>\n</svg>\n";
1063+
1064+
out += F("</g>\n</svg>\n");
10601065

1061-
server.send(200, "image/svg+xml", fromEWString(out));
1062-
}
1066+
ET_LOGDEBUG1(F("String Len = "), out.length());
10631067

1064-
#else
1065-
1066-
void drawGraph()
1067-
{
1068-
String out;
1069-
out.reserve(3000);
1070-
char temp[70];
1071-
out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n";
1072-
out += "<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
1073-
out += "<g stroke=\"black\">\n";
1074-
int y = rand() % 130;
1068+
if (out.length() > previousStrLen)
1069+
{
1070+
ET_LOGERROR3(F("String Len > "), previousStrLen, F(", extend to"), out.length() + 48);
10751071

1076-
for (int x = 10; x < 300; x += 10)
1072+
previousStrLen = out.length() + 48;
1073+
1074+
out.reserve(previousStrLen);
1075+
}
1076+
else
10771077
{
1078-
int y2 = rand() % 130;
1079-
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);
1080-
out += temp;
1081-
y = y2;
1078+
server.send(200, "image/svg+xml", out);
10821079
}
1083-
out += "</g>\n</svg>\n";
1084-
1085-
server.send(200, "image/svg+xml", out);
10861080
}
10871081

1088-
#endif
1089-
10901082
void setup()
10911083
{
10921084
pinMode(led, OUTPUT);
@@ -1375,7 +1367,7 @@ Following is debug terminal output and screen shot when running example [Advance
13751367

13761368
```
13771369
Start AdvancedWebServer on NUCLEO_F767ZI, using LAN8742A Ethernet & STM32Ethernet Library
1378-
EthernetWebServer_STM32 v1.3.0
1370+
EthernetWebServer_STM32 v1.3.1
13791371
HTTP EthernetWebServer is @ IP : 192.168.2.117
13801372
EthernetWebServer::handleClient: New Client
13811373
method: GET
@@ -1499,7 +1491,7 @@ The following is debug terminal output when running example [WebClientRepeating]
14991491

15001492
```
15011493
Start WebClientRepeating on NUCLEO_F767ZI, using ENC28J60 & EthernetENC Library
1502-
EthernetWebServer_STM32 v1.3.0
1494+
EthernetWebServer_STM32 v1.3.1
15031495
[ETHERNET_WEBSERVER] Board : NUCLEO_F767ZI , setCsPin: 10
15041496
[ETHERNET_WEBSERVER] Default SPI pinout:
15051497
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1574,7 +1566,7 @@ The following is debug terminal output when running example [UdpNTPClient](examp
15741566

15751567
```
15761568
Start UdpNTPClient on NUCLEO_F767ZI, using W5x00 & Ethernet2 Library
1577-
EthernetWebServer_STM32 v1.3.0
1569+
EthernetWebServer_STM32 v1.3.1
15781570
[ETHERNET_WEBSERVER] Board : NUCLEO_F767ZI , setCsPin: 10
15791571
[ETHERNET_WEBSERVER] Default SPI pinout:
15801572
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1598,7 +1590,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet
15981590

15991591
```
16001592
Starting SimpleWebSocket on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
1601-
EthernetWebServer_STM32 v1.3.0
1593+
EthernetWebServer_STM32 v1.3.1
16021594
[ETHERNET_WEBSERVER] =========================
16031595
[ETHERNET_WEBSERVER] Default SPI pinout:
16041596
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1643,7 +1635,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with W5x00 & Ethernet3
16431635

16441636
```
16451637
Starting SimpleWebSocket on NUCLEO_F767ZI with W5x00 & Ethernet3 Library
1646-
EthernetWebServer_STM32 v1.3.0
1638+
EthernetWebServer_STM32 v1.3.1
16471639
[ETHERNET_WEBSERVER] =========== USE_ETHERNET3 ===========
16481640
[ETHERNET_WEBSERVER] Default SPI pinout:
16491641
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1695,7 +1687,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet
16951687

16961688
```
16971689
Starting SimpleHTTPExample on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
1698-
EthernetWebServer_STM32 v1.3.0
1690+
EthernetWebServer_STM32 v1.3.1
16991691
[ETHERNET_WEBSERVER] =========================
17001692
[ETHERNET_WEBSERVER] Default SPI pinout:
17011693
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1768,7 +1760,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet
17681760

17691761
```
17701762
Start MQTTClient_Auth on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
1771-
EthernetWebServer_STM32 v1.3.0
1763+
EthernetWebServer_STM32 v1.3.1
17721764
[ETHERNET_WEBSERVER] =========================
17731765
[ETHERNET_WEBSERVER] Default SPI pinout:
17741766
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1807,7 +1799,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with ENC28J60 & Ethern
18071799

18081800
```
18091801
Start MQTTClient_Auth on NUCLEO_F767ZI with ENC28J60 & EthernetENC Library
1810-
EthernetWebServer_STM32 v1.3.0
1802+
EthernetWebServer_STM32 v1.3.1
18111803
[ETHERNET_WEBSERVER] =========== USE_ETHERNET_ENC ===========
18121804
[ETHERNET_WEBSERVER] Default SPI pinout:
18131805
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1846,7 +1838,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with W5x00 & Ethernet2
18461838

18471839
```
18481840
Start MQTTClient_Auth on NUCLEO_F767ZI with W5x00 & Ethernet2 Library
1849-
EthernetWebServer_STM32 v1.3.0
1841+
EthernetWebServer_STM32 v1.3.1
18501842
[ETHERNET_WEBSERVER] =========== USE_ETHERNET2 ===========
18511843
[ETHERNET_WEBSERVER] Default SPI pinout:
18521844
[ETHERNET_WEBSERVER] MOSI: 11
@@ -1880,7 +1872,7 @@ The terminal output of **STM32F4 BLACK_F407VE with LAN8720 Ethernet and STM32Eth
18801872

18811873
```
18821874
Starting SimpleWebSocket_LAN8720 on BLACK_F407VE with LAN8720 Ethernet & STM32Ethernet Library
1883-
EthernetWebServer_STM32 v1.3.0
1875+
EthernetWebServer_STM32 v1.3.1
18841876
Using mac index = 6
18851877
Connected! IP address: 192.168.2.138
18861878
starting WebSocket client
@@ -1905,7 +1897,7 @@ The terminal output of **BLACK_F407VE using LAN8720 Ethernet and STM32Ethernet L
19051897

19061898
```
19071899
Start WebClient_LAN8720 on BLACK_F407VE, using LAN8720 Ethernet & STM32Ethernet Library
1908-
EthernetWebServer_STM32 v1.3.0
1900+
EthernetWebServer_STM32 v1.3.1
19091901
You're connected to the network, IP = 192.168.2.139
19101902
19111903
Starting connection to server...
@@ -1978,9 +1970,9 @@ Following is debug terminal output and screen shot when running example [Advance
19781970

19791971
```
19801972
Start AdvancedWebServer_LAN8720 on BLACK_F407VE, using LAN8720 Ethernet & STM32Ethernet Library
1981-
EthernetWebServer_STM32 v1.3.0
1982-
HTTP EthernetWebServer is @ IP : 192.168.2.138
1983-
1973+
EthernetWebServer_STM32 v1.3.1
1974+
.[EWS] String Len = 0, extend to 2048
1975+
......... .......... .......... .......... .......... .......... .......... ..........
19841976
```
19851977

19861978
---

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.3.1](#releases-v131)
1516
* [Major Releases v1.3.0](#major-releases-v130)
1617
* [Releases v1.2.1](#releases-v121)
1718
* [Releases v1.2.0](#releases-v120)
@@ -29,6 +30,10 @@
2930

3031
## Changelog
3132

33+
### Releases v1.3.1
34+
35+
1. Fix bug related to String in examples
36+
3237
### Major Releases v1.3.0
3338

3439
1. Reduce usage of Arduino String with std::string

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EthernetWebServer_STM32",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"keywords": "WebServer, built-in-Ethernet, STM32F, STM32L, STM32H, STM32G, STM32WB, STM32MP1, Ethernet-shield, Nucleo-144, Nucleo-64, Nucleo-32, LAN8742A, LAN8720, ENC28J60, W5x00, W5500, W5100, Ethernet, Ethernet2, Ethernet3, EthernetLarge, EtnernetENC, UIPEthernet, HTTP-Client, WebSocket-Client, server, client, websocket",
55
"description": "Simple Ethernet WebServer, HTTP Client and WebSocket Client library for STM32F/L/H/G/WB/MP1 boards running built-in Ethernet LAN8742A, LAN8720 or Ethernet W5x00, ENC28J60 shields",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EthernetWebServer_STM32
2-
version=1.3.0
2+
version=1.3.1
33
author=Khoi Hoang
44
license=MIT
55
maintainer=Khoi Hoang <khoih.prog@gmail.com>

src/EthernetHttpClient_STM32.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@file Esp8266WebServer.h
1313
@author Ivan Grokhotkov
1414
15-
Version: 1.3.0
15+
Version: 1.3.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
@@ -29,6 +29,7 @@
2929
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3030
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
3131
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
32+
1.3.1 K Hoang 25/12/2021 Fix bug
3233
*************************************************************************************************************************************/
3334

3435
// Library to simplify HTTP fetching on Arduino

src/EthernetWebServer_STM32-impl.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@file Esp8266WebServer.h
1313
@author Ivan Grokhotkov
1414
15-
Version: 1.3.0
15+
Version: 1.3.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
@@ -29,6 +29,7 @@
2929
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3030
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
3131
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
32+
1.3.1 K Hoang 25/12/2021 Fix bug
3233
*************************************************************************************************************************************/
3334

3435
#pragma once
@@ -460,9 +461,6 @@ void EthernetWebServer::_prepareHeader(String& response, int code, const char* c
460461
response = fromEWString(aResponse);
461462

462463
_responseHeaders = String();
463-
464-
//MR & KH fix
465-
//_responseHeaders = *(new String());
466464
}
467465

468466
void EthernetWebServer::_prepareHeader(EWString& response, int code, const char* content_type, size_t contentLength)
@@ -505,9 +503,6 @@ void EthernetWebServer::_prepareHeader(EWString& response, int code, const char*
505503
response += RETURN_NEWLINE;
506504

507505
_responseHeaders = String();
508-
509-
//MR & KH fix
510-
//_responseHeaders = *(new String());
511506
}
512507

513508
void EthernetWebServer::send(int code, const char* content_type, const String& content)
@@ -885,9 +880,6 @@ void EthernetWebServer::_handleRequest()
885880
}
886881

887882
_currentUri = String();
888-
889-
//MR & KH fix
890-
//_currentUri = *(new String());
891883
}
892884

893885
void EthernetWebServer::_finalizeResponse()

src/EthernetWebServer_STM32.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@file Esp8266WebServer.h
1313
@author Ivan Grokhotkov
1414
15-
Version: 1.3.0
15+
Version: 1.3.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
@@ -29,6 +29,7 @@
2929
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3030
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
3131
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
32+
1.3.1 K Hoang 25/12/2021 Fix bug
3233
*************************************************************************************************************************************/
3334

3435
#pragma once
@@ -57,13 +58,13 @@
5758

5859
#endif
5960

60-
#define ETHERNET_WEBSERVER_STM32_VERSION "EthernetWebServer_STM32 v1.3.0"
61+
#define ETHERNET_WEBSERVER_STM32_VERSION "EthernetWebServer_STM32 v1.3.1"
6162

6263
#define ETHERNET_WEBSERVER_STM32_VERSION_MAJOR 1
6364
#define ETHERNET_WEBSERVER_STM32_VERSION_MINOR 3
64-
#define ETHERNET_WEBSERVER_STM32_VERSION_PATCH 0
65+
#define ETHERNET_WEBSERVER_STM32_VERSION_PATCH 1
6566

66-
#define ETHERNET_WEBSERVER_STM32_VERSION_INT 1003000
67+
#define ETHERNET_WEBSERVER_STM32_VERSION_INT 1003001
6768

6869
#define USE_NEW_WEBSERVER_VERSION true
6970

src/Ethernet_HTTPClient/Ethernet_HttpClient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@file Esp8266WebServer.h
1313
@author Ivan Grokhotkov
1414
15-
Version: 1.3.0
15+
Version: 1.3.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
@@ -29,6 +29,7 @@
2929
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3030
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
3131
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
32+
1.3.1 K Hoang 25/12/2021 Fix bug
3233
*************************************************************************************************************************************/
3334

3435
// Class to simplify HTTP fetching on Arduino

src/Ethernet_HTTPClient/Ethernet_HttpClient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@file Esp8266WebServer.h
1313
@author Ivan Grokhotkov
1414
15-
Version: 1.3.0
15+
Version: 1.3.1
1616
1717
Version Modified By Date Comments
1818
------- ----------- ---------- -----------
@@ -29,6 +29,7 @@
2929
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3030
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
3131
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
32+
1.3.1 K Hoang 25/12/2021 Fix bug
3233
*************************************************************************************************************************************/
3334

3435
// Class to simplify HTTP fetching on Arduino

0 commit comments

Comments
 (0)