source: rtos_arduino/trunk/arduino_lib/libraries/GSM/src/GSM3MobileClientProvider.h@ 136

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

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

File size: 4.4 KB
Line 
1/*
2This file is part of the GSM3 communications library for Arduino
3-- Multi-transport communications platform
4-- Fully asynchronous
5-- Includes code for the Arduino-Telefonica GSM/GPRS Shield V1
6-- Voice calls
7-- SMS
8-- TCP/IP connections
9-- HTTP basic clients
10
11This library has been developed by Telefónica Digital - PDI -
12- Physical Internet Lab, as part as its collaboration with
13Arduino and the Open Hardware Community.
14
15September-December 2012
16
17This library is free software; you can redistribute it and/or
18modify it under the terms of the GNU Lesser General Public
19License as published by the Free Software Foundation; either
20version 2.1 of the License, or (at your option) any later version.
21
22This library is distributed in the hope that it will be useful,
23but WITHOUT ANY WARRANTY; without even the implied warranty of
24MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25Lesser General Public License for more details.
26
27You should have received a copy of the GNU Lesser General Public
28License along with this library; if not, write to the Free Software
29Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
31The latest version of this library can always be found at
32https://github.com/BlueVia/Official-Arduino
33*/
34#ifndef __GSM3_MOBILECLIENTPROVIDER__
35#define __GSM3_MOBILECLIENTPROVIDER__
36
37#include <Arduino.h>
38#include <IPAddress.h>
39
40class GSM3MobileClientProvider
41{
42 protected:
43
44 uint8_t sockets;
45
46 public:
47
48 /** Constructor */
49 GSM3MobileClientProvider(){};
50
51 /** Minimum socket
52 @return socket
53 */
54 virtual inline int minSocket()=0;
55
56 /** Maximum socket
57 @return socket
58 */
59 virtual inline int maxSocket()=0;
60
61 /** Get last command status
62 @return returns 0 if last command is still executing, 1 success, >1 error
63 */
64 virtual int ready()=0;
65
66 /** Get status socket client
67 @param socket Socket
68 @return 1 if connected
69 */
70 virtual bool getStatusSocketClient(uint8_t socket)=0;
71
72 // Socket management
73
74 /** Get socket
75 @param socket Socket
76 @return socket
77 */
78 virtual int getSocket(int socket=-1)=0;
79
80 /** Release socket
81 @param socket Socket
82 */
83 virtual void releaseSocket(int socket)=0;
84
85 // Client socket functions
86
87 /** Connect to a server via TCP connection
88 @param server Server name or IP address in a String
89 @param port Port
90 @param id_socket Socket
91 @return 0 if command running, 1 if success, otherwise error
92 */
93 virtual int connectTCPClient(const char* server, int port, int id_socket)=0;
94
95 /** Connect to a server (by IP address) via TCP connection
96 @param add IP address in IPAddress format
97 @param port Port
98 @param id_socket Socket
99 @return 0 if command running, 1 if success, otherwise error
100 */
101 virtual int connectTCPClient(IPAddress add, int port, int id_socket)=0;
102
103 /** Begin writing through a socket
104 @param client1Server0 1 if modem acts as client, 0 if acts as server
105 @param id_socket Local socket number
106 @return 0 if command running, 1 if success, otherwise error
107 */
108 virtual void beginWriteSocket(bool client1Server0, int id_socket)=0;
109
110 /** Write through a socket. MUST go after beginWriteSocket()
111 @param c character to be written
112 */
113 virtual void writeSocket(uint8_t c)=0;
114
115 /** Write through a socket. MUST go after beginWriteSocket()
116 @param buf characters to be written (final 0 will not be written)
117 */
118 virtual void writeSocket(const char* buf)=0;
119
120 /** Finish current writing
121 */
122 virtual void endWriteSocket()=0;
123
124 /** Check if there are data to be read in socket.
125 @param client1Server0 1 if modem acts as client, 0 if acts as server
126 @param id_socket Local socket number
127 @return 0 if command running, 1 if there are data available, 4 if no data, otherwise error
128 */
129 virtual int availableSocket(bool client, int id_socket)=0;
130
131 /** Read data (get a character) available in socket
132 @return character
133 */
134 virtual int readSocket()=0;
135
136 /** Flush socket
137 */
138 virtual void flushSocket()=0;
139
140 /** Get a character but will not advance the buffer head
141 @return character
142 */
143 virtual int peekSocket()=0;
144
145 /** Close a socket
146 @param client1Server0 1 if modem acts as client, 0 if acts as server
147 @param id_socket Socket
148 @return 0 if command running, 1 if success, otherwise error
149 */
150 virtual int disconnectTCP(bool client1Server0, int idsocket)=0;
151
152};
153
154extern GSM3MobileClientProvider* theGSM3MobileClientProvider;
155
156#endif
Note: See TracBrowser for help on using the repository browser.