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

Commit

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

1. Fix bug related to String in library and examples
  • Loading branch information
khoih-prog authored Dec 26, 2021
1 parent f02de3b commit 7a236a3
Show file tree
Hide file tree
Showing 28 changed files with 149 additions and 80 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. Arduino SAMDUE core v1.6.12, ArduinoCore-mbed v2.6.1, 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
RASPBERRY_PI_PICO board
ArduinoCore-mbed v2.6.1
OS: Ubuntu 20.04 LTS
Expand Down
126 changes: 85 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ The ESP8266_AT_Web_Server class found in `ESP8266_AT_Web_Server.h` header, is a

## 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 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)
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.
4. [`Arduino SAM DUE core v1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards.
Expand All @@ -188,7 +188,7 @@ The ESP8266_AT_Web_Server class found in `ESP8266_AT_Web_Server.h` header, is a
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.
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)
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)
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)
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)
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)
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)
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.
Expand Down Expand Up @@ -334,14 +334,14 @@ These files must be copied into the directory:
#### 2. For Teensy boards
**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).
**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).
Supposing the Arduino version is 1.8.18. These files must be copied into the directory:
Supposing the Arduino version is 1.8.19. These files must be copied into the directory:
- `./arduino-1.8.18/hardware/teensy/avr/boards.txt`
- `./arduino-1.8.18/hardware/teensy/avr/cores/teensy/Stream.h`
- `./arduino-1.8.18/hardware/teensy/avr/cores/teensy3/Stream.h`
- `./arduino-1.8.18/hardware/teensy/avr/cores/teensy4/Stream.h`
- `./arduino-1.8.19/hardware/teensy/avr/boards.txt`
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h`
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h`
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h`
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
These files must be copied into the directory:
Expand Down Expand Up @@ -777,7 +777,7 @@ const int led = 13;

void handleRoot()
{
#define BUFFER_SIZE 500
#define BUFFER_SIZE 512

digitalWrite(led, 1);
char temp[BUFFER_SIZE];
Expand Down Expand Up @@ -834,22 +834,27 @@ void handleNotFound()
digitalWrite(led, 0);
}

#if (defined(ESP8266_AT_WEBSERVER_VERSION_INT) && (ESP8266_AT_WEBSERVER_VERSION_INT >= 1005000) && !ESP_AT_USE_AVR)
#warning Using EWString
#if 1

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)
{
AT_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 @@ -859,38 +864,77 @@ void drawGraph()
out += temp;
y = y2;
}
out += "</g>\n</svg>\n";

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

AT_LOGDEBUG1(F("String Len = "), out.length());

server.send(200, "image/svg+xml", fromEWString(out));
if (out.length() > previousStrLen)
{
AT_LOGERROR3(F("String Len > "), previousStrLen, F(", extend to"), out.length() + 48);

previousStrLen = out.length() + 48;

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

#else

#define ORIGINAL_STR_LEN 1280

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

if (out.length() == 0)
{
AT_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=\"160\" height=\"80\">\n" \
"<rect width=\"1600\" height=\"800\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
"<g stroke=\"blue\">\n");

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=\"3\" stroke=\"rgb(0, 0, 0)\" />\n";
out += "<g stroke=\"black\">\n";
int y = rand() % 130;

int y = rand() % 60;

for (int x = 10; x < 300; x += 10)
for (int x = 10; x < 150; x += 10)
{
int y2 = rand() % 130;
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 140 - y, x + 10, 140 - y2);
int y2 = rand() % 60;
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 70 - y, x + 10, 70 - y2);
out += temp;
y = y2;
}
out += "</g>\n</svg>\n";

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

AT_LOGDEBUG1(F("String Len = "), out.length());

