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:
jengbrecht
Date:
Tue Dec 17 23:56:20 2013 +0000
Revision:
27:8e6188cbcfd4
Parent:
23:bc6f98a1eb22
Child:
30:06c756af6c5c
Child:
32:629e6b1c8e22
Added a ton of documentation to Cellular.h and IPStack.h including some sample application code.

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