mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-10-18 13:31:28 +08:00

Add Time Support (server + manual setup), only used for ESP32 FS currently as ESP8266 SPIFFS does not support Time, need to wait for LittleFS may be ? Add DHT support Add Pin reset support Add Base for Display Add libraries for new supported features Add /config handle as shortcut for [ESP420]plain to be used in embedded page Code refactoring for defines, use less Define as switches but more define as values for switches Clean warnings Lot of small bug fixes Add docs for [ESPXXX] commands
89 lines
2.4 KiB
C++
89 lines
2.4 KiB
C++
/*
|
|
websocket_server.h - websocket functions class
|
|
|
|
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
|
|
#ifndef _WEBSOCKET_SERVER_H_
|
|
#define _WEBSOCKET_SERVER_H_
|
|
|
|
#include "Print.h"
|
|
#define TXBUFFERSIZE 1200
|
|
//#define RXBUFFERSIZE 128
|
|
#define FLUSHTIMEOUT 500
|
|
class WebSocketsServer;
|
|
class WebSocket_Server: public Print
|
|
{
|
|
public:
|
|
WebSocket_Server();
|
|
~WebSocket_Server();
|
|
size_t write(uint8_t c);
|
|
size_t write(const uint8_t *buffer, size_t size);
|
|
|
|
inline size_t write(const char * s)
|
|
{
|
|
return write((uint8_t*) s, strlen(s));
|
|
}
|
|
inline size_t write(unsigned long n)
|
|
{
|
|
return write((uint8_t) n);
|
|
}
|
|
inline size_t write(long n)
|
|
{
|
|
return write((uint8_t) n);
|
|
}
|
|
inline size_t write(unsigned int n)
|
|
{
|
|
return write((uint8_t) n);
|
|
}
|
|
inline size_t write(int n)
|
|
{
|
|
return write((uint8_t) n);
|
|
}
|
|
bool begin(uint16_t port=0);
|
|
uint16_t port()
|
|
{
|
|
return _port;
|
|
}
|
|
void end();
|
|
//int available();
|
|
//int peek(void);
|
|
//int read(void);
|
|
void pushMSG (const char * data);
|
|
void pushMSG (uint num, const char * data);
|
|
void flush(void);
|
|
void handle();
|
|
operator bool() const;
|
|
void set_currentID(uint8_t current_id);
|
|
uint8_t get_currentID();
|
|
private:
|
|
bool _started;
|
|
uint16_t _port;
|
|
uint32_t _lastflush;
|
|
WebSocketsServer * _websocket_server;
|
|
uint8_t _TXbuffer[TXBUFFERSIZE];
|
|
uint16_t _TXbufferSize;
|
|
uint8_t _current_id;
|
|
//uint8_t _RXbuffer[RXBUFFERSIZE];
|
|
//uint16_t _RXbufferSize;
|
|
//uint16_t _RXbufferpos;
|
|
};
|
|
|
|
extern WebSocket_Server websocket_terminal_server;
|
|
#endif //_WEBSOCKET_SERVER_H_
|