Skip to content

Commit

Permalink
Merge pull request #89 from ayushsharma82/dev
Browse files Browse the repository at this point in the history
v2.0.3
  • Loading branch information
ayushsharma82 authored Jun 28, 2024
2 parents 15de910 + 41c4e23 commit 1736f21
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 145 deletions.
31 changes: 22 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ jobs:
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/esphome-ESPAsyncTCP#v2.0.0

- name: Install ESPAsyncWebServer
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/ESPAsyncWebServer#v2.10.4
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/ESPAsyncWebServer#v3.0.2

- name: Build Demo
run: arduino-cli compile --library . --warnings none -b ${{ matrix.board }} "examples/Demo/Demo.ino"

- name: Build Demo_AP
run: arduino-cli compile --library . --warnings none -b ${{ matrix.board }} "examples/Demo_AP/Demo_AP.ino"

- name: Build Logging
run: arduino-cli compile --library . --warnings none -b ${{ matrix.board }} "examples/Logging/Logging.ino"

- name: Build HighPerf
run: arduino-cli compile --library . --warnings none -b ${{ matrix.board }} "examples/HighPerf/HighPerf.ino"

platformio:
name: pio ${{ matrix.name }}
runs-on: ubuntu-latest
Expand All @@ -82,31 +88,31 @@ jobs:
- name: esp32dev|arduino
board: esp32dev
platform: espressif32
opts:
opts: "--project-option 'lib_compat_mode = strict'"
- name: esp32dev|arduino-2
board: esp32dev
platform: [email protected]
opts:
opts: "--project-option 'lib_compat_mode = strict'"
- name: esp32dev|arduino-3
board: esp32dev
platform: espressif32
opts: "--project-option 'platform_packages=platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0, platform_packages=platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.0/esp32-arduino-libs-3.0.0.zip'"
opts: "--project-option 'lib_compat_mode = strict' --project-option 'platform_packages=platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2, platform_packages=platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip'"
- name: esp32-s3-devkitc-1|arduino
board: esp32-s3-devkitc-1
platform: espressif32
opts:
opts: "--project-option 'lib_compat_mode = strict'"
- name: esp32-s3-devkitc-1|arduino-2
board: esp32-s3-devkitc-1
platform: [email protected]
opts:
opts: "--project-option 'lib_compat_mode = strict'"
- name: esp32-s3-devkitc-1|arduino-3
board: esp32-s3-devkitc-1
platform: espressif32
opts: "--project-option 'platform_packages=platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0, platform_packages=platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.0/esp32-arduino-libs-3.0.0.zip'"
opts: "--project-option 'lib_compat_mode = strict' --project-option 'platform_packages=platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2, platform_packages=platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip'"
- name: huzzah|espressif8266
board: huzzah
platform: espressif8266
opts:
opts: "--project-option 'lib_compat_mode = strict'"
steps:
- uses: actions/checkout@v4
- name: Set up cache
Expand All @@ -123,4 +129,11 @@ jobs:
- run: platformio platform install ${{ matrix.platform }}

- run: platformio ci "examples/Demo/Demo.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: platformio ci "examples/Demo_AP/Demo_AP.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: platformio ci "examples/Demo_AP/Demo_AP.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: platformio ci "examples/Logging/Logging.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: platformio ci "examples/HighPerf/HighPerf.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}

- run: PLATFORMIO_BUILD_FLAGS="-DWSL_HIGH_PERF" platformio ci "examples/Demo/Demo.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: PLATFORMIO_BUILD_FLAGS="-DWSL_HIGH_PERF" platformio ci "examples/Demo_AP/Demo_AP.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: PLATFORMIO_BUILD_FLAGS="-DWSL_HIGH_PERF" platformio ci "examples/Logging/Logging.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
- run: PLATFORMIO_BUILD_FLAGS="-DWSL_HIGH_PERF" platformio ci "examples/HighPerf/HighPerf.ino" -l '.' -b ${{ matrix.board }} ${{ matrix.opts }}
2 changes: 1 addition & 1 deletion examples/Demo/Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void loop() {
WebSerial.print(F("IP address: "));
WebSerial.println(WiFi.localIP());
WebSerial.printf("Uptime: %lums\n", millis());
WebSerial.printf("Free heap: %u\n", ESP.getFreeHeap());
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
last_print_time = millis();
}

Expand Down
2 changes: 1 addition & 1 deletion examples/Demo_AP/Demo_AP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void loop() {
WebSerial.print(F("IP address: "));
WebSerial.println(WiFi.softAPIP());
WebSerial.printf("Uptime: %lums\n", millis());
WebSerial.printf("Free heap: %u\n", ESP.getFreeHeap());
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
last_print_time = millis();
}

