-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRemoteSerial.h
More file actions
34 lines (28 loc) · 825 Bytes
/
RemoteSerial.h
File metadata and controls
34 lines (28 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef RemoteSerial_h
#define RemoteSerial_h
#if defined(ESP8266)
#include "ESP8266WiFi.h"
#include "ESPAsyncTCP.h"
#elif defined(ESP32)
#include "WiFi.h"
#include "AsyncTCP.h"
#else
#error Platform not supported
#endif
#include "ESPAsyncWebServer.h"
#include "WebPage.h"
typedef std::function<void(const uint8_t *data, size_t len)> IncomingMessageHandler;
class RemoteSerialClass : public Print {
public:
void begin(AsyncWebServer *server, const char* url = "/remoteserial");
void setIncomingMessageHandler(IncomingMessageHandler handler);
void cleanupClients();
size_t write(uint8_t);
size_t write(const uint8_t* buffer, size_t size);
private:
AsyncWebServer* _server;
AsyncWebSocket* _ws;
IncomingMessageHandler _incomingMessageHandler = NULL;
};
extern RemoteSerialClass RemoteSerial;
#endif