[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 __GSM3_SHIELDV1__
|
---|
| 35 | #define __GSM3_SHIELDV1__
|
---|
| 36 |
|
---|
| 37 | #include <GSM3MobileNetworkProvider.h>
|
---|
| 38 | #include <GSM3ShieldV1ModemCore.h>
|
---|
| 39 | #include <GSM3ShieldV1BaseProvider.h>
|
---|
| 40 | #include <Arduino.h>
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | class GSM3ShieldV1 : public GSM3MobileNetworkProvider, public GSM3ShieldV1BaseProvider
|
---|
| 44 | {
|
---|
| 45 | // General code, for modem management
|
---|
| 46 | private:
|
---|
| 47 |
|
---|
| 48 | /** Delay inside an interrupt (2 seconds)
|
---|
| 49 | */
|
---|
| 50 | void delayInsideInterrupt2seg();
|
---|
| 51 |
|
---|
| 52 | // Code for SMS Service
|
---|
| 53 | private:
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | long commandMillis;
|
---|
| 57 | bool commandSent;
|
---|
| 58 |
|
---|
| 59 | const char* pinConfig; //PIN.
|
---|
| 60 | char* accessPoint; //APN.
|
---|
| 61 | char* userName; //User.
|
---|
| 62 | char* passw; //Password.
|
---|
| 63 | const char* remoteID; //Server.
|
---|
| 64 |
|
---|
| 65 | char* dataSocket; //Data socket.
|
---|
| 66 | int local_Port; //Local Port.
|
---|
| 67 | char* local_IP; //Local IP.
|
---|
| 68 | int local_IP_Length; //Local IP length.
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | int socketDataSize; //Size of socket data to be read.
|
---|
| 72 | int socketDataSizeWritten; //Number of socket data written in buffer not to overflow the buffer
|
---|
| 73 |
|
---|
| 74 | int socketsAccepted; //Status for remote clients accepted of closed.
|
---|
| 75 |
|
---|
| 76 | public:
|
---|
| 77 |
|
---|
| 78 | /** Constructor **/
|
---|
| 79 | GSM3ShieldV1(bool debug=false);
|
---|
| 80 |
|
---|
| 81 | /** Manages modem response
|
---|
| 82 | @param from Initial byte of buffer
|
---|
| 83 | @param to Final byte of buffer
|
---|
| 84 | */
|
---|
| 85 | void manageResponse(byte from, byte to);
|
---|
| 86 |
|
---|
| 87 | /** Get last command status
|
---|
| 88 | @return returns 0 if last command is still executing, 1 success, >1 error
|
---|
| 89 | */
|
---|
| 90 | int ready(){return GSM3ShieldV1BaseProvider::ready();};
|
---|
| 91 |
|
---|
| 92 | /** Parse modem response
|
---|
| 93 | @param rsp Returns true if expected response exists
|
---|
| 94 | @param string1 Substring expected in response
|
---|
| 95 | @param string2 Second substring expected in response
|
---|
| 96 | @return true if parsed successful
|
---|
| 97 | */
|
---|
| 98 | bool genericParse_rsp2(bool& rsp, char* string1, char* string2);
|
---|
| 99 |
|
---|
| 100 | /** Recognize URC
|
---|
| 101 | @param oldTail
|
---|
| 102 | @return true if successful
|
---|
| 103 | */
|
---|
| 104 | bool recognizeUnsolicitedEvent(byte oldTail);
|
---|
| 105 |
|
---|
| 106 | /** Receive answer
|
---|
| 107 | @return true if successful
|
---|
| 108 | */
|
---|
| 109 | bool answerReceived();
|
---|
| 110 |
|
---|
| 111 | /** Receive socket
|
---|
| 112 | @param id_socket Socket ID
|
---|
| 113 | @return true if successful
|
---|
| 114 | */
|
---|
| 115 | bool socketReceived(int id_socket);
|
---|
| 116 |
|
---|
| 117 | /** Update active ID sockets
|
---|
| 118 | @param active Active sockets
|
---|
| 119 | @param ID Id for update
|
---|
| 120 | */
|
---|
| 121 | void update_activeIDsockets (bool active, int ID);
|
---|
| 122 |
|
---|
| 123 | /** Assign ID to socket
|
---|
| 124 | @param ID Id to assign to socket
|
---|
| 125 | @return true if successful
|
---|
| 126 | */
|
---|
| 127 | bool assignIDsocket (int& ID);
|
---|
| 128 |
|
---|
| 129 | /** Close data socket
|
---|
| 130 | @return true if successful
|
---|
| 131 | */
|
---|
| 132 | bool closedDataSocket(); //Flag closed current data socket.
|
---|
| 133 |
|
---|
| 134 | //bool writeIncomingCalls(char* bufferForCallerId) If isn't zero, doesn't wait calls
|
---|
| 135 | };
|
---|
| 136 |
|
---|
| 137 | #endif
|
---|