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

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

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

File size: 5.2 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_SHIELDV1CLIENTPROVIDER__
35#define __GSM3_SHIELDV1CLIENTPROVIDER__
36
37#include <GSM3MobileClientProvider.h>
38#include <GSM3ShieldV1BaseProvider.h>
39
40class GSM3ShieldV1ClientProvider : public GSM3MobileClientProvider, public GSM3ShieldV1BaseProvider
41{
42 private:
43
44 int remotePort; //Current operation remote port.
45 IPAddress remoteIP; // Remote IP address
46 int idSocket; // Remote ID socket.
47
48
49 /** Continue to connect TCP client function
50 */
51 void connectTCPClientContinue();
52
53 /** Continue to available socket function
54 */
55 void availableSocketContinue();
56
57 /** Continue to flush socket function
58 */
59 void flushSocketContinue();
60
61 public:
62
63 /** Constructor */
64 GSM3ShieldV1ClientProvider();
65
66 /** minSocket
67 @return 0
68 */
69 int minSocket(){return 0;};
70
71 /** maxSocket
72 @return 0
73 */
74 int maxSocket(){return 0;};
75
76 /** Connect to a remote TCP server
77 @param server String with IP or server name
78 @param port Remote port number
79 @param id_socket Local socket number
80 @return 0 if command running, 1 if success, otherwise error
81 */
82 int connectTCPClient(const char* server, int port, int id_socket);
83
84 /** Connect to a remote TCP server
85 @param add Remote IP address
86 @param port Remote port number
87 @param id_socket Local socket number
88 @return 0 if command running, 1 if success, otherwise error
89 */
90 int connectTCPClient(IPAddress add, int port, int id_socket);
91
92 /** Begin writing through a socket
93 @param client1Server0 1 if modem acts as client, 0 if acts as server
94 @param id_socket Local socket number
95 @return 0 if command running, 1 if success, otherwise error
96 */
97 void beginWriteSocket(bool client1Server0, int id_socket);
98
99 /** Write through a socket. MUST go after beginWriteSocket()
100 @param buf characters to be written (final 0 will not be written)
101 */
102 void writeSocket(const char* buf);
103
104 /** Write through a socket. MUST go after beginWriteSocket()
105 @param c character to be written
106 */
107 void writeSocket(uint8_t c);
108
109 /** Finish current writing
110 */
111 void endWriteSocket();
112
113 /** Check if there are data to be read in socket.
114 @param client1Server0 1 if modem acts as client, 0 if acts as server
115 @param id_socket Local socket number
116 @return 0 if command running, 1 if there are data available, 4 if no data, otherwise error
117 */
118 int availableSocket(bool client, int id_socket); // With "available" and "readSocket" ask the modem for 1500 bytes.
119
120 /** Read data (get a character) available in socket
121 @return character
122 */
123 int readSocket(); //If Read() gets to the end of the QIRD response, execute again QIRD SYNCHRONOUSLY
124
125 /** Flush socket
126 */
127 void flushSocket();
128
129 /** Get a character but will not advance the buffer head
130 @return character
131 */
132 int peekSocket();
133
134 /** Close a socket
135 @param client1Server0 1 if modem acts as client, 0 if acts as server
136 @param id_socket Socket
137 @return 0 if command running, 1 if success, otherwise error
138 */
139 int disconnectTCP(bool client1Server0, int id_socket);
140
141 /** Recognize unsolicited event
142 @param oldTail
143 @return true if successful
144 */
145 bool recognizeUnsolicitedEvent(byte from);
146
147 /** Manages modem response
148 @param from Initial byte position
149 @param to Final byte position
150 */
151 void manageResponse(byte from, byte to);
152
153 /** Get last command status
154 @return returns 0 if last command is still executing, 1 success, >1 error
155 */
156 int ready(){return GSM3ShieldV1BaseProvider::ready();};
157
158 // Client socket management, just to be compatible
159 // with the Multi option
160
161 /** Get socket
162 @param socket Socket
163 @return socket
164 */
165 int getSocket(int socket=-1);
166
167 /** Release socket
168 @param socket Socket
169 */
170 void releaseSocket(int socket);
171
172 /** Get socket client status
173 @param socket Socket
174 @return 1 if connected, 0 otherwise
175 */
176 bool getStatusSocketClient(uint8_t socket);
177
178};
179
180
181#endif
Note: See TracBrowser for help on using the repository browser.