ESP3D Lib
1.0
3D Printer WiFi Library
serial2socket.h
Go to the documentation of this file.
1
/*
2
serial2socket.h - serial 2 socket functions class
3
4
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
22
#ifndef _SERIAL_2_SOCKET_H_
23
#define _SERIAL_2_SOCKET_H_
24
25
#include "Print.h"
26
#define TXBUFFERSIZE 1200
27
#define RXBUFFERSIZE 128
28
#define FLUSHTIMEOUT 500
29
class
Serial_2_Socket
:
public
Print{
30
public
:
31
Serial_2_Socket
();
32
~Serial_2_Socket
();
33
size_t
write
(uint8_t c);
34
size_t
write
(
const
uint8_t *buffer,
size_t
size);
35
36
inline
size_t
write
(
const
char
* s)
37
{
38
return
write
((uint8_t*) s, strlen(s));
39
}
40
inline
size_t
write
(
unsigned
long
n)
41
{
42
return
write
((uint8_t) n);
43
}
44
inline
size_t
write
(
long
n)
45
{
46
return
write
((uint8_t) n);
47
}
48
inline
size_t
write
(
unsigned
int
n)
49
{
50
return
write
((uint8_t) n);
51
}
52
inline
size_t
write
(
int
n)
53
{
54
return
write
((uint8_t) n);
55
}
56
long
baudRate
();
57
void
begin
(
long
speed);
58
void
end
();
59
int
available
();
60
int
peek
(
void
);
61
int
read
(
void
);
62
bool
push
(
const
char
* data);
63
void
flush
(
void
);
64
void
handle_flush
();
65
operator
bool()
const
;
66
bool
attachWS
(
void
* web_socket);
67
bool
detachWS
();
68
private
:
69
uint32_t _lastflush;
70
void
* _web_socket;
71
uint8_t _TXbuffer[
TXBUFFERSIZE
];
72
uint16_t _TXbufferSize;
73
uint8_t _RXbuffer[
RXBUFFERSIZE
];
74
uint16_t _RXbufferSize;
75
uint16_t _RXbufferpos;
76
};
77
78
79
extern
Serial_2_Socket
Serial2Socket
;
80
81
#endif
Serial_2_Socket::begin
void begin(long speed)
Serial_2_Socket::write
size_t write(const char *s)
Definition:
serial2socket.h:36
Serial_2_Socket::attachWS
bool attachWS(void *web_socket)
Serial_2_Socket::read
int read(void)
Serial_2_Socket::handle_flush
void handle_flush()
Serial_2_Socket::end
void end()
Serial_2_Socket::write
size_t write(unsigned long n)
Definition:
serial2socket.h:40
Serial_2_Socket::detachWS
bool detachWS()
Serial_2_Socket
Definition:
serial2socket.h:29
Serial_2_Socket::push
bool push(const char *data)
Serial_2_Socket::available
int available()
Serial_2_Socket::write
size_t write(unsigned int n)
Definition:
serial2socket.h:48
RXBUFFERSIZE
#define RXBUFFERSIZE
Definition:
serial2socket.h:27
Serial_2_Socket::write
size_t write(long n)
Definition:
serial2socket.h:44
Serial_2_Socket::flush
void flush(void)
Serial_2_Socket::~Serial_2_Socket
~Serial_2_Socket()
Serial_2_Socket::write
size_t write(int n)
Definition:
serial2socket.h:52
Serial2Socket
Serial_2_Socket Serial2Socket
TXBUFFERSIZE
#define TXBUFFERSIZE
Definition:
serial2socket.h:26
Serial_2_Socket::Serial_2_Socket
Serial_2_Socket()
Serial_2_Socket::write
size_t write(uint8_t c)
Serial_2_Socket::peek
int peek(void)
Serial_2_Socket::baudRate
long baudRate()
src
serial2socket.h
Generated by
1.8.17