-
Notifications
You must be signed in to change notification settings - Fork 4
/
Esp8266LocalServer.h
46 lines (36 loc) · 1003 Bytes
/
Esp8266LocalServer.h
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
35
36
37
38
39
40
41
42
43
44
45
46
#if defined(ESP8266)
#ifndef OTF_ESP8266LOCALSERVER_H
#define OTF_ESP8266LOCALSERVER_H
#include "LocalServer.h"
#include <Arduino.h>
#include <ESP8266WiFi.h>
namespace OTF {
class Esp8266LocalClient : public LocalClient {
friend class Esp8266LocalServer;
private:
WiFiClient client;
Esp8266LocalClient(WiFiClient client);
public:
bool dataAvailable();
size_t readBytes(char *buffer, size_t length);
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t write(const char *buffer, size_t length);
void print(const char *data);
void print(const __FlashStringHelper *data);
int peek();
void setTimeout(int timeout);
void flush();
void stop();
};
class Esp8266LocalServer : public LocalServer {
private:
WiFiServer server;
Esp8266LocalClient *activeClient = nullptr;
public:
Esp8266LocalServer(uint16_t port);
LocalClient *acceptClient();
void begin();
};
}// namespace OTF
#endif
#endif