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

Commit

Permalink
v1.5.0 to reduce String usage
Browse files Browse the repository at this point in the history
### Releases v1.5.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`
  • Loading branch information
khoih-prog authored Dec 22, 2021
1 parent c0dde6a commit 5acbdc2
Show file tree
Hide file tree
Showing 39 changed files with 538 additions and 191 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ 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.16) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.1 or STM32 v2.1.0)
* Arduino IDE version (e.g. 1.8.18) 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
* Anything that might be relevant in your opinion, such as:
Expand All @@ -26,9 +26,9 @@ Please ensure to specify the following:
### Example

```
Arduino IDE version: 1.8.16
Arduino-mbed RP2040 v2.6.1
NANO_RP2040_CONNECT Module
Arduino IDE version: 1.8.18
RASPBERRY_PI_PICO board
ArduinoCore-mbed v2.6.1
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
148 changes: 111 additions & 37 deletions README.md

Large diffs are not rendered by default.

8 changes: 8 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.0](#releases-v150)
* [Releases v1.4.1](#releases-v141)
* [Releases v1.4.0](#releases-v140)
* [Releases v1.3.0](#releases-v130)
Expand All @@ -36,6 +37,13 @@

## Changelog

### Releases v1.5.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`


### Releases v1.4.1

1. Add instructions for SIPEED_MAIX_DUINO
Expand Down
84 changes: 74 additions & 10 deletions examples/AdvancedWebServer/AdvancedWebServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,63 @@ 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

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";

void drawGraph()
{
String out;
EWString out;

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

out += initHeader;

int y = rand() % 130;

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

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

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

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

for (int x = 10; x < 300; 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);
out += temp;
y = y2;
}
out += "</g>\n</svg>\n";

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

void setup(void)
#endif

void setup()
{
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Expand Down Expand Up @@ -204,7 +236,39 @@ void setup(void)
Serial.println(WEBSERVER_PORT);
}

void loop(void)
void heartBeatPrint()
{
static int num = 1;

Serial.print(F("."));

if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}

void check_status()
{
static unsigned long checkstatus_timeout = 0;

#define STATUS_CHECK_INTERVAL 10000L

// Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
{
heartBeatPrint();
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
}
}

void loop()
{
server.handleClient();
check_status();
}
4 changes: 2 additions & 2 deletions examples/AdvancedWebServer/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@

#include <ESP8266_AT_WebServer.h>

char ssid[] = "****"; // your network SSID (name)
char pass[] = "****"; // your network password
char ssid[] = "YOUR_SSID"; // your network SSID (name)
char pass[] = "12345678"; // your network password

#endif //defines_h
4 changes: 2 additions & 2 deletions examples/AdvancedWebServer_STM32/AdvancedWebServer_STM32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void drawGraph()
server.send(200, F("image/svg+xml"), out);
}

void setup(void)
void setup()
{
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Expand Down Expand Up @@ -200,7 +200,7 @@ void setup(void)
Serial.println(WiFi.localIP());
}

void loop(void)
void loop()
{
server.handleClient();
}
4 changes: 2 additions & 2 deletions examples/HelloServer/HelloServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void handleNotFound()
digitalWrite(led, 0);
}

void setup(void)
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
Expand Down Expand Up @@ -154,7 +154,7 @@ void setup(void)
Serial.println(WiFi.localIP());
}

void loop(void)
void loop()
{
server.handleClient();
}
4 changes: 2 additions & 2 deletions examples/HelloServer2/HelloServer2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void handleNotFound()
digitalWrite(led, 0);
}

void setup(void)
void setup()
{
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Expand Down Expand Up @@ -175,7 +175,7 @@ void setup(void)
Serial.println(WiFi.localIP());
}

void loop(void)
void loop()
{
server.handleClient();
}
4 changes: 2 additions & 2 deletions examples/PostServer/PostServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void handleNotFound()
digitalWrite(led, 0);
}

