From 76648f4c2d27ffe68c787666f5c2b99d3781d86a Mon Sep 17 00:00:00 2001 From: Pablo2048 Date: Thu, 24 Jun 2021 17:37:53 +0200 Subject: [PATCH] Posledni verze se zmenami Lorola i Pangolina --- library.json => library.json_ | 0 library.properties => library.properties_ | 0 src/AsyncEventSource.cpp | 6 +++-- src/AsyncJson.h | 4 +++- src/AsyncWebSocket.cpp | 2 +- src/AsyncWebSocket.h | 14 +++++++---- src/ESPAsyncWebServer.h | 26 +++++++------------- src/StringArray.h | 13 ++++++++-- src/WebRequest.cpp | 29 ++--------------------- 9 files changed, 40 insertions(+), 54 deletions(-) rename library.json => library.json_ (100%) rename library.properties => library.properties_ (100%) diff --git a/library.json b/library.json_ similarity index 100% rename from library.json rename to library.json_ diff --git a/library.properties b/library.properties_ similarity index 100% rename from library.properties rename to library.properties_ diff --git a/src/AsyncEventSource.cpp b/src/AsyncEventSource.cpp index 1325310..af56811 100644 --- a/src/AsyncEventSource.cpp +++ b/src/AsyncEventSource.cpp @@ -21,7 +21,7 @@ #include "AsyncEventSource.h" static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){ - String ev; + String ev = ""; if(reconnect){ ev += F("retry: "); @@ -212,7 +212,9 @@ void AsyncEventSourceClient::_onPoll(){ void AsyncEventSourceClient::_onTimeout(uint32_t time __attribute__((unused))){ - _client->close(true); + //_client->close(true); according to Pango "Too harsh! breaks webui" so beware... + _messageQueue.remove(_messageQueue.front()); + _runQueue(); } void AsyncEventSourceClient::_onDisconnect(){ diff --git a/src/AsyncJson.h b/src/AsyncJson.h index 27b4a26..2fa6a2d 100644 --- a/src/AsyncJson.h +++ b/src/AsyncJson.h @@ -41,7 +41,9 @@ #if ARDUINOJSON_VERSION_MAJOR == 5 #define ARDUINOJSON_5_COMPATIBILITY #else - #define DYNAMIC_JSON_DOCUMENT_SIZE 1024 + #ifndef DYNAMIC_JSON_DOCUMENT_SIZE + #define DYNAMIC_JSON_DOCUMENT_SIZE 1024 + #endif #endif constexpr const char* JSON_MIMETYPE = "application/json"; diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index 9ebab12..ac4ddc9 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -911,7 +911,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer) IPAddress AsyncWebSocketClient::remoteIP() { if(!_client) { - return IPAddress(0U); + return IPAddress((uint32_t)0); } return _client->remoteIP(); } diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index 5ebf1cc..8179f1b 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -23,11 +23,17 @@ #include #ifdef ESP32 -#include -#define WS_MAX_QUEUED_MESSAGES 32 +# include +# if !defined(WS_MAX_QUEUED_MESSAGES) || WS_MAX_QUEUED_MESSAGES < 1 +# undef WS_MAX_QUEUED_MESSAGES +# define WS_MAX_QUEUED_MESSAGES 32 +# endif // !defined(WS_MAX_QUEUED_MESSAGES) || WS_MAX_QUEUED_MESSAGES < 1 #else -#include -#define WS_MAX_QUEUED_MESSAGES 8 +# include +# if !defined(WS_MAX_QUEUED_MESSAGES) || WS_MAX_QUEUED_MESSAGES < 1 +# undef WS_MAX_QUEUED_MESSAGES +# define WS_MAX_QUEUED_MESSAGES 8 +# endif // !defined(WS_MAX_QUEUED_MESSAGES) || WS_MAX_QUEUED_MESSAGES < 1 #endif #include diff --git a/src/ESPAsyncWebServer.h b/src/ESPAsyncWebServer.h index 498ae62..3aff61b 100644 --- a/src/ESPAsyncWebServer.h +++ b/src/ESPAsyncWebServer.h @@ -59,22 +59,14 @@ class AsyncResponseStream; #ifndef WEBSERVER_H typedef enum { - HTTP_GET = 0b0000000000000001, - HTTP_POST = 0b0000000000000010, - HTTP_DELETE = 0b0000000000000100, - HTTP_PUT = 0b0000000000001000, - HTTP_PATCH = 0b0000000000010000, - HTTP_HEAD = 0b0000000000100000, - HTTP_OPTIONS = 0b0000000001000000, - HTTP_PROPFIND = 0b0000000010000000, - HTTP_LOCK = 0b0000000100000000, - HTTP_UNLOCK = 0b0000001000000000, - HTTP_PROPPATCH = 0b0000010000000000, - HTTP_MKCOL = 0b0000100000000000, - HTTP_MOVE = 0b0001000000000000, - HTTP_COPY = 0b0010000000000000, - HTTP_RESERVED = 0b0100000000000000, - HTTP_ANY = 0b0111111111111111, + HTTP_GET = 0b00000001, + HTTP_POST = 0b00000010, + HTTP_DELETE = 0b00000100, + HTTP_PUT = 0b00001000, + HTTP_PATCH = 0b00010000, + HTTP_HEAD = 0b00100000, + HTTP_OPTIONS = 0b01000000, + HTTP_ANY = 0b01111111, } WebRequestMethod; #endif @@ -94,7 +86,7 @@ namespace fs { //if this value is returned when asked for data, packet will not be sent and you will be asked for data again #define RESPONSE_TRY_AGAIN 0xFFFFFFFF -typedef uint16_t WebRequestMethodComposite; +typedef uint8_t WebRequestMethodComposite; typedef std::function ArDisconnectHandler; /* diff --git a/src/StringArray.h b/src/StringArray.h index 4c0aa70..275f355 100644 --- a/src/StringArray.h +++ b/src/StringArray.h @@ -47,10 +47,19 @@ class LinkedList { class Iterator { ItemType* _node; + ItemType* _nextNode = nullptr; public: - Iterator(ItemType* current = nullptr) : _node(current) {} + Iterator(ItemType* current = nullptr) : _node(current) { + if (_node != nullptr) { + _nextNode = current->next; + } + } Iterator(const Iterator& i) : _node(i._node) {} - Iterator& operator ++() { _node = _node->next; return *this; } + Iterator& operator ++() { + _node = _nextNode; + _nextNode = _node != nullptr ? _node->next : nullptr; + return *this; + } bool operator != (const Iterator& i) const { return _node != i._node; } const T& operator * () const { return _node->value(); } const T* operator -> () const { return &_node->value(); } diff --git a/src/WebRequest.cpp b/src/WebRequest.cpp index 025bc3b..570e732 100644 --- a/src/WebRequest.cpp +++ b/src/WebRequest.cpp @@ -286,24 +286,6 @@ bool AsyncWebServerRequest::_parseReqHead(){ _method = HTTP_HEAD; } else if(m == F("OPTIONS")){ _method = HTTP_OPTIONS; - } else if(m == F("PROPFIND")){ - _method = HTTP_PROPFIND; - } else if(m == F("LOCK")){ - _method = HTTP_LOCK; - } else if(m == F("UNLOCK")){ - _method = HTTP_UNLOCK; - } else if(m == F("PROPPATCH")){ - _method = HTTP_PROPPATCH; - } else if(m == F("MKCOL")){ - _method = HTTP_MKCOL; - } else if(m == F("MOVE")){ - _method = HTTP_MOVE; - } else if(m == F("COPY")){ - _method = HTTP_COPY; - } else if(m == F("RESERVED")){ - _method = HTTP_RESERVED; - } else if(m == F("ANY")){ - _method = HTTP_ANY; } String g; @@ -347,7 +329,8 @@ bool AsyncWebServerRequest::_parseReqHeader(){ int index = _temp.indexOf(':'); if(index){ String name = _temp.substring(0, index); - String value = _temp.substring(index + 2); + String value = _temp.substring(index + 1); + value.trim(); if(name.equalsIgnoreCase("Host")){ _host = value; } else if(name.equalsIgnoreCase(F("Content-Type"))){ @@ -940,14 +923,6 @@ const __FlashStringHelper *AsyncWebServerRequest::methodToString() const { else if(_method & HTTP_PATCH) return F("PATCH"); else if(_method & HTTP_HEAD) return F("HEAD"); else if(_method & HTTP_OPTIONS) return F("OPTIONS"); - else if(_method & HTTP_PROPFIND) return F("PROPFIND"); - else if(_method & HTTP_LOCK) return F("LOCK"); - else if(_method & HTTP_UNLOCK) return F("UNLOCK"); - else if(_method & HTTP_PROPPATCH) return F("PROPPATCH"); - else if(_method & HTTP_MKCOL) return F("MKCOL"); - else if(_method & HTTP_MOVE) return F("MOVE"); - else if(_method & HTTP_COPY) return F("COPY"); - else if(_method & HTTP_RESERVED) return F("RESERVED"); return F("UNKNOWN"); }