-
Notifications
You must be signed in to change notification settings - Fork 4
/
Esp8266LocalServer.cpp
71 lines (53 loc) · 1.46 KB
/
Esp8266LocalServer.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#if defined(ESP8266)
#include "Esp8266LocalServer.h"
using namespace OTF;
Esp8266LocalServer::Esp8266LocalServer(uint16_t port) : server(port) {}
LocalClient *Esp8266LocalServer::acceptClient() {
if (activeClient != nullptr) {
delete activeClient;
}
WiFiClient wiFiClient = server.available();
if (wiFiClient) {
activeClient = new Esp8266LocalClient(wiFiClient);
} else {
activeClient = nullptr;
}
return activeClient;
}
void Esp8266LocalServer::begin() {
server.begin();
}
Esp8266LocalClient::Esp8266LocalClient(WiFiClient client) {
this->client = client;
}
bool Esp8266LocalClient::dataAvailable() {
return client.available();
}
size_t Esp8266LocalClient::readBytes(char *buffer, size_t length) {
return client.readBytes(buffer, length);
}
size_t Esp8266LocalClient::readBytesUntil(char terminator, char *buffer, size_t length) {
return client.readBytesUntil(terminator, buffer, length);
}
size_t Esp8266LocalClient::write(const char *buffer, size_t size) {
return client.write((const uint8_t *)buffer, size);
}
void Esp8266LocalClient::print(const char *data) {
client.print(data);
}
void Esp8266LocalClient::print(const __FlashStringHelper *data) {
client.print(data);
}
int Esp8266LocalClient::peek() {
return client.peek();
}
void Esp8266LocalClient::setTimeout(int timeout) {
client.setTimeout(timeout);
}
void Esp8266LocalClient::flush() {
client.flush();
}
void Esp8266LocalClient::stop() {
client.stop();
}
#endif