Compare commits

...

5 Commits

Author SHA1 Message Date
anschrammh
2d73921bc7 Minor modifications 2019-12-27 10:50:32 +01:00
anschrammh
7b80f7a95c Minor changes to the Dictionary class 2019-12-27 10:48:47 +01:00
anschrammh
9148e61911 Created new HttpConstants class 2019-12-27 10:47:34 +01:00
anschrammh
2cca10ec5a Removed http specific enums, which are now part of the HttpConstants class 2019-12-27 10:47:02 +01:00
anschrammh
c29d4edbd7 Renamed HtmlClient to HttpClient 2019-12-27 10:45:52 +01:00
6 changed files with 25 additions and 57 deletions

View File

@ -242,11 +242,11 @@ public:
_next = NULL;
}
const char *stringValue() const {return _value == NULL ? "" : _value->toString();}
const char *stringValue() const {return _value == NULL ? NULL : _value->toString();}
const char *getParameter(const unsigned int index)
{
unsigned int position(0);
if(isListEmpty(_head->_next))return "";
if(isListEmpty(_head->_next))return NULL;
Dictionary *cursor = _head->_next;
@ -257,7 +257,7 @@ public:
cursor = cursor->_next;
}
return "";
return NULL;
}
protected:
Dictionary(const char *parameter, T *value) : Dictionary()

View File

@ -1,11 +0,0 @@
#include "HtmlClient.h"
HtmlClient::HtmlClient() : WiFiClient()
{
}
HtmlClient::~HtmlClient()
{
}

View File

@ -1,35 +0,0 @@
#ifndef HTMLCLIENT_H
#define HTMLCLIENT_H
#include <ESP8266WiFi.h>
class HtmlClient : WiFiClient
{
public:
HtmlClient();
virtual ~HtmlClient();
boolean sendHtmlQuery();
uint16_t readHtmlResponse(uint8_t *buffer);
protected:
private:
};
#endif //HTMLCLIENT_H
/*
* TCP status codes :
* enum tcp_state {
CLOSED = 0,
LISTEN = 1,
SYN_SENT = 2,
SYN_RCVD = 3,
ESTABLISHED = 4,
FIN_WAIT_1 = 5,
FIN_WAIT_2 = 6,
CLOSE_WAIT = 7,
CLOSING = 8,
LAST_ACK = 9,
TIME_WAIT = 10
};
*/

15
src/app/HttpConstants.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef HTTPCONSTANTS_H
#define HTTPCONSTANTS_H
class HttpConstants
{
public:
enum HttpRequestMethod {UNDEFINED, GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH};
enum HttpVersion {UNKNOWN, HTTP_0_9, HTTP_1_1, HTTP_1_0, HTTP_2_0};
enum HttpMIMEType{UNKNOWN_MIME, TEXT_PLAIN, TEXT_CSS, TEXT_HTML, TEXT_JAVASCRIPT, APPLICATION_JSON, APPLICATION_X_WWW_FORM_URLENCODED, IMAGE_PNG, IMAGE_JPEG, AUDIO_MPEG, APPLICATION_OCTET_STREAM};
enum HTTP_CODE {UNDEFINED_CODE, _100, _101, _200, _400, _401, _403, _404, _405, _500, _501};
protected:
private:
};
#endif//HTTPCONSTANTS_H

View File

@ -112,14 +112,16 @@ TaskSchedulerManager::TaskSchedulerManager(RtcManager &rtcManager) : _nextTaskIn
boolean TaskSchedulerManager::addTask(const char *name, TaskSchedulerManagerHelper::Schedule *schedule, boolean (*taskRoutine)(void*), void *pData)
{
boolean result = _taskDataDictio.add(name, new TaskData({*schedule, taskRoutine, pData}));
delete schedule;
delete schedule;schedule = NULL;
return result;
}
boolean TaskSchedulerManager::addTask(uint16_t id, TaskSchedulerManagerHelper::Schedule *schedule, boolean (*taskRoutine)(void*), void *pData)
{
boolean result = _taskDataDictio.add(id, new TaskData({*schedule, taskRoutine, pData}));
delete schedule;
delete schedule;schedule = NULL;
return result;
}

View File

@ -4,20 +4,17 @@
#include "TCPServer.h"
#include "Dictionary.h"
#include "SDCardManager.h"
#include "HttpConstants.h"
//#define DEBUG_WEBS
#define READ_WRITE_BUFFER_SIZE 2500
template <typename T>
class WEBServer : public TCPServer<T>
class WEBServer : public TCPServer<T>, public HttpConstants
{
public:
enum HttpRequestMethod {UNDEFINED, GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH};
enum HttpVersion {UNKNOWN, HTTP_0_9, HTTP_1_1, HTTP_1_0, HTTP_2_0};
enum HttpMIMEType{UNKNOWN_MIME, TEXT_PLAIN, TEXT_CSS, TEXT_HTML, TEXT_JAVASCRIPT, APPLICATION_JSON, APPLICATION_X_WWW_FORM_URLENCODED, IMAGE_PNG, IMAGE_JPEG, AUDIO_MPEG, APPLICATION_OCTET_STREAM};
enum HttpParserStatus {HTTP_VERB, HTTP_RESSOURCE, HTTP_VERSION, HTTP_PARAMS, POST_DATA, HEADER_PARAMS};
enum WEBClientState {ACCEPTED, PARSING, QUERY_PARSED, RESPONSE_SENT, DONE};
enum HTTP_CODE {_100, _101, _200, _400, _401, _403, _404, _405, _500, _501};
struct HttpRequestData
{
HttpRequestMethod HRM;