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

Commit 7a236a3

Browse files
authored
v1.5.1 to fix String-related bug
### Releases v1.5.1 1. Fix bug related to String in library and examples
1 parent f02de3b commit 7a236a3

28 files changed

+149
-80
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. Arduino SAMDUE core v1.6.12, ArduinoCore-mbed v2.6.1, 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
RASPBERRY_PI_PICO board
3131
ArduinoCore-mbed v2.6.1
3232
OS: Ubuntu 20.04 LTS

README.md

Lines changed: 85 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ The ESP8266_AT_Web_Server class found in `ESP8266_AT_Web_Server.h` header, is a
178178

179179
## Prerequisites
180180

181-
1. [`Arduino IDE 1.8.18+` for Arduino](https://www.arduino.cc/en/Main/Software)
181+
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)
182182
2. [`Arduino AVR core 1.8.3+`](https://github.com/arduino/ArduinoCore-avr) for Arduino (Use Arduino Board Manager) for AVR boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-avr.svg)](https://github.com/arduino/ArduinoCore-avr/releases/latest)
183183
3. [`Teensy core v1.55+`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards.
184184
4. [`Arduino SAM DUE core v1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards.
@@ -188,7 +188,7 @@ The ESP8266_AT_Web_Server class found in `ESP8266_AT_Web_Server.h` header, is a
188188
8. [`Adafruit nRF52 v1.2.0+`](https://www.adafruit.com) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest). Please remember to use latest [`Packages_Patches`](https://github.com/khoih-prog/WiFiWebServer/tree/master/Packages_Patches) or getting compiler errors.
189189
9. [`Arduino Core for STM32 v2.2.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32F/L/H/G/WB/MP1 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
190190
10. [`Arduino mbed_rp2040 core 2.6.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest)
191-
11. [`Earle Philhower's arduino-pico core v1.9.8+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest)
191+
11. [`Earle Philhower's arduino-pico core v1.9.9+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest)
192192
12. [`Sipeed Maixduino core v0.3.11+`](https://github.com/sipeed/Maixduino) for K210-RISC-V-based boards such as **Maixduino AI Development Kit K210 RISC-V AI + IoT ESP32, Sipeed Maix Go, Sipeed Maix Bit**, etc. [![GitHub release](https://img.shields.io/github/release/sipeed/Maixduino.svg)](https://github.com/sipeed/Maixduino/releases/latest)
193193
13. [`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)
194194
14. [`Ai-Thinker AT Firmware v1.5.4`](AT_Firmwares/At_firmware_bin1.54.zip) or [`AT Firmware v1.7.4.0`](AT_Firmwares/AT_Firmware_bin_1.7.4.0.zip) for ESP8266-AT shields.
@@ -334,14 +334,14 @@ These files must be copied into the directory:
334334
335335
#### 2. For Teensy boards
336336
337-
**To be able to compile and run on Teensy boards**, you have to copy the files in [**Packages_Patches for Teensy directory**](Packages_Patches/hardware/teensy/avr) into Teensy hardware directory (./arduino-1.8.18/hardware/teensy/avr/boards.txt).
337+
**To be able to compile and run on Teensy boards**, you have to copy the files in [**Packages_Patches for Teensy directory**](Packages_Patches/hardware/teensy/avr) into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt).
338338
339-
Supposing the Arduino version is 1.8.18. These files must be copied into the directory:
339+
Supposing the Arduino version is 1.8.19. These files must be copied into the directory:
340340
341-
- `./arduino-1.8.18/hardware/teensy/avr/boards.txt`
342-
- `./arduino-1.8.18/hardware/teensy/avr/cores/teensy/Stream.h`
343-
- `./arduino-1.8.18/hardware/teensy/avr/cores/teensy3/Stream.h`
344-
- `./arduino-1.8.18/hardware/teensy/avr/cores/teensy4/Stream.h`
341+
- `./arduino-1.8.19/hardware/teensy/avr/boards.txt`
342+
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h`
343+
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h`
344+
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h`
345345
346346
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
347347
These files must be copied into the directory:
@@ -777,7 +777,7 @@ const int led = 13;
777777

778778
void handleRoot()
779779
{
780-
#define BUFFER_SIZE 500
780+
#define BUFFER_SIZE 512
781781

782782
digitalWrite(led, 1);
783783
char temp[BUFFER_SIZE];
@@ -834,22 +834,27 @@ void handleNotFound()
834834
digitalWrite(led, 0);
835835
}
836836

837-
#if (defined(ESP8266_AT_WEBSERVER_VERSION_INT) && (ESP8266_AT_WEBSERVER_VERSION_INT >= 1005000) && !ESP_AT_USE_AVR)
838-
#warning Using EWString
837+
#if 1
839838

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

844841
void drawGraph()
845842
{
846-
EWString out;
847-
848-
out.reserve(3000);
843+
static String out;
844+
static uint16_t previousStrLen = ORIGINAL_STR_LEN;
845+
846+
if (out.length() == 0)
847+
{
848+
AT_LOGWARN1(F("String Len = 0, extend to"), ORIGINAL_STR_LEN);
849+
out.reserve(ORIGINAL_STR_LEN);
850+
}
851+
852+
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n" \
853+
"<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
854+
"<g stroke=\"blue\">\n");
855+
849856
char temp[70];
850857

851-
out += initHeader;
852-
853858
int y = rand() % 130;
854859

855860
for (int x = 10; x < 300; x += 10)
@@ -859,38 +864,77 @@ void drawGraph()
859864
out += temp;
860865
y = y2;
861866
}
862-
out += "</g>\n</svg>\n";
867+
868+
out += F("</g>\n</svg>\n");
869+
870+
AT_LOGDEBUG1(F("String Len = "), out.length());
863871

864-
server.send(200, "image/svg+xml", fromEWString(out));
872+
if (out.length() > previousStrLen)
873+
{
874+
AT_LOGERROR3(F("String Len > "), previousStrLen, F(", extend to"), out.length() + 48);
875+
876+
previousStrLen = out.length() + 48;
877+
878+
out.reserve(previousStrLen);
879+
}
880+
else
881+
{
882+
server.send(200, "image/svg+xml", out);
883+
}
865884
}
866885

867886
#else
868887

888+
#define ORIGINAL_STR_LEN 1280
889+
869890
void drawGraph()
870891
{
871-
String out;
872-
out.reserve(3000);
892+
static String out;
893+
static uint16_t previousStrLen = ORIGINAL_STR_LEN;
894+
895+
if (out.length() == 0)
896+
{
897+
AT_LOGWARN1(F("String Len = 0, extend to"), ORIGINAL_STR_LEN);
898+
out.reserve(ORIGINAL_STR_LEN);
899+
}
900+
901+
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"160\" height=\"80\">\n" \
902+
"<rect width=\"1600\" height=\"800\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
903+
"<g stroke=\"blue\">\n");
904+
873905
char temp[70];
874-
out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n";
875-
out += "<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n";
876-
out += "<g stroke=\"black\">\n";
877-
int y = rand() % 130;
906+
907+
int y = rand() % 60;
878908

879-
for (int x = 10; x < 300; x += 10)
909+
for (int x = 10; x < 150; x += 10)
880910
{
881-
int y2 = rand() % 130;
882-
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 140 - y, x + 10, 140 - y2);
911+
int y2 = rand() % 60;
912+
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 70 - y, x + 10, 70 - y2);
883913
out += temp;
884914
y = y2;
885915
}
886-
out += "</g>\n</svg>\n";
916+
917+
out += F("</g>\n</svg>\n");
918+
919+
AT_LOGDEBUG1(F("String Len = "), out.length());
920+
921+
if (out.length() > previousStrLen)
922+
{
923+
AT_LOGERROR3(F("String Len > "), previousStrLen, F(", extend to"), out.length() + 48);
887924

888-
server.send(200, "image/svg+xml", out);
925+
previousStrLen = out.length() + 48;
926+
927+
out.reserve(previousStrLen);
928+
}
929+
else
930+
{
931+
server.send(200, "image/svg+xml", out);
932+
}
889933
}
890934

891935
#endif
892936

893-
void setup(void)
937+
void setup()
894938
{
895939
pinMode(led, OUTPUT);
896940
digitalWrite(led, 0);
@@ -992,7 +1036,7 @@ void loop()
9921036
#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial
9931037
9941038
// Debug Level from 0 to 4
995-
#define _ESP_AT_LOGLEVEL_ 0
1039+
#define _ESP_AT_LOGLEVEL_ 2
9961040
9971041
// Uncomment to use ESP32-AT commands
9981042
//#define USE_ESP32_AT true
@@ -1380,7 +1424,7 @@ The following are debug terminal output when running example [AdvancedWebServer]
13801424

13811425
```
13821426
Starting AdvancedWebServer on NRF52840_ITSYBITSY_EXPRESS
1383-
ESP8266_AT_WebServer v1.5.0
1427+
ESP8266_AT_WebServer v1.5.1
13841428
[ESP_AT] Initializing ESP module
13851429
[ESP_AT] Use ES8266-AT Command
13861430
WiFi shield init done
@@ -1509,7 +1553,7 @@ The following are debug terminal output when running example [MQTT_ThingStream](
15091553

15101554
```
15111555
Start MQTT_ThingStream on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
1512-
ESP8266_AT_WebServer v1.5.0
1556+
ESP8266_AT_WebServer v1.5.1
15131557
[ESP_AT] Use ES8266-AT Command
15141558
WiFi shield init done
15151559
Connecting to SSID: HueNet1
@@ -1544,7 +1588,7 @@ The following are debug terminal output when running example [MQTTClient_Auth](e
15441588

15451589
```
15461590
Starting MQTTClient_Auth on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
1547-
ESP8266_AT_WebServer v1.5.0
1591+
ESP8266_AT_WebServer v1.5.1
15481592
[ESP_AT] Use ES8266-AT Command
15491593
WiFi shield init done
15501594
Connecting to SSID: HueNet1
@@ -1570,7 +1614,7 @@ The following are debug terminal output when running example [MQTTClient_Basic](
15701614

15711615
```
15721616
MQTTClient_Basic on ITSYBITSY_M4 with ESP8266-AT & ESP8266_AT_WebServer Library
1573-
ESP8266_AT_WebServer v1.5.0
1617+
ESP8266_AT_WebServer v1.5.1
15741618
[ESP_AT] Use ES8266-AT Command
15751619
WiFi shield init done
15761620
Connecting to SSID: HueNet1
@@ -1595,7 +1639,7 @@ The following are debug terminal output when running example [WebClientRepeating
15951639

15961640
```
15971641
Starting WebClientRepeating on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
1598-
ESP8266_AT_WebServer v1.5.0
1642+
ESP8266_AT_WebServer v1.5.1
15991643
[ESP_AT] Use ES8266-AT Command
16001644
WiFi shield init done
16011645
Connecting to SSID: HueNet1
@@ -1664,7 +1708,7 @@ The following are debug terminal output when running example [MQTTClient_Auth](e
16641708

16651709
```
16661710
Starting MQTTClient_Auth on RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
1667-
ESP8266_AT_WebServer v1.5.0
1711+
ESP8266_AT_WebServer v1.5.1
16681712
[ESP_AT] Use ES8266-AT Command
16691713
WiFi shield init done
16701714
Connecting to SSID: HueNet1
@@ -1689,7 +1733,7 @@ The following are debug terminal output when running example [UdpNTPClient](exam
16891733

16901734
```
16911735
Starting UdpNTPClient on MBED RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
1692-
ESP8266_AT_WebServer v1.5.0
1736+
ESP8266_AT_WebServer v1.5.1
16931737
[ESP_AT] Use ES8266-AT Command
16941738
WiFi shield init done
16951739
Connecting to WPA SSID: HueNet1

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.5.1](#releases-v151)
1516
* [Releases v1.5.0](#releases-v150)
1617
* [Releases v1.4.1](#releases-v141)
1718
* [Releases v1.4.0](#releases-v140)
@@ -37,6 +38,10 @@
3738

3839
## Changelog
3940

41+
### Releases v1.5.1
42+
43+
1. Fix bug related to String in library and examples
44+
4045
### Releases v1.5.0
4146

4247
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": "ESP8266_AT_WebServer",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"keywords": "wifi, WebServer, server, AT-command, wifi-shield, ESP8266, ESP32, Teensy, AVR, SAM-DUE, SAMD, Maixduino, STM32, nRF52, ESP8266-AT, ESP32-AT, rpi-pico, rp2040, mbed, Maixduino-AI",
55
"description": "Simple WebServer library for AVR, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52, SIPEED_MAIX_DUINO and RP2040-based (RASPBERRY_PI_PICO) boards using ESP8266/ESP32 AT-command 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=ESP8266_AT_WebServer
2-
version=1.5.0
2+
version=1.5.1
33
author=Khoi Hoang
44
license=MIT
55
maintainer=Khoi Hoang <[email protected]>

src/ESP8266_AT-impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@file Esp8266WebServer.h
1212
@author Ivan Grokhotkov
1313
14-
Version: 1.5.0
14+
Version: 1.5.1
1515
1616
Version Modified By Date Comments
1717
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
3737
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
3838
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
3939
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
40+
1.5.1 K Hoang 24/12/2021 Fix bug
4041
*****************************************************************************************************************************/
4142

4243
#ifndef ESP8266_AT_impl_h

src/ESP8266_AT.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@file Esp8266WebServer.h
1212
@author Ivan Grokhotkov
1313
14-
Version: 1.5.0
14+
Version: 1.5.1
1515
1616
Version Modified By Date Comments
1717
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
3737
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
3838
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
3939
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
40+
1.5.1 K Hoang 24/12/2021 Fix bug
4041
*****************************************************************************************************************************/
4142

4243
#ifndef ESP8266_AT_h

src/ESP8266_AT_Client-impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@file Esp8266WebServer.h
1212
@author Ivan Grokhotkov
1313
14-
Version: 1.5.0
14+
Version: 1.5.1
1515
1616
Version Modified By Date Comments
1717
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
3737
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
3838
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
3939
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
40+
1.5.1 K Hoang 24/12/2021 Fix bug
4041
*****************************************************************************************************************************/
4142

4243
#ifndef ESP8266_AT_Client_impl_h

src/ESP8266_AT_Client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@file Esp8266WebServer.h
1212
@author Ivan Grokhotkov
1313
14-
Version: 1.5.0
14+
Version: 1.5.1
1515
1616
Version Modified By Date Comments
1717
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
3737
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
3838
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
3939
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
40+
1.5.1 K Hoang 24/12/2021 Fix bug
4041
*****************************************************************************************************************************/
4142

4243
#ifndef ESP8266_AT_Client_h

src/ESP8266_AT_Server-impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@file Esp8266WebServer.h
1212
@author Ivan Grokhotkov
1313
14-
Version: 1.5.0
14+
Version: 1.5.1
1515
1616
Version Modified By Date Comments
1717
------- ----------- ---------- -----------
@@ -37,6 +37,7 @@
3737
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
3838
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
3939
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
40+
1.5.1 K Hoang 24/12/2021 Fix bug
4041
*****************************************************************************************************************************/
4142
#ifndef ESP8266_AT_Server_impl_h
4243
#define ESP8266_AT_Server_impl_h

0 commit comments

Comments
 (0)