-
Notifications
You must be signed in to change notification settings - Fork 3
/
ESP8266proConnectionBase.h
66 lines (51 loc) · 1.31 KB
/
ESP8266proConnectionBase.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ESP8266pro
// This software distributed under the terms of the MIT license
// (c) Skurydin Alexey, 2014
#ifndef _ESP8266proConnectionBase_H_
#define _ESP8266proConnectionBase_H_
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define ESP_INVALID_CONNECTION ((uint8_t)255)
class ESP8266pro;
class ESP8266Connection;
class ESP8266proServer;
class IESP8266proBaseReceiver
{
public:
virtual void onDataReceive(uint8_t connectionId, char* buffer, int length, DataReceiveAction action) = 0;
};
class ESP8266proConnection
{
public:
virtual uint8_t getId() = 0;
ESP8266proConnection(ESP8266pro& esp);
virtual bool send(String data);
virtual bool send(const __FlashStringHelper* data);
virtual bool close();
protected:
bool internalSend(const __FlashStringHelper* dataP, const char* dataR);
protected:
ESP8266pro &parent;
};
class ESP8266proServerConection : public ESP8266proConnection
{
public:
ESP8266proServerConection(ESP8266pro& esp, uint8_t id);
virtual bool send(String data);
virtual bool send(const __FlashStringHelper* data);
virtual bool close();
virtual uint8_t getId();
// Internal methods
void incrimentUses();
void decrementUses();
//bool isUsed();
void dispose();
friend class ESP8266proServer;
private:
uint8_t cid;
uint8_t uses;
};
#endif