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

Commit

Permalink
v1.3.1 to fix String-related bug
Browse files Browse the repository at this point in the history
### Releases v1.3.1

1. Fix bug related to String in examples
  • Loading branch information
khoih-prog authored Dec 25, 2021
1 parent 9e939da commit 46242ff
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 86 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p

Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.18) or Platform.io version
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* Board Core Version (e.g. STM32F7 Nucleo-144 NUCLEO_F767ZI, STM32 core v2.2.0, etc.)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
Expand All @@ -26,7 +26,7 @@ Please ensure to specify the following:
### Example

```
Arduino IDE version: 1.8.18
Arduino IDE version: 1.8.19
STM32F7 Nucleo-144 NUCLEO_F767ZI, STM32 core v2.2.0
OS: Ubuntu 20.04 LTS
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
Expand Down
92 changes: 42 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ Check [`EthernetWebServer Library Issue: Support for STM32F Series`](https://git

## Prerequisites

1. [`Arduino IDE 1.8.18+` for Arduino](https://www.arduino.cc/en/Main/Software)
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. [`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)
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)
4. For built-in LAN8742A or LAN8720 Ethernet:
Expand Down Expand Up @@ -979,7 +979,7 @@ void handleRoot()
{
digitalWrite(led, 1);

#define BUFFER_SIZE 400
#define BUFFER_SIZE 512

char temp[BUFFER_SIZE];
int sec = millis() / 1000;
Expand Down Expand Up @@ -1032,21 +1032,25 @@ void handleNotFound()
digitalWrite(led, 0);
}

#if (defined(ETHERNET_WEBSERVER_STM32_VERSION_INT) && (ETHERNET_WEBSERVER_STM32_VERSION_INT >= 1003000))

EWString initHeader = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n" \
"<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
"<g stroke=\"blue\">\n";
#define ORIGINAL_STR_LEN 2048

void drawGraph()
{
EWString out;

out.reserve(3000);
static String out;
static uint16_t previousStrLen = ORIGINAL_STR_LEN;

if (out.length() == 0)
{
ET_LOGWARN1(F("String Len = 0, extend to"), ORIGINAL_STR_LEN);
out.reserve(ORIGINAL_STR_LEN);
}

out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n" \
"<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
"<g stroke=\"blue\">\n");

char temp[70];

out += initHeader;

int y = rand() % 130;

for (int x = 10; x < 300; x += 10)
Expand All @@ -1056,37 +1060,25 @@ void drawGraph()
out += temp;
y = y2;
}
out += "</g>\n</svg>\n";

out += F("</g>\n</svg>\n");

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

#else

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

for (int x = 10; x < 300; x += 10)
previousStrLen = out.length() + 48;

out.reserve(previousStrLen);
}
else
{
int y2 = rand() % 130;
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);
out += temp;
y = y2;
server.send(200, "image/svg+xml", out);
}
out += "</g>\n</svg>\n";

server.send(200, "image/svg+xml", out);
}

#endif

