Compare commits

...

1 Commits

Author SHA1 Message Date
76648f4c2d Posledni verze se zmenami Lorola i Pangolina 2021-06-24 17:37:53 +02:00
9 changed files with 40 additions and 54 deletions

View File

@ -21,7 +21,7 @@
#include "AsyncEventSource.h" #include "AsyncEventSource.h"
static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){ static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){
String ev; String ev = "";
if(reconnect){ if(reconnect){
ev += F("retry: "); ev += F("retry: ");
@ -212,7 +212,9 @@ void AsyncEventSourceClient::_onPoll(){
void AsyncEventSourceClient::_onTimeout(uint32_t time __attribute__((unused))){ 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(){ void AsyncEventSourceClient::_onDisconnect(){

View File

@ -41,7 +41,9 @@
#if ARDUINOJSON_VERSION_MAJOR == 5 #if ARDUINOJSON_VERSION_MAJOR == 5
#define ARDUINOJSON_5_COMPATIBILITY #define ARDUINOJSON_5_COMPATIBILITY
#else #else
#define DYNAMIC_JSON_DOCUMENT_SIZE 1024 #ifndef DYNAMIC_JSON_DOCUMENT_SIZE
#define DYNAMIC_JSON_DOCUMENT_SIZE 1024
#endif
#endif #endif
constexpr const char* JSON_MIMETYPE = "application/json"; constexpr const char* JSON_MIMETYPE = "application/json";

View File

@ -911,7 +911,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer)
IPAddress AsyncWebSocketClient::remoteIP() { IPAddress AsyncWebSocketClient::remoteIP() {
if(!_client) { if(!_client) {
return IPAddress(0U); return IPAddress((uint32_t)0);
} }
return _client->remoteIP(); return _client->remoteIP();
} }

View File

@ -23,11 +23,17 @@
#include <Arduino.h> #include <Arduino.h>
#ifdef ESP32 #ifdef ESP32
#include <AsyncTCP.h> # include <AsyncTCP.h>
#define WS_MAX_QUEUED_MESSAGES 32 # 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 #else
#include <ESPAsyncTCP.h> # include <ESPAsyncTCP.h>
#define WS_MAX_QUEUED_MESSAGES 8 # 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 #endif
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>

View File

@ -59,22 +59,14 @@ class AsyncResponseStream;
#ifndef WEBSERVER_H #ifndef WEBSERVER_H
typedef enum { typedef enum {
HTTP_GET = 0b0000000000000001, HTTP_GET = 0b00000001,
HTTP_POST = 0b0000000000000010, HTTP_POST = 0b00000010,
HTTP_DELETE = 0b0000000000000100, HTTP_DELETE = 0b00000100,
HTTP_PUT = 0b0000000000001000, HTTP_PUT = 0b00001000,
HTTP_PATCH = 0b0000000000010000, HTTP_PATCH = 0b00010000,
HTTP_HEAD = 0b0000000000100000, HTTP_HEAD = 0b00100000,
HTTP_OPTIONS = 0b0000000001000000, HTTP_OPTIONS = 0b01000000,
HTTP_PROPFIND = 0b0000000010000000, HTTP_ANY = 0b01111111,
HTTP_LOCK = 0b0000000100000000,
HTTP_UNLOCK = 0b0000001000000000,
HTTP_PROPPATCH = 0b0000010000000000,
HTTP_MKCOL = 0b0000100000000000,
HTTP_MOVE = 0b0001000000000000,
HTTP_COPY = 0b0010000000000000,
HTTP_RESERVED = 0b0100000000000000,
HTTP_ANY = 0b0111111111111111,
} WebRequestMethod; } WebRequestMethod;
#endif #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 //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 #define RESPONSE_TRY_AGAIN 0xFFFFFFFF
typedef uint16_t WebRequestMethodComposite; typedef uint8_t WebRequestMethodComposite;
typedef std::function<void(void)> ArDisconnectHandler; typedef std::function<void(void)> ArDisconnectHandler;
/* /*

View File

@ -47,10 +47,19 @@ class LinkedList {
class Iterator { class Iterator {
ItemType* _node; ItemType* _node;
ItemType* _nextNode = nullptr;
public: 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(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; } bool operator != (const Iterator& i) const { return _node != i._node; }
const T& operator * () const { return _node->value(); } const T& operator * () const { return _node->value(); }
const T* operator -> () const { return &_node->value(); } const T* operator -> () const { return &_node->value(); }

View File

@ -286,24 +286,6 @@ bool AsyncWebServerRequest::_parseReqHead(){
_method = HTTP_HEAD; _method = HTTP_HEAD;
} else if(m == F("OPTIONS")){ } else if(m == F("OPTIONS")){
_method = HTTP_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; String g;
@ -347,7 +329,8 @@ bool AsyncWebServerRequest::_parseReqHeader(){
int index = _temp.indexOf(':'); int index = _temp.indexOf(':');
if(index){ if(index){
String name = _temp.substring(0, 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")){ if(name.equalsIgnoreCase("Host")){
_host = value; _host = value;
} else if(name.equalsIgnoreCase(F("Content-Type"))){ } 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_PATCH) return F("PATCH");
else if(_method & HTTP_HEAD) return F("HEAD"); else if(_method & HTTP_HEAD) return F("HEAD");
else if(_method & HTTP_OPTIONS) return F("OPTIONS"); 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"); return F("UNKNOWN");
} }