void setup(void)
void setup()
{
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Expand Down Expand Up @@ -186,7 +186,7 @@ void setup(void)
Serial.println(WiFi.localIP());
}

void loop(void)
void loop()
{
server.handleClient();
}
4 changes: 2 additions & 2 deletions examples/SimpleAuthentication/SimpleAuthentication.ino
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void handleNotFound()
server.send(404, F("text/plain"), message);
}

void setup(void)
void setup()
{
Serial.begin(115200);

Expand Down Expand Up @@ -220,7 +220,7 @@ void setup(void)
Serial.println(WiFi.localIP());
}

void loop(void)
void loop()
{
server.handleClient();
}
2 changes: 1 addition & 1 deletion examples/WebClient/WebClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void setup()
httpRequest();
}

void printoutData(void)
void printoutData()
{
// if there are incoming bytes available
// from the server, read them and print them
Expand Down
3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ HTTPMethod KEYWORD1
HTTPUploadStatus KEYWORD1
HTTPClientStatus KEYWORD1
HTTPAuthMethod KEYWORD1
EWString KEYWORD1


HTTPUpload KEYWORD1
ESP8266_AT_Class KEYWORD1
WiFi KEYWORD1
Expand Down
6 changes: 3 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ESP8266_AT_WebServer",
"version": "1.4.1",
"keywords": "wifi, WebServer, AT-command, wifi-shield, ESP8266, ESP32, Teensy, AVR, SAM DUE, SAMD, Maixduino, STM32, nRF52, ESP8266-AT, ESP32-AT, rpi-pico, rp2040, nano-rp2040-connect, 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 (Nano RP2040 Connect, RASPBERRY_PI_PICO) boards using ESP8266/ESP32 AT-command shields",
"version": "1.5.0",
"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":
{
"name": "Khoi Hoang",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=ESP8266_AT_WebServer
version=1.4.1
version=1.5.0
author=Khoi Hoang
license=MIT
maintainer=Khoi Hoang <[email protected]>
sentence=Simple WebServer library for AVR, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52, SIPEED_MAIX_DUINO and RP2040-based (Nano RP2040 Connect, RASPBERRY_PI_PICO) boards using ESP8266/ESP32 AT-command shields with functions similar to those of ESP8266/ESP32 WebServer libraries
sentence=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 with functions similar to those of ESP8266/ESP32 WebServer libraries
paragraph=The library supports HTTP GET and POST requests, provides argument parsing, handles one client at a time.
category=Communication
url=https://github.com/khoih-prog/ESP8266_AT_WebServer
Expand Down
Binary file added pics/AdvancedWebServer_Mbed_RPi_Pico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
default_envs = SAMD
;default_envs = NRF52
;default_envs = STM32
;default_envs = pico
;default_envs = portenta_h7_m7
;default_envs = portenta_h7_m4

[env]
; ============================================================
Expand Down Expand Up @@ -336,6 +339,26 @@ framework = arduino
;board = coreboard_f401rc
;board = feather_f405

[env:portenta_h7_m7]
platform = ststm32
board = portenta_h7_m7
framework = arduino

[env:portenta_h7_m4]
platform = ststm32
board = portenta_h7_m4
framework = arduino

[env:pico]
; ============================================================
; Just a sample
; You have to research and fix if there is issue
; ============================================================
platform = raspberrypi
board = pico
framework = arduino
upload_protocol = picotool

; ============================================================
; Board configuration Many more Boards to be filled
; ============================================================
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.4.1
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -36,6 +36,7 @@
1.3.0 K Hoang 29/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using Arduino mbed code
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
*****************************************************************************************************************************/

#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.4.1
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -36,6 +36,7 @@
1.3.0 K Hoang 29/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using Arduino mbed code
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
*****************************************************************************************************************************/

#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.4.1
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -36,6 +36,7 @@
1.3.0 K Hoang 29/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using Arduino mbed code
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
*****************************************************************************************************************************/

#ifndef ESP8266_AT_Client_impl_h
Expand Down
Loading

0 comments on commit 5acbdc2

Please sign in to comment.