source: rtos_arduino/trunk/arduino_lib/libraries/Bridge/src/YunClient.h@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.9 KB
Line 
1/*
2 Copyright (c) 2013 Arduino LLC. All right reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#ifndef _YUN_CLIENT_H_
20#define _YUN_CLIENT_H_
21
22#include <Bridge.h>
23#include <Client.h>
24
25class YunClient : public Client {
26 public:
27 // Constructor with a user provided BridgeClass instance
28 YunClient(int _h, BridgeClass &_b = Bridge);
29 YunClient(BridgeClass &_b = Bridge);
30 ~YunClient();
31
32 // Stream methods
33 // (read message)
34 virtual int available();
35 virtual int read();
36 virtual int read(uint8_t *buf, size_t size);
37 virtual int peek();
38 // (write response)
39 virtual size_t write(uint8_t);
40 virtual size_t write(const uint8_t *buf, size_t size);
41 virtual void flush();
42 // TODO: add optimized function for block write
43
44 virtual operator bool () {
45 return opened;
46 }
47
48 YunClient& operator=(const YunClient &_x);
49
50 virtual void stop();
51 virtual uint8_t connected();
52
53 virtual int connect(IPAddress ip, uint16_t port);
54 virtual int connect(const char *host, uint16_t port);
55
56 private:
57 BridgeClass &bridge;
58 unsigned int handle;
59 boolean opened;
60
61 private:
62 void doBuffer();
63 uint8_t buffered;
64 uint8_t readPos;
65 static const int BUFFER_SIZE = 64;
66 uint8_t buffer[BUFFER_SIZE];
67
68};
69
70#endif // _YUN_CLIENT_H_
Note: See TracBrowser for help on using the repository browser.