A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Committer:
sgodinez
Date:
Wed Dec 18 22:45:53 2013 +0000
Revision:
32:629e6b1c8e22
Parent:
27:8e6188cbcfd4
Child:
33:e04aa7c013c9
Successfully recognizes when remote endpoint closes socket.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jengbrecht 0:563b70517320 1 #ifndef CELLULAR_H
jengbrecht 0:563b70517320 2 #define CELLULAR_H
jengbrecht 0:563b70517320 3
sgodinez 11:134435d8a2d5 4 #include "IPStack.h"
sgodinez 11:134435d8a2d5 5 #include "MTSBufferedIO.h"
jengbrecht 0:563b70517320 6 #include "mbed.h"
jengbrecht 0:563b70517320 7 #include <string>
sgodinez 4:6561c9128c6f 8 #include <vector>
jengbrecht 0:563b70517320 9
jengbrecht 27:8e6188cbcfd4 10 #define PINGDELAY 3 //Time to wait on each ping for a response before timimg out (seconds)
jengbrecht 27:8e6188cbcfd4 11 #define PINGNUM 4 //Number of pings to try on ping command
jengbrecht 27:8e6188cbcfd4 12
sgodinez 32:629e6b1c8e22 13 //Special Payload Characters
sgodinez 32:629e6b1c8e22 14 const char ETX = 0x03; //Ends socket connection
sgodinez 32:629e6b1c8e22 15 const char DLE = 0x10; //Escapes ETX and DLE within Payload
sgodinez 32:629e6b1c8e22 16
jengbrecht 27:8e6188cbcfd4 17 // An array of strings for printing the names of the Code enum.
jengbrecht 27:8e6188cbcfd4 18 const string CodeNames[] = {"OK", "ERROR", "NO_RESPONSE", "FAILURE"};
jengbrecht 27:8e6188cbcfd4 19
jengbrecht 27:8e6188cbcfd4 20 // An array of strings for printing the names of the Registration enum.
jengbrecht 27:8e6188cbcfd4 21 const string RegistrationNames[] = {"NOT_REGISTERED", "REGISTERED", "SEARCHING", "DENIED", "UNKNOWN", "ROAMING"};
jengbrecht 27:8e6188cbcfd4 22
jengbrecht 27:8e6188cbcfd4 23
jengbrecht 27:8e6188cbcfd4 24 /** This is a class for communicating with a Multi-Tech Systems SocketModem iCell. The
jengbrecht 27:8e6188cbcfd4 25 * SocketModem iCell is a family of carrier certified embedded cellular radio modules with
jengbrecht 27:8e6188cbcfd4 26 * a common hardware footprint and AT command set for built in IP-stack functionality.
jengbrecht 27:8e6188cbcfd4 27 * This class supports three main types of cellular radio interactions including:
jengbrecht 27:8e6188cbcfd4 28 * configuration and status AT command processing, SMS processing, and TCP/UDP Socket
jengbrecht 27:8e6188cbcfd4 29 * data connections. It should be noted that the radio can not process commands or
jengbrecht 27:8e6188cbcfd4 30 * SMS messages while having an open data connection at the same time. The concurrent
jengbrecht 27:8e6188cbcfd4 31 * capability may be added in a future release. This class also inherits from IPStack
jengbrecht 27:8e6188cbcfd4 32 * providing a common set of commands for communication devices that have an onboard
jengbrecht 27:8e6188cbcfd4 33 * IP Stack. It is also integrated with the standard Mbed Sockets package and can therefore
jengbrecht 27:8e6188cbcfd4 34 * be used seamlessly with clients and services built on top of this interface already within
jengbrecht 27:8e6188cbcfd4 35 * the Mbed library.
jengbrecht 27:8e6188cbcfd4 36 *
jengbrecht 27:8e6188cbcfd4 37 * All of the following examples use the Pin Names for the Freedom KL46Z board coupled with
jengbrecht 27:8e6188cbcfd4 38 * the SocketModem Shield Arduino compatible board. Please chage Pin Names accordingly to
jengbrecht 27:8e6188cbcfd4 39 * match your hardware configuration. It also assumes the use of RTS/CTS hardware handshaking
jengbrecht 27:8e6188cbcfd4 40 * using GPIOs. To disable this you will need to change settings on the radio module and
jengbrecht 27:8e6188cbcfd4 41 * and use the MTSSerial class instead of MTSSerialFlowControl. The default baud rate for the
jengbrecht 27:8e6188cbcfd4 42 * cellular radio is 115200 bps.
jengbrecht 27:8e6188cbcfd4 43 *
jengbrecht 27:8e6188cbcfd4 44 * The following set of example code demonstrates how to send and receive configuration and
jengbrecht 27:8e6188cbcfd4 45 * status AT commands with the radio:
jengbrecht 27:8e6188cbcfd4 46 * @code
jengbrecht 27:8e6188cbcfd4 47 * #include "mbed.h"
jengbrecht 27:8e6188cbcfd4 48 * #include "Cellular.h"
jengbrecht 27:8e6188cbcfd4 49 * #include "MTSSerialFlowControl.h"
jengbrecht 27:8e6188cbcfd4 50 *
jengbrecht 27:8e6188cbcfd4 51 * main() {
jengbrecht 27:8e6188cbcfd4 52 * //Wait for radio to boot up
jengbrecht 27:8e6188cbcfd4 53 * wait(15);
jengbrecht 27:8e6188cbcfd4 54 *
jengbrecht 27:8e6188cbcfd4 55 * //Setup serial interface to radio
jengbrecht 27:8e6188cbcfd4 56 * MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8);
jengbrecht 27:8e6188cbcfd4 57 * serial->baud(115200);
jengbrecht 27:8e6188cbcfd4 58 *
jengbrecht 27:8e6188cbcfd4 59 * //Setup Cellular class
jengbrecht 27:8e6188cbcfd4 60 * Cellular* cellular = Cellular::getInstance(serial);
jengbrecht 27:8e6188cbcfd4 61 *
jengbrecht 27:8e6188cbcfd4 62 * //Run status and configuration commands
jengbrecht 27:8e6188cbcfd4 63 * printf("Start Status and Configuration Example\n\r");
jengbrecht 27:8e6188cbcfd4 64 * printf("test: %s\n\r", CodeNames[cellular->test()]);
jengbrecht 27:8e6188cbcfd4 65 * printf("Phone Number: %s\n\r", cellular->getPhoneNumber());
jengbrecht 27:8e6188cbcfd4 66 * printf("Signal Strength: %d\n\r", cellular->getSignalStrength());
jengbrecht 27:8e6188cbcfd4 67 * printf("Registration State: %s\n\r", RegistrationNames[cellular->getRegistration()]);
jengbrecht 27:8e6188cbcfd4 68 * printf("Send Basic Command (AT): %s\n\r", CodeNames[cellular->sendBasicCommand("AT", 1000)]);
jengbrecht 27:8e6188cbcfd4 69 * printf("Send Command (AT+CSQ): %s\n\r", sendCommand("AT+CSQ", 1000));
jengbrecht 27:8e6188cbcfd4 70 *
jengbrecht 27:8e6188cbcfd4 71 * printf("End Program\n\r");
jengbrecht 27:8e6188cbcfd4 72 * }
jengbrecht 27:8e6188cbcfd4 73 * @endcode
jengbrecht 27:8e6188cbcfd4 74 *
jengbrecht 27:8e6188cbcfd4 75 * The following set of example code demonstrates how process SMS messages:
jengbrecht 27:8e6188cbcfd4 76 * @code
jengbrecht 27:8e6188cbcfd4 77 * #include "mbed.h"
jengbrecht 27:8e6188cbcfd4 78 * @endcode
jengbrecht 27:8e6188cbcfd4 79 *
jengbrecht 27:8e6188cbcfd4 80 * The following set of example code demonstrates how to setup and verify a cellular data
jengbrecht 27:8e6188cbcfd4 81 * connection:
jengbrecht 27:8e6188cbcfd4 82 * @code
jengbrecht 27:8e6188cbcfd4 83 * #include "mbed.h"
jengbrecht 27:8e6188cbcfd4 84 * #include "Cellular.h"
jengbrecht 27:8e6188cbcfd4 85 * #include "MTSSerialFlowControl.h"
jengbrecht 27:8e6188cbcfd4 86 *
jengbrecht 27:8e6188cbcfd4 87 * main() {
jengbrecht 27:8e6188cbcfd4 88 * //Wait for radio to boot up
jengbrecht 27:8e6188cbcfd4 89 * wait(20);
jengbrecht 27:8e6188cbcfd4 90 *
jengbrecht 27:8e6188cbcfd4 91 * //Setup serial interface to radio
jengbrecht 27:8e6188cbcfd4 92 * MTSSerialFlowControl* serial = new MTSSerialFlowControl(PTD3, PTD2, PTA12, PTC8);
jengbrecht 27:8e6188cbcfd4 93 * serial->baud(115200);
jengbrecht 27:8e6188cbcfd4 94 *
jengbrecht 27:8e6188cbcfd4 95 * //Setup Cellular class
jengbrecht 27:8e6188cbcfd4 96 * Cellular* cellular = Cellular::getInstance(serial);
jengbrecht 27:8e6188cbcfd4 97 *
jengbrecht 27:8e6188cbcfd4 98 * //Start Test
jengbrecht 27:8e6188cbcfd4 99 * printf("Start Network Connectivity Example\n\r");
jengbrecht 27:8e6188cbcfd4 100 * printf("test: %s\n\r", CodeNames[cellular->test()]);
jengbrecht 27:8e6188cbcfd4 101 * printf("Set APN: %s\n\r", CodeNames[cellular->setApn("wap.cingular")]) //Use APN from service provider!!!
jengbrecht 27:8e6188cbcfd4 102 *
jengbrecht 27:8e6188cbcfd4 103 * //Setup a data connection
jengbrecht 27:8e6188cbcfd4 104 * printf("Attempting to Connect\n\r");
jengbrecht 27:8e6188cbcfd4 105 * while (cellular->connect()) {
jengbrecht 27:8e6188cbcfd4 106 * wait(1);
jengbrecht 27:8e6188cbcfd4 107 * }
jengbrecht 27:8e6188cbcfd4 108 * printf("Connected to Network!\n\r");
jengbrecht 27:8e6188cbcfd4 109 *
jengbrecht 27:8e6188cbcfd4 110 * //Try pinging default server "8.8.8.8"
jengbrecht 27:8e6188cbcfd4 111 * printf("Ping Valid: %s\n\r", cellular->ping() ? "true" : "false");
jengbrecht 27:8e6188cbcfd4 112 *
jengbrecht 27:8e6188cbcfd4 113 * printf("End Program\n\r");
jengbrecht 27:8e6188cbcfd4 114 * }
jengbrecht 27:8e6188cbcfd4 115 * @endcode
jengbrecht 27:8e6188cbcfd4 116 *
jengbrecht 27:8e6188cbcfd4 117 * The following set of example code demonstrates how to setup and use a TCP socket connection
jengbrecht 27:8e6188cbcfd4 118 * using the native commands from this class:
jengbrecht 27:8e6188cbcfd4 119 * @code
jengbrecht 27:8e6188cbcfd4 120 * #include "mbed.h"
jengbrecht 27:8e6188cbcfd4 121 * @endcode
jengbrecht 27:8e6188cbcfd4 122 *
jengbrecht 27:8e6188cbcfd4 123 * The following set of example code demonstrates how to setup and use a TCP socket connection
jengbrecht 27:8e6188cbcfd4 124 * using the Mbed compatible Socket interfaces.
jengbrecht 27:8e6188cbcfd4 125 * @code
jengbrecht 27:8e6188cbcfd4 126 * #include "mbed.h"
jengbrecht 27:8e6188cbcfd4 127 * @endcode
jengbrecht 27:8e6188cbcfd4 128 */
jengbrecht 23:bc6f98a1eb22 129
sgodinez 11:134435d8a2d5 130 class Cellular : virtual IPStack
jengbrecht 0:563b70517320 131 {
jengbrecht 0:563b70517320 132 public:
jengbrecht 27:8e6188cbcfd4 133 /// An enumeration for common responses to an AT command.
jengbrecht 0:563b70517320 134 enum Code {
jengbrecht 0:563b70517320 135 OK, ERROR, NO_RESPONSE, FAILURE
jengbrecht 0:563b70517320 136 };
jengbrecht 0:563b70517320 137
jengbrecht 27:8e6188cbcfd4 138 /// An enumeration for escape characters at the end of AT commands.
jengbrecht 0:563b70517320 139 enum ESC_CHAR {
sgodinez 13:0af863114629 140 CR, CTRL_Z, NONE
jengbrecht 0:563b70517320 141 };
jengbrecht 0:563b70517320 142
jengbrecht 27:8e6188cbcfd4 143 /// An enumeration of radio registration states with a cell tower.
jengbrecht 0:563b70517320 144 enum Registration {
jengbrecht 0:563b70517320 145 NOT_REGISTERED, REGISTERED, SEARCHING, DENIED, UNKNOWN, ROAMING
jengbrecht 0:563b70517320 146 };
jengbrecht 0:563b70517320 147
sgodinez 4:6561c9128c6f 148 struct Sms {
jengbrecht 27:8e6188cbcfd4 149 std::string phoneNumber;
jengbrecht 27:8e6188cbcfd4 150 std::string message;
jengbrecht 27:8e6188cbcfd4 151 std::string timestamp;
sgodinez 4:6561c9128c6f 152 };
jengbrecht 27:8e6188cbcfd4 153
jengbrecht 27:8e6188cbcfd4 154 /** Destructs a Cellular object and frees all related resources.
jengbrecht 27:8e6188cbcfd4 155 */
jengbrecht 0:563b70517320 156 ~Cellular();
jengbrecht 27:8e6188cbcfd4 157
sgodinez 19:38794784e009 158 static Cellular* getInstance();
sgodinez 19:38794784e009 159 static Cellular* getInstance(MTSBufferedIO* io);
jengbrecht 0:563b70517320 160
jengbrecht 27:8e6188cbcfd4 161 /** This method establishes a data connection on the cellular radio.
jengbrecht 27:8e6188cbcfd4 162 * Note that before calling you must have an activated radio and if
jengbrecht 27:8e6188cbcfd4 163 * using a SIM card set the APN using the setApn method. The APN can
jengbrecht 27:8e6188cbcfd4 164 * be obtained from your cellular service provider.
jengbrecht 27:8e6188cbcfd4 165 *
jengbrecht 27:8e6188cbcfd4 166 * @returns true if the connection was successfully established, otherwise
jengbrecht 27:8e6188cbcfd4 167 * false on an error.
jengbrecht 27:8e6188cbcfd4 168 */
jengbrecht 27:8e6188cbcfd4 169 virtual bool connect();
jengbrecht 27:8e6188cbcfd4 170
jengbrecht 27:8e6188cbcfd4 171 /** This method is used to stop a previously established cellular data connection.
jengbrecht 27:8e6188cbcfd4 172 */
sgodinez 11:134435d8a2d5 173 virtual void disconnect();
jengbrecht 27:8e6188cbcfd4 174
jengbrecht 27:8e6188cbcfd4 175 /** This method is used to check if the radio currently has a data connection
jengbrecht 27:8e6188cbcfd4 176 * established.
jengbrecht 27:8e6188cbcfd4 177 *
jengbrecht 27:8e6188cbcfd4 178 * @returns true if a data connection exists, otherwise false.
jengbrecht 27:8e6188cbcfd4 179 */
sgodinez 11:134435d8a2d5 180 virtual bool isConnected();
jengbrecht 0:563b70517320 181
sgodinez 11:134435d8a2d5 182 // Used for TCPSocketConnection & UDPSocketConnection
sgodinez 11:134435d8a2d5 183 virtual bool bind(unsigned int port);
sgodinez 11:134435d8a2d5 184 virtual bool open(const std::string& address, unsigned int port, Mode mode);
sgodinez 11:134435d8a2d5 185 virtual bool isOpen();
sgodinez 17:2d7c4ea7491b 186 virtual bool close();
sgodinez 11:134435d8a2d5 187 virtual int read(char* data, int max, int timeout = -1);
sgodinez 11:134435d8a2d5 188 virtual int write(char* data, int length, int timeout = -1);
sgodinez 11:134435d8a2d5 189 virtual unsigned int readable();
sgodinez 11:134435d8a2d5 190 virtual unsigned int writeable();
jengbrecht 27:8e6188cbcfd4 191
sgodinez 11:134435d8a2d5 192 //Other
jengbrecht 27:8e6188cbcfd4 193 virtual void reset();
sgodinez 11:134435d8a2d5 194
jengbrecht 27:8e6188cbcfd4 195 /** A method for sending a generic AT command to the radio. Note that you cannot
jengbrecht 27:8e6188cbcfd4 196 * send commands and have a data connection at the same time.
jengbrecht 27:8e6188cbcfd4 197 *
jengbrecht 27:8e6188cbcfd4 198 * @param command the command to send to the radio without the escape character.
jengbrecht 27:8e6188cbcfd4 199 * @param timeoutMillis the time in millis to wait for a response before returning.
jengbrecht 27:8e6188cbcfd4 200 * @param esc escape character to add at the end of the command, defaults to
jengbrecht 27:8e6188cbcfd4 201 * carriage return (CR).
jengbrecht 27:8e6188cbcfd4 202 * @returns all data received from the radio after the command as a string.
jengbrecht 27:8e6188cbcfd4 203 */
sgodinez 11:134435d8a2d5 204 std::string sendCommand(std::string command, int timeoutMillis, ESC_CHAR esc = CR);
jengbrecht 27:8e6188cbcfd4 205
jengbrecht 27:8e6188cbcfd4 206 /** A method for sending a basic AT command to the radio. A basic AT command is
jengbrecht 27:8e6188cbcfd4 207 * one that simply has a response of either OK or ERROR without any other information.
jengbrecht 27:8e6188cbcfd4 208 * Note that you cannot send commands and have a data connection at the same time.
jengbrecht 27:8e6188cbcfd4 209 *
jengbrecht 27:8e6188cbcfd4 210 * @param command the command to send to the radio without the escape character.
jengbrecht 27:8e6188cbcfd4 211 * @param timeoutMillis the time in millis to wait for a response before returning.
jengbrecht 27:8e6188cbcfd4 212 * @param esc escape character to add at the end of the command, defaults to
jengbrecht 27:8e6188cbcfd4 213 * carriage return (CR).
jengbrecht 27:8e6188cbcfd4 214 * @returns the standard AT Code enumeration.
jengbrecht 27:8e6188cbcfd4 215 */
sgodinez 11:134435d8a2d5 216 Code sendBasicCommand(std::string command, int timeoutMillis, ESC_CHAR esc = CR);
sgodinez 11:134435d8a2d5 217
jengbrecht 23:bc6f98a1eb22 218 /** A method for testing command access to the radio. This method sends the
jengbrecht 27:8e6188cbcfd4 219 * command "AT" to the radio, which is a standard radio test to see if you
jengbrecht 23:bc6f98a1eb22 220 * have command access to the radio.
jengbrecht 23:bc6f98a1eb22 221 *
jengbrecht 23:bc6f98a1eb22 222 * @returns the standard AT Code enumeration.
jengbrecht 23:bc6f98a1eb22 223 */
sgodinez 11:134435d8a2d5 224 Code test();
jengbrecht 27:8e6188cbcfd4 225
jengbrecht 23:bc6f98a1eb22 226 /** A method for configuring command ehco capability on the radio. This command
jengbrecht 23:bc6f98a1eb22 227 * sets whether sent characters are echoed back from the radio, in which case you
jengbrecht 23:bc6f98a1eb22 228 * will receive back every command you send.
jengbrecht 23:bc6f98a1eb22 229 *
jengbrecht 23:bc6f98a1eb22 230 * @param state if true echo will be turned off, otherwise it will be turned on.
jengbrecht 23:bc6f98a1eb22 231 * @returns the standard AT Code enumeration.
jengbrecht 23:bc6f98a1eb22 232 */
jengbrecht 0:563b70517320 233 Code echoOff(bool state);
jengbrecht 27:8e6188cbcfd4 234
jengbrecht 23:bc6f98a1eb22 235 /** A method for getting the signal strength of the radio. This method allows you to
jengbrecht 23:bc6f98a1eb22 236 * get a value that maps to signal strength in dBm. Here 0-1 is Poor, 2-9 is Marginal,
jengbrecht 23:bc6f98a1eb22 237 * 10-14 is Ok, 15-19 is Good, and 20+ is Excellent. If you get a result of 99 the
jengbrecht 27:8e6188cbcfd4 238 * signal strength is not known or not detectable.
jengbrecht 23:bc6f98a1eb22 239 *
jengbrecht 23:bc6f98a1eb22 240 * @returns an integer representing the signal strength.
jengbrecht 23:bc6f98a1eb22 241 */
jengbrecht 0:563b70517320 242 int getSignalStrength();
jengbrecht 27:8e6188cbcfd4 243
jengbrecht 27:8e6188cbcfd4 244 /** This method is used to get the phone number of the cellular radio if one exists.
jengbrecht 27:8e6188cbcfd4 245 *
jengbrecht 27:8e6188cbcfd4 246 * @returns the phone number as a string, otherwise "unknown" if it does not exist.
jengbrecht 27:8e6188cbcfd4 247 */
sgodinez 5:93e889a5abc6 248 std::string getPhoneNumber();
jengbrecht 27:8e6188cbcfd4 249
jengbrecht 27:8e6188cbcfd4 250 /** This method is used to check the registration state of the radio with the cell tower.
jengbrecht 27:8e6188cbcfd4 251 * If not appropriatley registered with the tower you cannot make a cellular connection.
jengbrecht 27:8e6188cbcfd4 252 *
jengbrecht 27:8e6188cbcfd4 253 * @returns the registration state as an enumeration type.
jengbrecht 27:8e6188cbcfd4 254 */
sgodinez 5:93e889a5abc6 255 Registration getRegistration();
jengbrecht 27:8e6188cbcfd4 256
jengbrecht 27:8e6188cbcfd4 257 /** This method is used to set the radios APN if using a SIM card. Note that the APN
jengbrecht 27:8e6188cbcfd4 258 * must be set correctly before you can make a data connection. The APN for your SIM
jengbrecht 27:8e6188cbcfd4 259 * can be obtained by contacting your cellular service provider.
jengbrecht 27:8e6188cbcfd4 260 *
jengbrecht 27:8e6188cbcfd4 261 * @param the APN as a string.
jengbrecht 27:8e6188cbcfd4 262 * @returns the standard AT Code enumeration.
jengbrecht 27:8e6188cbcfd4 263 */
sgodinez 11:134435d8a2d5 264 Code setApn(const std::string& apn);
jengbrecht 27:8e6188cbcfd4 265
jengbrecht 27:8e6188cbcfd4 266 /** This method is used to set the DNS which enables the use of URLs instead
jengbrecht 27:8e6188cbcfd4 267 * of IP addresses when making a socket connection.
jengbrecht 27:8e6188cbcfd4 268 *
jengbrecht 27:8e6188cbcfd4 269 * @param the DNS server address as a string in form xxx.xxx.xxx.xxx.
jengbrecht 27:8e6188cbcfd4 270 * @returns the standard AT Code enumeration.
jengbrecht 27:8e6188cbcfd4 271 */
jengbrecht 27:8e6188cbcfd4 272 Code setDns(const std::string& address);
jengbrecht 27:8e6188cbcfd4 273
jengbrecht 27:8e6188cbcfd4 274 /** This method is used test network connectivity by pinging a server.
jengbrecht 27:8e6188cbcfd4 275 *
jengbrecht 27:8e6188cbcfd4 276 * @param address the address of the server in format xxx.xxx.xxx.xxx.
jengbrecht 27:8e6188cbcfd4 277 * @returns true if the ping was successful, otherwise false.
jengbrecht 27:8e6188cbcfd4 278 */
jengbrecht 23:bc6f98a1eb22 279 bool ping(const std::string& address = "8.8.8.8");
sgodinez 17:2d7c4ea7491b 280 Code setSocketCloseable(bool enabled = true); //ETX closes socket (ETX and DLE in payload are escaped with DLE)
jengbrecht 27:8e6188cbcfd4 281
jengbrecht 27:8e6188cbcfd4 282 /** This method is used to send an SMS message. Note that you cannot send an
jengbrecht 27:8e6188cbcfd4 283 * SMS message and have a data connection open at the same time.
jengbrecht 27:8e6188cbcfd4 284 *
jengbrecht 27:8e6188cbcfd4 285 * @param phoneNumber the phone number to send the message to as a string.
jengbrecht 27:8e6188cbcfd4 286 * @param message the text message to be sent.
jengbrecht 27:8e6188cbcfd4 287 * @returns the standard AT Code enumeration.
jengbrecht 27:8e6188cbcfd4 288 */
jengbrecht 27:8e6188cbcfd4 289 Code sendSMS(const std::string& phoneNumber, const std::string& message);
sgodinez 4:6561c9128c6f 290
jengbrecht 27:8e6188cbcfd4 291 /** This method is used to send an SMS message. Note that you cannot send an
jengbrecht 27:8e6188cbcfd4 292 * SMS message and have a data connection open at the same time.
jengbrecht 27:8e6188cbcfd4 293 *
jengbrecht 27:8e6188cbcfd4 294 * @param sms an Sms struct that contains all SMS transaction information.
jengbrecht 27:8e6188cbcfd4 295 * @returns the standard AT Code enumeration.
jengbrecht 27:8e6188cbcfd4 296 */
sgodinez 4:6561c9128c6f 297 Code sendSMS(const Sms& sms);
jengbrecht 27:8e6188cbcfd4 298
jengbrecht 27:8e6188cbcfd4 299 /**
jengbrecht 27:8e6188cbcfd4 300 *
jengbrecht 27:8e6188cbcfd4 301 */
sgodinez 4:6561c9128c6f 302 std::vector<Cellular::Sms> getReceivedSms();
sgodinez 4:6561c9128c6f 303 Code deleteAllReceivedSms();
sgodinez 4:6561c9128c6f 304 Code deleteOnlyReceivedReadSms();
sgodinez 19:38794784e009 305
jengbrecht 27:8e6188cbcfd4 306
jengbrecht 0:563b70517320 307 private:
jengbrecht 23:bc6f98a1eb22 308 static Cellular* instance; //Static pointer to the single Cellular object.
sgodinez 19:38794784e009 309
jengbrecht 23:bc6f98a1eb22 310 MTSBufferedIO* io; //IO interface obect that the radio is accessed through.
jengbrecht 23:bc6f98a1eb22 311 bool echoMode; //Specifies if the echo mode is currently enabled.
jengbrecht 27:8e6188cbcfd4 312
jengbrecht 23:bc6f98a1eb22 313 bool pppConnected; //Specifies if a PPP session is currently connected.
jengbrecht 23:bc6f98a1eb22 314 std::string apn; //A string that holds the APN for the radio.
jengbrecht 27:8e6188cbcfd4 315
jengbrecht 27:8e6188cbcfd4 316 Mode mode;
jengbrecht 23:bc6f98a1eb22 317 bool socketOpened; //Specifies if a Socket is presently opened.
jengbrecht 23:bc6f98a1eb22 318 bool socketCloseable; //Specifies is a Socket can be closed.
jengbrecht 27:8e6188cbcfd4 319 unsigned int local_port; //Holds the local port for socket connections.
jengbrecht 27:8e6188cbcfd4 320 std::string local_address; //Holds the local address for socket connections.
jengbrecht 27:8e6188cbcfd4 321 unsigned int host_port; //Holds the remote port for socket connections.
jengbrecht 27:8e6188cbcfd4 322 std::string host_address; //Holds the remote address for socket connections.
sgodinez 11:134435d8a2d5 323
jengbrecht 23:bc6f98a1eb22 324 Cellular(); //Private constructor, use the getInstance() method.
jengbrecht 23:bc6f98a1eb22 325 Cellular(MTSBufferedIO* io); //Private constructor, use the getInstance method.
jengbrecht 27:8e6188cbcfd4 326
jengbrecht 0:563b70517320 327 };
jengbrecht 0:563b70517320 328
jengbrecht 0:563b70517320 329 #endif /* CELLULAR_H */