Browse Source

Merge branch 'feature/newAsyncWebserver' into development03

pull/1738/merge
lumapu 7 months ago
parent
commit
16869b4e26
  1. 34
      patches/AsyncWeb_Prometheus.patch
  2. 2
      scripts/applyPatches.py
  3. 4
      src/platformio.ini
  4. 28
      src/web/web.h

34
patches/AsyncWeb_Prometheus.patch

@ -1,26 +1,26 @@
diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp
index 6e88da9..09359c3 100644
diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp
index 88d88ec..cb06fe0 100644
--- a/src/AsyncWebSocket.cpp
+++ b/src/AsyncWebSocket.cpp
@@ -827,7 +827,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer)
@@ -745,7 +745,7 @@ void AsyncWebSocketClient::binary(const __FlashStringHelper* data, size_t len) {
IPAddress AsyncWebSocketClient::remoteIP() {
if(!_client) {
- return IPAddress((uint32_t)0);
+ return IPAddress();
}
return _client->remoteIP();
IPAddress AsyncWebSocketClient::remoteIP() const {
if (!_client)
- return IPAddress((uint32_t)0U);
+ return IPAddress();
return _client->remoteIP();
}
diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp
index a22e991..babef18 100644
index 86aa947..9d0ee00 100644
--- a/src/WebResponses.cpp
+++ b/src/WebResponses.cpp
@@ -317,7 +317,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
free(buf);
return 0;
@@ -447,7 +447,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest* request, size_t len, u
free(buf);
return 0;
}
- outLen = sprintf((char*)buf+headLen, "%x", readLen) + headLen;
+ outLen = sprintf((char*)buf+headLen, "%04x", readLen) + headLen;
while(outLen < headLen + 4) buf[outLen++] = ' ';
- outLen = sprintf_P((char*)buf + headLen, PSTR("%x"), readLen) + headLen;
+ outLen = sprintf_P((char*)buf + headLen, PSTR("%04x"), readLen) + headLen;
while (outLen < headLen + 4)
buf[outLen++] = ' ';
buf[outLen++] = '\r';
buf[outLen++] = '\n';

2
scripts/applyPatches.py

@ -26,7 +26,7 @@ def applyPatch(libName, patchFile):
# list of patches to apply (relative to /src)
applyPatch("ESPAsyncWebServer-esphome", "../patches/AsyncWeb_Prometheus.patch")
applyPatch("ESPAsyncWebServer", "../patches/AsyncWeb_Prometheus.patch")
if (env['PIOENV'][:5] == "esp32") or (env['PIOENV'][:13] == "opendtufusion"):
applyPatch("GxEPD2", "../patches/GxEPD2_HAL.patch")

4
src/platformio.ini

@ -26,7 +26,8 @@ extra_scripts =
post:../scripts/add_littlefs_binary.py
lib_deps =
https://github.com/esphome/ESPAsyncWebServer @ ^3.2.2
#https://github.com/esphome/ESPAsyncWebServer @ ^3.2.2
https://github.com/mathieucarbou/ESPAsyncWebServer @ ^3.1.3
https://github.com/nRF24/RF24.git#v1.4.8
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.7.0
@ -51,6 +52,7 @@ lib_deps =
https://github.com/me-no-dev/ESPAsyncUDP
build_flags = ${env.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
;-Wl,-Map,output.map
monitor_filters =
esp8266_exception_decoder

28
src/web/web.h

@ -245,7 +245,7 @@ class Web {
if (CHECK_MASK(mConfig->sys.protectionMask, mask))
checkProtection(request);
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), zippedHtml, len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), zippedHtml, len);
response->addHeader(F("Content-Encoding"), "gzip");
response->addHeader(F("content-type"), "text/html; charset=UTF-8");
if(request->hasParam("v"))
@ -343,7 +343,7 @@ class Web {
}
}
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), login_html, login_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), login_html, login_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -354,7 +354,7 @@ class Web {
checkProtection(request);
mApp->lock(true);
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -363,9 +363,9 @@ class Web {
DPRINTLN(DBG_VERBOSE, F("onColor"));
AsyncWebServerResponse *response;
if (mConfig->sys.darkMode)
response = request->beginResponse_P(200, F("text/css"), colorDark_css, colorDark_css_len);
response = request->beginResponse(200, F("text/css"), colorDark_css, colorDark_css_len);
else
response = request->beginResponse_P(200, F("text/css"), colorBright_css, colorBright_css_len);
response = request->beginResponse(200, F("text/css"), colorBright_css, colorBright_css_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v")) {
response->addHeader(F("Cache-Control"), F("max-age=604800"));
@ -375,7 +375,7 @@ class Web {
void onCss(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("onCss"));
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/css"), style_css, style_css_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/css"), style_css, style_css_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v")) {
response->addHeader(F("Cache-Control"), F("max-age=604800"));
@ -386,7 +386,7 @@ class Web {
void onApiJs(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("onApiJs"));
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/javascript"), api_js, api_js_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v"))
response->addHeader(F("Cache-Control"), F("max-age=604800"));
@ -396,7 +396,7 @@ class Web {
void onGridInfoJson(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("onGridInfoJson"));
AsyncWebServerResponse *response = request->beginResponse_P(200, F("application/json; charset=utf-8"), grid_info_json, grid_info_json_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("application/json; charset=utf-8"), grid_info_json, grid_info_json_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v"))
response->addHeader(F("Cache-Control"), F("max-age=604800"));
@ -405,7 +405,7 @@ class Web {
void onFavicon(AsyncWebServerRequest *request) {
static const char favicon_type[] PROGMEM = "image/x-icon";
AsyncWebServerResponse *response = request->beginResponse_P(200, favicon_type, favicon_ico, favicon_ico_len);
AsyncWebServerResponse *response = request->beginResponse(200, favicon_type, favicon_ico, favicon_ico_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -418,7 +418,7 @@ class Web {
void onReboot(AsyncWebServerRequest *request) {
mApp->setRebootFlag();
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -426,7 +426,7 @@ class Web {
void showHtml(AsyncWebServerRequest *request) {
checkProtection(request);
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -443,7 +443,7 @@ class Web {
}
#endif
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), wizard_html, wizard_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), wizard_html, wizard_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
response->addHeader(F("content-type"), "text/html; charset=UTF-8");
request->send(response);
@ -635,7 +635,7 @@ class Web {
mApp->saveSettings((request->arg("reboot") == "on"));
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), save_html, save_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), save_html, save_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
@ -649,7 +649,7 @@ class Web {
}
void onAbout(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), about_html, about_html_len);
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), about_html, about_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
response->addHeader(F("content-type"), "text/html; charset=UTF-8");
if(request->hasParam("v")) {

Loading…
Cancel
Save