Arduino  1.8.10
GSM3MobileClientProvider.h
[詳解]
1 /*
2 This 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 
11 This library has been developed by Telefnica Digital - PDI -
12 - Physical Internet Lab, as part as its collaboration with
13 Arduino and the Open Hardware Community.
14 
15 September-December 2012
16 
17 This library is free software; you can redistribute it and/or
18 modify it under the terms of the GNU Lesser General Public
19 License as published by the Free Software Foundation; either
20 version 2.1 of the License, or (at your option) any later version.
21 
22 This library is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 Lesser General Public License for more details.
26 
27 You should have received a copy of the GNU Lesser General Public
28 License along with this library; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 
31 The latest version of this library can always be found at
32 https://github.com/BlueVia/Official-Arduino
33 */
34 #ifndef __GSM3_MOBILECLIENTPROVIDER__
35 #define __GSM3_MOBILECLIENTPROVIDER__
36 
37 #include <Arduino.h>
38 #include <IPAddress.h>
39 
41 {
42  protected:
43 
44  uint8_t sockets;
45 
46  public:
47 
48  /** Constructor */
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 
155 
156 #endif
EthernetClient client
virtual int maxSocket()=0
virtual void endWriteSocket()=0
virtual void flushSocket()=0
virtual int getSocket(int socket=-1)=0
virtual void beginWriteSocket(bool client1Server0, int id_socket)=0
virtual int connectTCPClient(const char *server, int port, int id_socket)=0
virtual void releaseSocket(int socket)=0
virtual void writeSocket(uint8_t c)=0
GSM3MobileClientProvider * theGSM3MobileClientProvider
virtual int peekSocket()=0
virtual int minSocket()=0
virtual int ready()=0
virtual bool getStatusSocketClient(uint8_t socket)=0
virtual int disconnectTCP(bool client1Server0, int idsocket)=0
virtual int readSocket()=0
virtual int availableSocket(bool client, int id_socket)=0