if (out.length() > previousStrLen)
{
AT_LOGERROR3(F("String Len > "), previousStrLen, F(", extend to"), out.length() + 48);

server.send(200, "image/svg+xml", out);
previousStrLen = out.length() + 48;

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

#endif

void setup(void)
void setup()
{
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Expand Down Expand Up @@ -992,7 +1036,7 @@ void loop()
#define DEBUG_ESP8266_AT_WEBSERVER_PORT Serial
// Debug Level from 0 to 4
#define _ESP_AT_LOGLEVEL_ 0
#define _ESP_AT_LOGLEVEL_ 2
// Uncomment to use ESP32-AT commands
//#define USE_ESP32_AT true
Expand Down Expand Up @@ -1380,7 +1424,7 @@ The following are debug terminal output when running example [AdvancedWebServer]

```
Starting AdvancedWebServer on NRF52840_ITSYBITSY_EXPRESS
ESP8266_AT_WebServer v1.5.0
ESP8266_AT_WebServer v1.5.1
[ESP_AT] Initializing ESP module
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Expand Down Expand Up @@ -1509,7 +1553,7 @@ The following are debug terminal output when running example [MQTT_ThingStream](

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

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

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

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

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

```
Starting UdpNTPClient on MBED RASPBERRY_PI_PICO with ESP8266-AT & ESP8266_AT_WebServer Library
ESP8266_AT_WebServer v1.5.0
ESP8266_AT_WebServer v1.5.1
[ESP_AT] Use ES8266-AT Command
WiFi shield init done
Connecting to WPA SSID: HueNet1
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.5.1](#releases-v151)
* [Releases v1.5.0](#releases-v150)
* [Releases v1.4.1](#releases-v141)
* [Releases v1.4.0](#releases-v140)
Expand All @@ -37,6 +38,10 @@

## Changelog

### Releases v1.5.1

1. Fix bug related to String in library and examples

### Releases v1.5.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": "ESP8266_AT_WebServer",
"version": "1.5.0",
"version": "1.5.1",
"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",
"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",
"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=ESP8266_AT_WebServer
version=1.5.0
version=1.5.1
author=Khoi Hoang
license=MIT
maintainer=Khoi Hoang <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion src/ESP8266_AT-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.5.0
Version: 1.5.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -37,6 +37,7 @@
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
1.5.1 K Hoang 24/12/2021 Fix bug
*****************************************************************************************************************************/

#ifndef ESP8266_AT_impl_h
Expand Down
3 changes: 2 additions & 1 deletion src/ESP8266_AT.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.5.0
Version: 1.5.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -37,6 +37,7 @@
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
1.5.1 K Hoang 24/12/2021 Fix bug
*****************************************************************************************************************************/

#ifndef ESP8266_AT_h
Expand Down
3 changes: 2 additions & 1 deletion src/ESP8266_AT_Client-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.5.0
Version: 1.5.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -37,6 +37,7 @@
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
1.5.1 K Hoang 24/12/2021 Fix bug
*****************************************************************************************************************************/

#ifndef ESP8266_AT_Client_impl_h
Expand Down
3 changes: 2 additions & 1 deletion src/ESP8266_AT_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.5.0
Version: 1.5.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -37,6 +37,7 @@
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
1.5.1 K Hoang 24/12/2021 Fix bug
*****************************************************************************************************************************/

#ifndef ESP8266_AT_Client_h
Expand Down
3 changes: 2 additions & 1 deletion src/ESP8266_AT_Server-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@file Esp8266WebServer.h
@author Ivan Grokhotkov
Version: 1.5.0
Version: 1.5.1
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -37,6 +37,7 @@
1.4.0 K Hoang 14/08/2021 Add support to Adafruit nRF52 core v0.22.0+
1.4.1 K Hoang 08/12/2021 Add Packages_Patches and instructions for BOARD_SIPEED_MAIX_DUINO
1.5.0 K Hoang 19/12/2021 Reduce usage of Arduino String with std::string
1.5.1 K Hoang 24/12/2021 Fix bug
*****************************************************************************************************************************/
#ifndef ESP8266_AT_Server_impl_h
#define ESP8266_AT_Server_impl_h
Expand Down
Loading

0 comments on commit 7a236a3

Please sign in to comment.