-
Notifications
You must be signed in to change notification settings - Fork 138
/
SLIPEncodedTCP.h
48 lines (34 loc) · 1.05 KB
/
SLIPEncodedTCP.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
/*
Extends the TCP client class to encode SLIP over TCP
*/
#ifndef SLIPEncodedTCP_H
#define SLIPEncodedTCP_H
#include "Arduino.h"
#include <Stream.h>
#include <Client.h>
class SLIPEncodedTCP: public Stream{
private:
enum erstate {CHAR, FIRSTEOT, SECONDEOT, SLIPESC } rstate;
//the TCP client used
Client * tcpClient;
public:
SLIPEncodedTCP(Client & );
int available();
int read();
int peek();
void flush();
void beginPacket(); // SLIP specific method which begins a transmitted packet
void endPacket(); // SLIP specific method which ends a transmittedpacket
bool endofPacket(); // SLIP specific method which indicates that an EOT was received
//the arduino and wiring libraries have different return types for the write function
#if defined(WIRING) || defined(BOARD_DEFS_H)
void write(uint8_t b);
void write(const uint8_t *buffer, size_t size);
#else
//overrides the Stream's write function to encode SLIP
size_t write(uint8_t b);
size_t write(const uint8_t *buffer, size_t size);
//using Print::write;
#endif
};
#endif