[136] | 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 Telefónica 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 _GSM3MOBILENETWORKPROVIDER_
|
---|
| 35 | #define _GSM3MOBILENETWORKPROVIDER_
|
---|
| 36 |
|
---|
| 37 | #include <GSM3MobileAccessProvider.h>
|
---|
| 38 | #include <inttypes.h>
|
---|
| 39 | #include <stddef.h>
|
---|
| 40 | #include <IPAddress.h>
|
---|
| 41 |
|
---|
| 42 | class GSM3MobileNetworkProvider
|
---|
| 43 | {
|
---|
| 44 | private:
|
---|
| 45 |
|
---|
| 46 | /** Restart hardware
|
---|
| 47 | @return 1 if successful
|
---|
| 48 | */
|
---|
| 49 | int HWrestart();
|
---|
| 50 |
|
---|
| 51 | uint16_t socketsAsServer; // Server socket
|
---|
| 52 |
|
---|
| 53 | /** Get modem status
|
---|
| 54 | @param s Socket
|
---|
| 55 | @return modem status (true if connected)
|
---|
| 56 | */
|
---|
| 57 | virtual inline bool getSocketAsServerModemStatus(int s){return false;};
|
---|
| 58 |
|
---|
| 59 | public:
|
---|
| 60 |
|
---|
| 61 | /** minSocketAsServer
|
---|
| 62 | @return 0
|
---|
| 63 | */
|
---|
| 64 | virtual inline int minSocketAsServer(){return 0;};
|
---|
| 65 |
|
---|
| 66 | /** maxSocketAsServer
|
---|
| 67 | @return 0
|
---|
| 68 | */
|
---|
| 69 | virtual inline int maxSocketAsServer(){return 0;};
|
---|
| 70 |
|
---|
| 71 | /** Get last command status
|
---|
| 72 | @return returns 0 if last command is still executing, 1 success, >1 error
|
---|
| 73 | */
|
---|
| 74 | virtual int ready()=0;
|
---|
| 75 |
|
---|
| 76 | /** Constructor */
|
---|
| 77 | GSM3MobileNetworkProvider();
|
---|
| 78 |
|
---|
| 79 | /** Get network status
|
---|
| 80 | @return network status
|
---|
| 81 | */
|
---|
| 82 | virtual inline GSM3_NetworkStatus_t getStatus(){return ERROR;};
|
---|
| 83 |
|
---|
| 84 | /** Get socket client status
|
---|
| 85 | @param socket Socket
|
---|
| 86 | @return 1 if connected, 0 otherwise
|
---|
| 87 | */
|
---|
| 88 | bool getStatusSocketClient(uint8_t socket);
|
---|
| 89 |
|
---|
| 90 | /** Close a AT command
|
---|
| 91 | @param code Close code
|
---|
| 92 | */
|
---|
| 93 | virtual inline void closeCommand(int code){};
|
---|
| 94 |
|
---|
| 95 | /** Establish a TCP connection
|
---|
| 96 | @param port Port
|
---|
| 97 | @param localIP IP address
|
---|
| 98 | @param localIPlength IP address size in characters
|
---|
| 99 | @return command error if exists
|
---|
| 100 | */
|
---|
| 101 | virtual inline int connectTCPServer(int port, char* localIP, int localIPlength){return 0;};
|
---|
| 102 |
|
---|
| 103 | /** Get local IP address
|
---|
| 104 | @param LocalIP Buffer for save IP address
|
---|
| 105 | @param LocalIPlength Buffer size
|
---|
| 106 | */
|
---|
| 107 | virtual inline int getIP(char* LocalIP, int LocalIPlength){return 0;};
|
---|
| 108 |
|
---|
| 109 | /** Get new occupied socket
|
---|
| 110 | @return -1 if no new socket has been occupied
|
---|
| 111 | */
|
---|
| 112 | int getNewOccupiedSocketAsServer();
|
---|
| 113 |
|
---|
| 114 | /** Get socket status as server
|
---|
| 115 | @param socket Socket to get status
|
---|
| 116 | @return socket status
|
---|
| 117 | */
|
---|
| 118 | bool getStatusSocketAsServer(uint8_t socket);
|
---|
| 119 |
|
---|
| 120 | /** Close a socket
|
---|
| 121 | @param client1Server0 1 if modem acts as client, 0 if acts as server
|
---|
| 122 | @param id_socket Local socket number
|
---|
| 123 | @return 0 if command running, 1 if success, otherwise error
|
---|
| 124 | */
|
---|
| 125 | int disconnectTCP(bool client1Server0, int idsocket){return 1;};
|
---|
| 126 |
|
---|
| 127 | /** Release socket
|
---|
| 128 | @param socket Socket
|
---|
| 129 | */
|
---|
| 130 | void releaseSocket(int socket){};
|
---|
| 131 |
|
---|
| 132 | };
|
---|
| 133 |
|
---|
| 134 | extern GSM3MobileNetworkProvider* theProvider;
|
---|
| 135 |
|
---|
| 136 | #endif
|
---|