Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group of commits from dev branch #224

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ 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.1
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/ESPAsyncWebServer#v3.0.2

- name: Install ArduinoJson
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/bblanchon/ArduinoJson#v7.0.4
Expand Down Expand Up @@ -97,31 +97,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 Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{
"owner": "mathieucarbou",
"name": "ESP Async WebServer",
"version": "^2.10.1",
"version": "^3.0.2",
"platforms": ["espressif8266", "espressif32"]
}
]
Expand Down
8 changes: 4 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build_flags =
lib_deps =
bblanchon/ArduinoJson @ 7.0.4
mathieucarbou/Async TCP @ ^3.1.4
mathieucarbou/ESP Async WebServer @ 2.10.1
mathieucarbou/ESP Async WebServer @ 3.0.2
upload_protocol = esptool
monitor_speed = 115200
monitor_filters = esp32_exception_decoder, log2file
Expand All @@ -32,14 +32,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

[env:esp8266]
platform = espressif8266
board = huzzah
lib_deps =
bblanchon/ArduinoJson @ 7.0.4
mathieucarbou/ESP Async WebServer @ 2.10.1
mathieucarbou/ESP Async WebServer @ 3.0.2
esphome/ESPAsyncTCP-esphome @ 2.0.0
16 changes: 8 additions & 8 deletions src/ESPDash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ ESPDash::ESPDash(AsyncWebServer* server, const char* uri, bool enable_default_st
// Attach AsyncWebServer Routes
_server->on(uri, HTTP_GET, [this](AsyncWebServerRequest *request){
if(basic_auth){
if(!request->authenticate(username, password))
if(!request->authenticate(username.c_str(), password.c_str()))
return request->requestAuthentication();
}
// respond with the compressed frontend
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", DASH_HTML, sizeof(DASH_HTML));
AsyncWebServerResponse *response = request->beginResponse(200, "text/html", DASH_HTML, sizeof(DASH_HTML));
response->addHeader("Content-Encoding", "gzip");
response->addHeader("Cache-Control", "public, max-age=900");
request->send(response);
});

// Websocket Callback Handler
_ws->onEvent([&](AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len){
_ws->onEvent([&](__unused AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len){
// Request Buffer
#if ARDUINOJSON_VERSION_MAJOR == 7
JsonDocument json;
Expand Down Expand Up @@ -107,11 +107,11 @@ ESPDash::ESPDash(AsyncWebServer* server, const char* uri, bool enable_default_st
}

void ESPDash::setAuthentication(const char *user, const char *pass) {
basic_auth = strlen(user) > 0 && strlen(pass) > 0;
username = user;
password = pass;
basic_auth = username.length() && password.length();
if(basic_auth) {
strncpy(username, user, sizeof(username));
strncpy(password, pass, sizeof(password));
_ws->setAuthentication(user, pass);
_ws->setAuthentication(username.c_str(), password.c_str());
}
}

Expand Down Expand Up @@ -316,7 +316,7 @@ void ESPDash::generateLayoutJSON(AsyncWebSocketClient* client, bool changes_only

doc["stats"][idx]["i"] = s->_id;
doc["stats"][idx]["k"] = s->_key;
if (changes_only || strlen(s->_value) > 0)
if (changes_only || s->_value.length() > 0)
doc["stats"][idx]["v"] = s->_value;
doc["stats"][idx]["v"] = s->_value;
idx++;
Expand Down
4 changes: 2 additions & 2 deletions src/ESPDash.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class ESPDash{
Vector<Statistic*> statistics;
bool default_stats_enabled = false;
bool basic_auth = false;
char username[64];
char password[64];
String username;
String password;
uint32_t _idCounter = 0;
BeforeUpdateCallback _beforeUpdateCallback = nullptr;

Expand Down
7 changes: 3 additions & 4 deletions src/Statistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ Statistic::Statistic(ESPDash *dashboard, const char *key, const char *value) {
_id = dashboard->nextId();
// Safe copy
_key = key;
strncpy(_value, value, sizeof(_value));
_value = value;
_dashboard->add(this);
}

void Statistic::set(const char *value) {
// Safe copy
_changed = strcmp(_value, value) != 0;
_changed = _value != value;
if(_changed)
strncpy(_value, value, sizeof(_value));

_value = value;
}

Statistic::~Statistic() {
Expand Down
2 changes: 1 addition & 1 deletion src/Statistic.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Statistic {
ESPDash *_dashboard;
uint32_t _id;
const char *_key;
char _value[64];
String _value;
bool _changed = false;

public:
Expand Down
Loading