void setup()
{
pinMode(led, OUTPUT);
Expand Down Expand Up @@ -1375,7 +1367,7 @@ Following is debug terminal output and screen shot when running example [Advance

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

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

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

```
Starting SimpleWebSocket on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
EthernetWebServer_STM32 v1.3.0
EthernetWebServer_STM32 v1.3.1
[ETHERNET_WEBSERVER] =========================
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
Expand Down Expand Up @@ -1643,7 +1635,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with W5x00 & Ethernet3

```
Starting SimpleWebSocket on NUCLEO_F767ZI with W5x00 & Ethernet3 Library
EthernetWebServer_STM32 v1.3.0
EthernetWebServer_STM32 v1.3.1
[ETHERNET_WEBSERVER] =========== USE_ETHERNET3 ===========
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
Expand Down Expand Up @@ -1695,7 +1687,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet

```
Starting SimpleHTTPExample on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
EthernetWebServer_STM32 v1.3.0
EthernetWebServer_STM32 v1.3.1
[ETHERNET_WEBSERVER] =========================
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
Expand Down Expand Up @@ -1768,7 +1760,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with LAN8742A Ethernet

```
Start MQTTClient_Auth on NUCLEO_F767ZI with LAN8742A Ethernet & STM32Ethernet Library
EthernetWebServer_STM32 v1.3.0
EthernetWebServer_STM32 v1.3.1
[ETHERNET_WEBSERVER] =========================
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
Expand Down Expand Up @@ -1807,7 +1799,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with ENC28J60 & Ethern

```
Start MQTTClient_Auth on NUCLEO_F767ZI with ENC28J60 & EthernetENC Library
EthernetWebServer_STM32 v1.3.0
EthernetWebServer_STM32 v1.3.1
[ETHERNET_WEBSERVER] =========== USE_ETHERNET_ENC ===========
[ETHERNET_WEBSERVER] Default SPI pinout:
[ETHERNET_WEBSERVER] MOSI: 11
Expand Down Expand Up @@ -1846,7 +1838,7 @@ The terminal output of **STM32F7 Nucleo-144 NUCLEO_F767ZI with W5x00 & Ethernet2

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

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

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

```
Start AdvancedWebServer_LAN8720 on BLACK_F407VE, using LAN8720 Ethernet & STM32Ethernet Library
EthernetWebServer_STM32 v1.3.0
HTTP EthernetWebServer is @ IP : 192.168.2.138
EthernetWebServer_STM32 v1.3.1
.[EWS] String Len = 0, extend to 2048
......... .......... .......... .......... .......... .......... .......... ..........
```

---
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v1.3.1](#releases-v131)
* [Major Releases v1.3.0](#major-releases-v130)
* [Releases v1.2.1](#releases-v121)
* [Releases v1.2.0](#releases-v120)
Expand All @@ -29,6 +30,10 @@

## Changelog

### Releases v1.3.1

1. Fix bug related to String in examples

### Major Releases v1.3.0

1. Reduce usage of Arduino String with std::string
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "EthernetWebServer_STM32",
"version": "1.3.0",
"version": "1.3.1",
"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",
"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",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=EthernetWebServer_STM32
version=1.3.0
version=1.3.1
author=Khoi Hoang
license=MIT
maintainer=Khoi Hoang <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion src/EthernetHttpClient_STM32.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.3.0
Version: 1.3.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -29,6 +29,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
1.3.1 K Hoang 25/12/2021 Fix bug
*************************************************************************************************************************************/

// Library to simplify HTTP fetching on Arduino
Expand Down
12 changes: 2 additions & 10 deletions src/EthernetWebServer_STM32-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.3.0
Version: 1.3.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -29,6 +29,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
1.3.1 K Hoang 25/12/2021 Fix bug
*************************************************************************************************************************************/

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

_responseHeaders = String();

//MR & KH fix
//_responseHeaders = *(new String());
}

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

_responseHeaders = String();

//MR & KH fix
//_responseHeaders = *(new String());
}

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

_currentUri = String();

//MR & KH fix
//_currentUri = *(new String());
}

void EthernetWebServer::_finalizeResponse()
Expand Down
9 changes: 5 additions & 4 deletions src/EthernetWebServer_STM32.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.3.0
Version: 1.3.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -29,6 +29,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
1.3.1 K Hoang 25/12/2021 Fix bug
*************************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -57,13 +58,13 @@

#endif

#define ETHERNET_WEBSERVER_STM32_VERSION "EthernetWebServer_STM32 v1.3.0"
#define ETHERNET_WEBSERVER_STM32_VERSION "EthernetWebServer_STM32 v1.3.1"

#define ETHERNET_WEBSERVER_STM32_VERSION_MAJOR 1
#define ETHERNET_WEBSERVER_STM32_VERSION_MINOR 3
#define ETHERNET_WEBSERVER_STM32_VERSION_PATCH 0
#define ETHERNET_WEBSERVER_STM32_VERSION_PATCH 1

#define ETHERNET_WEBSERVER_STM32_VERSION_INT 1003000
#define ETHERNET_WEBSERVER_STM32_VERSION_INT 1003001

#define USE_NEW_WEBSERVER_VERSION true

Expand Down
3 changes: 2 additions & 1 deletion src/Ethernet_HTTPClient/Ethernet_HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.3.0
Version: 1.3.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -29,6 +29,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
1.3.1 K Hoang 25/12/2021 Fix bug
*************************************************************************************************************************************/

// Class to simplify HTTP fetching on Arduino
Expand Down
3 changes: 2 additions & 1 deletion src/Ethernet_HTTPClient/Ethernet_HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.3.0
Version: 1.3.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -29,6 +29,7 @@
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
1.2.1 K Hoang 04/10/2021 Change option for PIO `lib_compat_mode` from default `soft` to `strict`. Update Packages Patches
1.3.0 K Hoang 20/12/2021 Reduce usage of Arduino String with std::string. Use reference passing instead of value-passing
1.3.1 K Hoang 25/12/2021 Fix bug
*************************************************************************************************************************************/

// Class to simplify HTTP fetching on Arduino
Expand Down
Loading

0 comments on commit 46242ff

Please sign in to comment.