Expand Down
69 changes: 69 additions & 0 deletions examples/HighPerf/HighPerf.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This example shows how to use WebSerial variant to send data to the browser when timing, speed and latency are important.
* WebSerial focuses on reducing latency and increasing speed by enqueueing messages and sending them in a single packet.
*
* The responsibility is left to the caller to ensure that the messages sent are not too large or not too small and frequent.
* For example, use of printf(), write(c), print(c), etc are not recommended.
*
* This variant can allow WebSerial to support a high speed of more than 20 messages per second like in this example.
*
* It can be used to log data, debug, or send data to the browser in real-time without any delay.
*
* You might want to look at the Logging variant to see how to better use WebSerial for streaming logging.
*
* You might want to control these flags to control the async library performance:
* -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
* -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
* -D WS_MAX_QUEUED_MESSAGES=128
*/
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#elif defined(ESP32)
#include <AsyncTCP.h>
#include <WiFi.h>
#endif
#include <DNSServer.h>
#include <ESPAsyncWebServer.h>
#include <WString.h>
#include <WebSerial.h>

AsyncWebServer server(80);

static const char* dict = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
static uint32_t last = millis();
static uint32_t count = 0;

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

WiFi.softAP("WSLDemo");
Serial.print("IP Address: ");
Serial.println(WiFi.softAPIP().toString());

WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
WebSerial.begin(&server);

server.onNotFound([](AsyncWebServerRequest* request) { request->redirect("/webserial"); });
server.begin();
}

void loop() {
if (millis() - last > 50) {
count++;
long r = random(10, 250) + 15;
String buffer;
buffer.reserve(r);
buffer += count;
while (buffer.length() < 10) {
buffer += " ";
}
buffer += "";
for (int i = 0; i < r; i++) {
buffer += dict[random(0, 62)];
}
WebSerial.print(buffer);
last = millis();
}
}
55 changes: 55 additions & 0 deletions examples/Logging/Logging.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This example shows how to use WebSerial variant to send logging data to the browser.
*
* Before using this example, make sure to look at the WebSerial example before and its description.\
*
* You might want to control these flags to control the async library performance:
* -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
* -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
* -D WS_MAX_QUEUED_MESSAGES=128
*/
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#elif defined(ESP32)
#include <AsyncTCP.h>
#include <WiFi.h>
#endif
#include <DNSServer.h>
#include <ESPAsyncWebServer.h>
#include <WString.h>
#include <WebSerial.h>

AsyncWebServer server(80);

static uint32_t last = millis();
static uint32_t count = 0;

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

WiFi.softAP("WSLDemo");
Serial.print("IP Address: ");
Serial.println(WiFi.softAPIP().toString());

WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
WebSerial.begin(&server);
WebSerial.setBuffer(100);

server.onNotFound([](AsyncWebServerRequest* request) { request->redirect("/webserial"); });
server.begin();
}

void loop() {
if (millis() - last > 1000) {
count++;

WebSerial.print(F("IP address: "));
WebSerial.println(WiFi.softAPIP());
WebSerial.printf("Uptime: %lums\n", millis());
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());

last = millis();
}
}
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"maintainer": true
}
],
"version": "2.0.2",
"version": "2.0.3",
"frameworks": "arduino",
"platforms": ["espressif8266", "espressif32"],
"dependencies": [
{
"owner": "mathieucarbou",
"name": "ESP Async WebServer",
"version": "^2.10.4",
"version": "^3.0.2",
"platforms": ["espressif8266", "espressif32"]
}
]
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=WebSerial
version=2.0.2
version=2.0.3
author=Ayush Sharma
category=Communication
maintainer=Ayush Sharma <[email protected]>
Expand Down
17 changes: 12 additions & 5 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ build_flags =
-Wall -Wextra
-D CONFIG_ARDUHAL_LOG_COLORS
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
-D WS_MAX_QUEUED_MESSAGES=128
-D WSL_HIGH_PERF
lib_deps =
mathieucarbou/Async TCP @ ^3.1.4
mathieucarbou/ESP Async WebServer @ 2.10.4
mathieucarbou/ESP Async WebServer @ 3.0.2
upload_protocol = esptool
monitor_speed = 115200
monitor_filters = esp32_exception_decoder, log2file

[platformio]
lib_dir = .
src_dir = examples/Demo
; src_dir = examples/Demo
; src_dir = examples/Demo_AP
; src_dir = examples/HighPerf
src_dir = examples/Logging

[env:arduino]
platform = espressif32
Expand All @@ -27,13 +33,14 @@ board = esp32-s3-devkitc-1
[env:arduino-3]
platform = espressif32
platform_packages=
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.0/esp32-arduino-libs-3.0.0.zip
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip
board = esp32-s3-devkitc-1
; board = esp32dev

[env:esp8266]
platform = espressif8266
board = huzzah
lib_deps =
mathieucarbou/ESP Async WebServer @ 2.10.4
mathieucarbou/ESP Async WebServer @ 3.0.2
esphome/ESPAsyncTCP-esphome @ 2.0.0
Loading

0 comments on commit 1736f21

Please sign in to comment.