Line | |
---|
1 | /*
|
---|
2 | EthernetClientStream.h
|
---|
3 | An Arduino-Stream that wraps an instance of Client reconnecting to
|
---|
4 | the remote-ip in a transparent way. A disconnected client may be
|
---|
5 | recognized by the returnvalues -1 from calls to peek or read and
|
---|
6 | a 0 from calls to write.
|
---|
7 |
|
---|
8 | Copyright (C) 2013 Norbert Truchsess. All rights reserved.
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2.1 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | See file LICENSE.txt for further informations on licensing terms.
|
---|
16 |
|
---|
17 | formatted using the GNU C formatting and indenting
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef ETHERNETCLIENTSTREAM_H
|
---|
21 | #define ETHERNETCLIENTSTREAM_H
|
---|
22 |
|
---|
23 | #include <inttypes.h>
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <Stream.h>
|
---|
26 | #include <Client.h>
|
---|
27 | #include <IPAddress.h>
|
---|
28 |
|
---|
29 | class EthernetClientStream : public Stream
|
---|
30 | {
|
---|
31 | public:
|
---|
32 | EthernetClientStream(Client &client, IPAddress localip, IPAddress ip, const char* host, uint16_t port);
|
---|
33 | int available();
|
---|
34 | int read();
|
---|
35 | int peek();
|
---|
36 | void flush();
|
---|
37 | size_t write(uint8_t);
|
---|
38 | void maintain(IPAddress localip);
|
---|
39 |
|
---|
40 | private:
|
---|
41 | Client &client;
|
---|
42 | IPAddress localip;
|
---|
43 | IPAddress ip;
|
---|
44 | const char* host;
|
---|
45 | uint16_t port;
|
---|
46 | bool connected;
|
---|
47 | uint32_t time_connect;
|
---|
48 | bool maintain();
|
---|
49 | void stop();
|
---|
50 | };
|
---|
51 |
|
---|
52 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.