Cellular library for MTS Socket Modem Arduino Shield devices from Multi-Tech Systems

Dependents:   mtsas mtsas mtsas mtsas

Committer:
Mike Fiore
Date:
Wed May 21 15:39:35 2014 -0500
Revision:
9:1a03e3f3e7fe
Parent:
8:2d7259d244d1
Child:
10:c188cc05aed5
more restructuring
move configureSignals and pins to Cellular class
add Radio field to Cellular class to hold radio type

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 0:830c436480e3 1 #ifndef CELLULAR_H
mfiore 0:830c436480e3 2 #define CELLULAR_H
mfiore 0:830c436480e3 3
Mike Fiore 1:f155d94d6f3a 4 #include <string>
Mike Fiore 1:f155d94d6f3a 5 #include <vector>
Mike Fiore 1:f155d94d6f3a 6
Mike Fiore 1:f155d94d6f3a 7 #include "IPStack.h"
Mike Fiore 1:f155d94d6f3a 8 #include "MTSBufferedIO.h"
Mike Fiore 2:10e72dce251d 9 #include "CellUtils.h"
Mike Fiore 1:f155d94d6f3a 10
Mike Fiore 1:f155d94d6f3a 11 namespace mts
Mike Fiore 1:f155d94d6f3a 12 {
Mike Fiore 1:f155d94d6f3a 13
Mike Fiore 1:f155d94d6f3a 14 /** This is a class for communicating with a Cellular radio device.
Mike Fiore 1:f155d94d6f3a 15 * This class supports three main types of cellular radio interactions including:
Mike Fiore 1:f155d94d6f3a 16 * configuration and status processing, SMS processing, and TCP/UDP Socket
Mike Fiore 1:f155d94d6f3a 17 * data connections. This class also inherits from IPStack providing a common set of commands
Mike Fiore 1:f155d94d6f3a 18 * for communication devices that support IP protocols. It is also integrated with the standard
Mike Fiore 1:f155d94d6f3a 19 * mbed Sockets package and can therefore be used seamlessly with clients and services built
Mike Fiore 1:f155d94d6f3a 20 * on top of this interface already within the mbed library.
Mike Fiore 1:f155d94d6f3a 21 *
Mike Fiore 1:f155d94d6f3a 22 * For all examples below please change Pin Names to match your hardware configuration.
Mike Fiore 1:f155d94d6f3a 23 * It also assumes the use of RTS/CTS hardware handshaking using GPIOs. To disable this
Mike Fiore 1:f155d94d6f3a 24 * you will need to change settings on the radio module and and use the MTSSerial class
Mike Fiore 1:f155d94d6f3a 25 * instead of MTSSerialFlowControl.
Mike Fiore 1:f155d94d6f3a 26 *
Mike Fiore 1:f155d94d6f3a 27 * The following set of example code demonstrates how to send and receive configuration and
Mike Fiore 1:f155d94d6f3a 28 * status AT commands with the radio, create a data connection and test it:
Mike Fiore 1:f155d94d6f3a 29 * @code
Mike Fiore 1:f155d94d6f3a 30 * #include "mbed.h"
Mike Fiore 1:f155d94d6f3a 31 * #include "mtech.h"
Mike Fiore 1:f155d94d6f3a 32 *
Mike Fiore 1:f155d94d6f3a 33 * using namespace mts;
Mike Fiore 1:f155d94d6f3a 34 *
Mike Fiore 1:f155d94d6f3a 35 * main() {
Mike Fiore 1:f155d94d6f3a 36 * //Setup serial interface to radio
Mike Fiore 1:f155d94d6f3a 37 * MTSSerialFlowControl* serial = new MTSSerialFlowControl(YOUR_TXD, YOUR_RXD, YOUR_RTS, YOUR_CTS);
Mike Fiore 1:f155d94d6f3a 38 * serial->baud(YOUR_BAUD);
Mike Fiore 1:f155d94d6f3a 39 *
Mike Fiore 1:f155d94d6f3a 40 * //Setup Cellular class - Select your radio type
Mike Fiore 1:f155d94d6f3a 41 * Cellular* cellular = new UniversalIP();
Mike Fiore 1:f155d94d6f3a 42 * //Cellular cellular = new TelitIP();
Mike Fiore 1:f155d94d6f3a 43 * cellular->init(serial);
Mike Fiore 1:f155d94d6f3a 44 *
Mike Fiore 1:f155d94d6f3a 45 * //Run status and configuration commands
Mike Fiore 1:f155d94d6f3a 46 * printf("\n\r////Start Status and Configuration Commands////\n\r");
Mike Fiore 1:f155d94d6f3a 47 * printf("Command Test: %s\n\r", getCodeNames(cellular->test()).c_str());
Mike Fiore 1:f155d94d6f3a 48 * wait(1);
Mike Fiore 1:f155d94d6f3a 49 * printf("Signal Strength: %d\n\r", cellular->getSignalStrength());
Mike Fiore 1:f155d94d6f3a 50 * wait(1);
Mike Fiore 1:f155d94d6f3a 51 * printf("Registration State: %s\n\r", Cellular::getRegistrationNames(cellular->getRegistration()).c_str());
Mike Fiore 1:f155d94d6f3a 52 * wait(1);
Mike Fiore 1:f155d94d6f3a 53 * printf("Send Basic Command (AT): %s\n\r", getCodeNames(cellular->sendBasicCommand("AT", 1000)).c_str());
Mike Fiore 1:f155d94d6f3a 54 * wait(1);
Mike Fiore 1:f155d94d6f3a 55 * printf("Send Command (AT+CSQ): %s\n\r", cellular->sendCommand("AT+CSQ", 1000).c_str());
Mike Fiore 1:f155d94d6f3a 56 * wait(1);
Mike Fiore 1:f155d94d6f3a 57 *
Mike Fiore 1:f155d94d6f3a 58 * //Start Test
Mike Fiore 1:f155d94d6f3a 59 * printf("\n\r////Start Network Connectivity Test////\n\r");
Mike Fiore 1:f155d94d6f3a 60 * printf("Set APN: %s\n\r", getCodeNames(cellular->setApn("wap.cingular")).c_str()); //Use APN from service provider!!!
Mike Fiore 1:f155d94d6f3a 61 *
Mike Fiore 1:f155d94d6f3a 62 * //Setup a data connection
Mike Fiore 1:f155d94d6f3a 63 * printf("Attempting to Connect, this may take some time...\n\r");
Mike Fiore 1:f155d94d6f3a 64 * while (!cellular->connect()) {
Mike Fiore 1:f155d94d6f3a 65 * printf("Failed to connect... Trying again.\n\r");
Mike Fiore 1:f155d94d6f3a 66 * wait(1);
Mike Fiore 1:f155d94d6f3a 67 * }
Mike Fiore 1:f155d94d6f3a 68 * printf("Connected to the Network!\n\r");
Mike Fiore 1:f155d94d6f3a 69 *
Mike Fiore 1:f155d94d6f3a 70 * //Try pinging default server "8.8.8.8"
Mike Fiore 1:f155d94d6f3a 71 * printf("Ping Valid: %s\n\r", cellular->ping() ? "true" : "false");
Mike Fiore 1:f155d94d6f3a 72 *
Mike Fiore 1:f155d94d6f3a 73 * //Perform HTTP transfer over TCP socket connection
Mike Fiore 1:f155d94d6f3a 74 * printf("Open Connection: %s\n\r", cellular->open("echo.200please.com", 80, IPStack::TCP) ? "Success" : "Failure");
Mike Fiore 1:f155d94d6f3a 75 * printf("Performing HTTP GET on echo.200please.com\n\r");
Mike Fiore 1:f155d94d6f3a 76 * string httpGET = "GET / HTTP/1.1\r\nHost: echo.200please.com\r\nConnection: keep-alive\r\n\r\n";
Mike Fiore 1:f155d94d6f3a 77 * printf("Wrote %d of %d bytes\n\r", cellular->write(httpGET.data(), httpGET.size(), 2000), httpGET.size());
Mike Fiore 1:f155d94d6f3a 78 * char buffer[256];
Mike Fiore 1:f155d94d6f3a 79 * buffer[255] = '\0';
Mike Fiore 1:f155d94d6f3a 80 * printf("Read %d bytes\n\r", cellular->read(buffer, 255, 2000));
Mike Fiore 1:f155d94d6f3a 81 * printf("HTTP Response:\n\r %s", buffer);
Mike Fiore 1:f155d94d6f3a 82 * wait(1);
Mike Fiore 1:f155d94d6f3a 83 * printf("Close Connection: %s\n\r", cellular->close() ? "Success" : "Failure");
Mike Fiore 1:f155d94d6f3a 84 *
Mike Fiore 1:f155d94d6f3a 85 * //Disconnect from network
Mike Fiore 1:f155d94d6f3a 86 * printf("Disconnecting...\n\r");
Mike Fiore 1:f155d94d6f3a 87 * cellular->disconnect();
Mike Fiore 1:f155d94d6f3a 88 * printf("Is Connected: %s\n\r", cellular->isConnected() ? "True" : "False");
Mike Fiore 1:f155d94d6f3a 89 *
Mike Fiore 1:f155d94d6f3a 90 * printf("End Program\n\r");
Mike Fiore 1:f155d94d6f3a 91 * }
Mike Fiore 1:f155d94d6f3a 92 * @endcode
Mike Fiore 1:f155d94d6f3a 93 *
Mike Fiore 1:f155d94d6f3a 94 * The following set of example code demonstrates how process SMS messages:
Mike Fiore 1:f155d94d6f3a 95 * @code
Mike Fiore 1:f155d94d6f3a 96 * #include "mbed.h"
Mike Fiore 1:f155d94d6f3a 97 * #include "mtech.h"
Mike Fiore 1:f155d94d6f3a 98 *
Mike Fiore 1:f155d94d6f3a 99 * using namespace mts;
Mike Fiore 1:f155d94d6f3a 100 *
Mike Fiore 1:f155d94d6f3a 101 * main() {
Mike Fiore 1:f155d94d6f3a 102 * //Setup serial interface to radio
Mike Fiore 1:f155d94d6f3a 103 * MTSSerialFlowControl* serial = new MTSSerialFlowControl(YOUR_TXD, YOUR_RXD, YOUR_RTS, YOUR_CTS);
Mike Fiore 1:f155d94d6f3a 104 * serial->baud(YOUR_BAUD);
Mike Fiore 1:f155d94d6f3a 105 *
Mike Fiore 1:f155d94d6f3a 106 * //Setup Cellular class
Mike Fiore 1:f155d94d6f3a 107 * //Setup Cellular class - Select your radio type
Mike Fiore 1:f155d94d6f3a 108 * Cellular* cellular = new UniversalIP();
Mike Fiore 1:f155d94d6f3a 109 * //Cellular cellular = new TelitIP();
Mike Fiore 1:f155d94d6f3a 110 * cellular->init(serial);
Mike Fiore 1:f155d94d6f3a 111 *
Mike Fiore 1:f155d94d6f3a 112 * //Start test
Mike Fiore 1:f155d94d6f3a 113 * printf("AT Test: %s\n\r", getCodeNames(cellular->test()).c_str());
Mike Fiore 1:f155d94d6f3a 114 *
Mike Fiore 1:f155d94d6f3a 115 * //Waiting for network registration
Mike Fiore 1:f155d94d6f3a 116 * printf("Checking Network Registration, this may take some time...\n\r");
Mike Fiore 1:f155d94d6f3a 117 * while (cellular->getRegistration() != Cellular::REGISTERED) {
Mike Fiore 1:f155d94d6f3a 118 * printf("Still waiting... Checking again.\n\r");
Mike Fiore 1:f155d94d6f3a 119 * wait(1);
Mike Fiore 1:f155d94d6f3a 120 * }
Mike Fiore 1:f155d94d6f3a 121 * printf("Connected to the Network!\n\r");
Mike Fiore 1:f155d94d6f3a 122 *
Mike Fiore 1:f155d94d6f3a 123 * //Send SMS Message
Mike Fiore 1:f155d94d6f3a 124 * Code code;
Mike Fiore 1:f155d94d6f3a 125 * std::string sMsg("Hello from Multi-Tech MBED!");
Mike Fiore 1:f155d94d6f3a 126 * std::string sPhoneNum("16128675309"); //Put your phone number here or leave Jenny's...
Mike Fiore 1:f155d94d6f3a 127 *
Mike Fiore 1:f155d94d6f3a 128 * printf("Sending message [%s] to [%s]\r\n", sMsg.c_str(), sPhoneNum.c_str());
Mike Fiore 1:f155d94d6f3a 129 * code = cellular->sendSMS(sPhoneNum, sMsg);
Mike Fiore 1:f155d94d6f3a 130 *
Mike Fiore 1:f155d94d6f3a 131 * if(code != SUCCESS) {
Mike Fiore 1:f155d94d6f3a 132 * printf("Error during SMS send [%s]\r\n", getCodeNames(code).c_str());
Mike Fiore 1:f155d94d6f3a 133 * } else {
Mike Fiore 1:f155d94d6f3a 134 * printf("Success!\r\n");
Mike Fiore 1:f155d94d6f3a 135 * }
Mike Fiore 1:f155d94d6f3a 136 *
Mike Fiore 1:f155d94d6f3a 137 * //Try and receive SMS messages
Mike Fiore 1:f155d94d6f3a 138 * //To determine your radio's phone number send yourself an SMS and check the received #
Mike Fiore 1:f155d94d6f3a 139 * printf("Checking Received Messages\r\n");
Mike Fiore 1:f155d94d6f3a 140 * while (true) {
Mike Fiore 1:f155d94d6f3a 141 * std::vector<Cellular::Sms> vSms = cellular->getReceivedSms();
Mike Fiore 1:f155d94d6f3a 142 * printf("\r\n");
Mike Fiore 1:f155d94d6f3a 143 * for(unsigned int i = 0; i < vSms.size(); i++) {
Mike Fiore 1:f155d94d6f3a 144 * printf("[%d][%s][%s][%s]\r\n", i, vSms[i].timestamp.c_str(),
Mike Fiore 1:f155d94d6f3a 145 * vSms[i].phoneNumber.c_str(), vSms[i].message.c_str());
Mike Fiore 1:f155d94d6f3a 146 * }
Mike Fiore 1:f155d94d6f3a 147 * wait(10);
Mike Fiore 1:f155d94d6f3a 148 * }
Mike Fiore 1:f155d94d6f3a 149 * }
Mike Fiore 1:f155d94d6f3a 150 * @endcode
Mike Fiore 1:f155d94d6f3a 151 */
Mike Fiore 1:f155d94d6f3a 152
Mike Fiore 1:f155d94d6f3a 153 class Cellular : public IPStack
Mike Fiore 1:f155d94d6f3a 154 {
Mike Fiore 1:f155d94d6f3a 155 public:
Mike Fiore 1:f155d94d6f3a 156 // Class ping paramter constants
Mike Fiore 1:f155d94d6f3a 157 static const unsigned int PINGDELAY = 3; //Time to wait on each ping for a response before timimg out (seconds)
Mike Fiore 1:f155d94d6f3a 158 static const unsigned int PINGNUM = 4; //Number of pings to try on ping command
Mike Fiore 1:f155d94d6f3a 159
Mike Fiore 1:f155d94d6f3a 160 /// Enumeration for different cellular radio types.
Mike Fiore 1:f155d94d6f3a 161 enum Radio {
Mike Fiore 7:0ee8e69a3e9c 162 NA, MTSMC_H5, MTSMC_EV3, MTSMC_G3, MTSMC_C2, MTSMC_H5_IP, MTSMC_EV3_IP, MTSMC_C2_IP
Mike Fiore 1:f155d94d6f3a 163 };
Mike Fiore 1:f155d94d6f3a 164
Mike Fiore 1:f155d94d6f3a 165 /// An enumeration of radio registration states with a cell tower.
Mike Fiore 1:f155d94d6f3a 166 enum Registration {
Mike Fiore 1:f155d94d6f3a 167 NOT_REGISTERED, REGISTERED, SEARCHING, DENIED, UNKNOWN, ROAMING
Mike Fiore 1:f155d94d6f3a 168 };
Mike Fiore 1:f155d94d6f3a 169
Mike Fiore 1:f155d94d6f3a 170 /** This structure contains the data for an SMS message.
Mike Fiore 1:f155d94d6f3a 171 */
Mike Fiore 1:f155d94d6f3a 172 struct Sms {
Mike Fiore 1:f155d94d6f3a 173 /// Message Phone Number
Mike Fiore 1:f155d94d6f3a 174 std::string phoneNumber;
Mike Fiore 1:f155d94d6f3a 175 /// Message Body
Mike Fiore 1:f155d94d6f3a 176 std::string message;
Mike Fiore 1:f155d94d6f3a 177 /// Message Timestamp
Mike Fiore 1:f155d94d6f3a 178 std::string timestamp;
Mike Fiore 1:f155d94d6f3a 179 };
Mike Fiore 1:f155d94d6f3a 180
Mike Fiore 1:f155d94d6f3a 181 /** This method initializes the object with the underlying radio
Mike Fiore 1:f155d94d6f3a 182 * interface to use. Note that this function MUST be called before
Mike Fiore 1:f155d94d6f3a 183 * any other calls will function correctly on a Cellular object. Also
Mike Fiore 1:f155d94d6f3a 184 * note that MTSBufferedIO is abstract, so you must use one of
Mike Fiore 3:04046eebaef5 185 * its inherited classes like MTSSerial, MTSSerialFlowControl or write a class
Mike Fiore 3:04046eebaef5 186 * similar to MTSSerialFlowControl which maps the MTSBufferedIO API
Mike Fiore 3:04046eebaef5 187 * to your favorite serial library.
Mike Fiore 1:f155d94d6f3a 188 *
Mike Fiore 3:04046eebaef5 189 * @param io the io interface that is attached to the cellular radio.
Mike Fiore 1:f155d94d6f3a 190 * @param DCD this is the dcd signal from the radio. If attached the
Mike Fiore 1:f155d94d6f3a 191 * the pin must be passed in here for this class to operate correctly.
Mike Fiore 1:f155d94d6f3a 192 * The default is not connected.
Mike Fiore 1:f155d94d6f3a 193 * @param DTR this is the dtr signal from the radio. If attached the
Mike Fiore 1:f155d94d6f3a 194 * the pin must be passed in here for this class to operate correctly.
Mike Fiore 1:f155d94d6f3a 195 * The default is not connected.
Mike Fiore 1:f155d94d6f3a 196 * @returns true if the init was successful, otherwise false.
Mike Fiore 1:f155d94d6f3a 197 */
Mike Fiore 8:2d7259d244d1 198 virtual bool init(MTSBufferedIO* io);
Mike Fiore 9:1a03e3f3e7fe 199
Mike Fiore 9:1a03e3f3e7fe 200 /**
Mike Fiore 9:1a03e3f3e7fe 201 *
Mike Fiore 9:1a03e3f3e7fe 202 */
Mike Fiore 9:1a03e3f3e7fe 203 bool configureSignals(unsigned int DCD = NC, unsigned int DTR = NC, unsigned int RESET = NC);
Mike Fiore 1:f155d94d6f3a 204
Mike Fiore 1:f155d94d6f3a 205 /** A method for testing command access to the radio. This method sends the
Mike Fiore 1:f155d94d6f3a 206 * command "AT" to the radio, which is a standard radio test to see if you
Mike Fiore 1:f155d94d6f3a 207 * have command access to the radio. The function returns when it receives
Mike Fiore 1:f155d94d6f3a 208 * the expected response from the radio.
Mike Fiore 1:f155d94d6f3a 209 *
Mike Fiore 1:f155d94d6f3a 210 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 211 */
Mike Fiore 1:f155d94d6f3a 212 virtual Code test();
Mike Fiore 1:f155d94d6f3a 213
Mike Fiore 1:f155d94d6f3a 214 /** A method for getting the signal strength of the radio. This method allows you to
Mike Fiore 1:f155d94d6f3a 215 * get a value that maps to signal strength in dBm. Here 0-1 is Poor, 2-9 is Marginal,
Mike Fiore 1:f155d94d6f3a 216 * 10-14 is Ok, 15-19 is Good, and 20+ is Excellent. If you get a result of 99 the
Mike Fiore 1:f155d94d6f3a 217 * signal strength is not known or not detectable.
Mike Fiore 1:f155d94d6f3a 218 *
Mike Fiore 1:f155d94d6f3a 219 * @returns an integer representing the signal strength.
Mike Fiore 1:f155d94d6f3a 220 */
Mike Fiore 1:f155d94d6f3a 221 virtual int getSignalStrength();
Mike Fiore 1:f155d94d6f3a 222
Mike Fiore 1:f155d94d6f3a 223 /** This method is used to check the registration state of the radio with the cell tower.
Mike Fiore 1:f155d94d6f3a 224 * If not appropriatley registered with the tower you cannot make a cellular connection.
Mike Fiore 1:f155d94d6f3a 225 *
Mike Fiore 1:f155d94d6f3a 226 * @returns the registration state as an enumeration type.
Mike Fiore 1:f155d94d6f3a 227 */
Mike Fiore 1:f155d94d6f3a 228 virtual Registration getRegistration();
Mike Fiore 1:f155d94d6f3a 229
Mike Fiore 1:f155d94d6f3a 230 /** This method is used to set the radios APN if using a SIM card. Note that the APN
Mike Fiore 1:f155d94d6f3a 231 * must be set correctly before you can make a data connection. The APN for your SIM
Mike Fiore 1:f155d94d6f3a 232 * can be obtained by contacting your cellular service provider.
Mike Fiore 1:f155d94d6f3a 233 *
Mike Fiore 1:f155d94d6f3a 234 * @param the APN as a string.
Mike Fiore 1:f155d94d6f3a 235 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 236 */
Mike Fiore 8:2d7259d244d1 237 virtual Code setApn(const std::string& apn);
Mike Fiore 1:f155d94d6f3a 238
Mike Fiore 1:f155d94d6f3a 239 /** This method is used to set the DNS which enables the use of URLs instead
Mike Fiore 1:f155d94d6f3a 240 * of IP addresses when making a socket connection.
Mike Fiore 1:f155d94d6f3a 241 *
Mike Fiore 1:f155d94d6f3a 242 * @param the DNS server address as a string in form xxx.xxx.xxx.xxx.
Mike Fiore 1:f155d94d6f3a 243 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 244 */
Mike Fiore 8:2d7259d244d1 245 virtual Code setDns(const std::string& primary, const std::string& secondary = "0.0.0.0");
Mike Fiore 1:f155d94d6f3a 246
Mike Fiore 1:f155d94d6f3a 247 /** This method is used to send an SMS message. Note that you cannot send an
Mike Fiore 1:f155d94d6f3a 248 * SMS message and have a data connection open at the same time.
Mike Fiore 1:f155d94d6f3a 249 *
Mike Fiore 1:f155d94d6f3a 250 * @param phoneNumber the phone number to send the message to as a string.
Mike Fiore 1:f155d94d6f3a 251 * @param message the text message to be sent.
Mike Fiore 1:f155d94d6f3a 252 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 253 */
Mike Fiore 7:0ee8e69a3e9c 254 virtual Code sendSMS(const std::string& phoneNumber, const std::string& message);
Mike Fiore 1:f155d94d6f3a 255
Mike Fiore 1:f155d94d6f3a 256 /** This method is used to send an SMS message. Note that you cannot send an
Mike Fiore 1:f155d94d6f3a 257 * SMS message and have a data connection open at the same time.
Mike Fiore 1:f155d94d6f3a 258 *
Mike Fiore 1:f155d94d6f3a 259 * @param sms an Sms struct that contains all SMS transaction information.
Mike Fiore 1:f155d94d6f3a 260 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 261 */
Mike Fiore 7:0ee8e69a3e9c 262 virtual Code sendSMS(const Sms& sms);
Mike Fiore 1:f155d94d6f3a 263
Mike Fiore 1:f155d94d6f3a 264 /** This method retrieves all of the SMS messages currently available for
Mike Fiore 1:f155d94d6f3a 265 * this phone number.
Mike Fiore 1:f155d94d6f3a 266 *
Mike Fiore 1:f155d94d6f3a 267 * @returns a vector of existing SMS messages each as an Sms struct.
Mike Fiore 1:f155d94d6f3a 268 */
Mike Fiore 7:0ee8e69a3e9c 269 virtual std::vector<Cellular::Sms> getReceivedSms();
Mike Fiore 1:f155d94d6f3a 270
Mike Fiore 1:f155d94d6f3a 271 /** This method can be used to remove/delete all received SMS messages
Mike Fiore 1:f155d94d6f3a 272 * even if they have never been retrieved or read.
Mike Fiore 1:f155d94d6f3a 273 *
Mike Fiore 1:f155d94d6f3a 274 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 275 */
Mike Fiore 7:0ee8e69a3e9c 276 virtual Code deleteAllReceivedSms();
Mike Fiore 1:f155d94d6f3a 277
Mike Fiore 1:f155d94d6f3a 278 /** This method can be used to remove/delete all received SMS messages
Mike Fiore 1:f155d94d6f3a 279 * that have been retrieved by the user through the getReceivedSms method.
Mike Fiore 1:f155d94d6f3a 280 * Messages that have not been retrieved yet will be unaffected.
Mike Fiore 1:f155d94d6f3a 281 *
Mike Fiore 1:f155d94d6f3a 282 * @returns the standard AT Code enumeration.
Mike Fiore 1:f155d94d6f3a 283 */
Mike Fiore 7:0ee8e69a3e9c 284 virtual Code deleteOnlyReceivedReadSms();
Mike Fiore 1:f155d94d6f3a 285
Mike Fiore 1:f155d94d6f3a 286 //Cellular Radio Specific
Mike Fiore 1:f155d94d6f3a 287 /** A method for sending a generic AT command to the radio. Note that you cannot
Mike Fiore 1:f155d94d6f3a 288 * send commands and have a data connection at the same time.
Mike Fiore 1:f155d94d6f3a 289 *
Mike Fiore 1:f155d94d6f3a 290 * @param command the command to send to the radio without the escape character.
Mike Fiore 1:f155d94d6f3a 291 * @param timeoutMillis the time in millis to wait for a response before returning.
Mike Fiore 1:f155d94d6f3a 292 * @param esc escape character to add at the end of the command, defaults to
Mike Fiore 1:f155d94d6f3a 293 * carriage return (CR). Does not append any character if esc == 0.
Mike Fiore 1:f155d94d6f3a 294 * @returns all data received from the radio after the command as a string.
Mike Fiore 1:f155d94d6f3a 295 */
Mike Fiore 1:f155d94d6f3a 296 virtual std::string sendCommand(const std::string& command, unsigned int timeoutMillis, char esc = CR) = 0;
Mike Fiore 1:f155d94d6f3a 297
Mike Fiore 1:f155d94d6f3a 298 /** A method for sending a basic AT command to the radio. A basic AT command is
Mike Fiore 1:f155d94d6f3a 299 * one that simply has a response of either OK or ERROR without any other information.
Mike Fiore 1:f155d94d6f3a 300 * Note that you cannot send commands and have a data connection at the same time.
Mike Fiore 1:f155d94d6f3a 301 *
Mike Fiore 1:f155d94d6f3a 302 * @param command the command to send to the radio without the escape character.
Mike Fiore 1:f155d94d6f3a 303 * @param timeoutMillis the time in millis to wait for a response before returning.
Mike Fiore 1:f155d94d6f3a 304 * @param esc escape character to add at the end of the command, defaults to
Mike Fiore 1:f155d94d6f3a 305 * carriage return (CR).
Mike Fiore 1:f155d94d6f3a 306 * @returns the standard Code enumeration.
Mike Fiore 1:f155d94d6f3a 307 */
Mike Fiore 1:f155d94d6f3a 308 virtual Code sendBasicCommand(const std::string& command, unsigned int timeoutMillis, char esc = CR) = 0;
Mike Fiore 1:f155d94d6f3a 309
Mike Fiore 1:f155d94d6f3a 310 /** A static method for getting a string representation for the Registration
Mike Fiore 1:f155d94d6f3a 311 * enumeration.
Mike Fiore 1:f155d94d6f3a 312 *
Mike Fiore 1:f155d94d6f3a 313 * @param code a Registration enumeration.
Mike Fiore 1:f155d94d6f3a 314 * @returns the enumeration name as a string.
Mike Fiore 1:f155d94d6f3a 315 */
Mike Fiore 1:f155d94d6f3a 316 static std::string getRegistrationNames(Registration registration);
Mike Fiore 3:04046eebaef5 317
Mike Fiore 3:04046eebaef5 318 protected:
Mike Fiore 3:04046eebaef5 319 MTSBufferedIO* io; //IO interface obect that the radio is accessed through.
Mike Fiore 3:04046eebaef5 320 bool echoMode; //Specifies if the echo mode is currently enabled.
Mike Fiore 3:04046eebaef5 321
Mike Fiore 3:04046eebaef5 322 bool pppConnected; //Specifies if a PPP session is currently connected.
Mike Fiore 3:04046eebaef5 323 std::string apn; //A string that holds the APN for the radio.
Mike Fiore 3:04046eebaef5 324
Mike Fiore 9:1a03e3f3e7fe 325 Radio type; //The type of radio being used
Mike Fiore 9:1a03e3f3e7fe 326
Mike Fiore 3:04046eebaef5 327 Mode mode; //The current socket Mode.
Mike Fiore 3:04046eebaef5 328 bool socketOpened; //Specifies if a Socket is presently opened.
Mike Fiore 3:04046eebaef5 329 bool socketCloseable; //Specifies is a Socket can be closed.
Mike Fiore 3:04046eebaef5 330 unsigned int local_port; //Holds the local port for socket connections.
Mike Fiore 3:04046eebaef5 331 std::string local_address; //Holds the local address for socket connections.
Mike Fiore 3:04046eebaef5 332 unsigned int host_port; //Holds the remote port for socket connections.
Mike Fiore 3:04046eebaef5 333 std::string host_address; //Holds the remote address for socket connections.
Mike Fiore 9:1a03e3f3e7fe 334
Mike Fiore 9:1a03e3f3e7fe 335 DigitalIn* dcd; //Maps to the radio's dcd signal
Mike Fiore 9:1a03e3f3e7fe 336 DigitalOut* dtr; //Maps to the radio's dtr signal
Mike Fiore 9:1a03e3f3e7fe 337 DigitalOut* resetLine; //Maps to the radio's reset signal
Mike Fiore 1:f155d94d6f3a 338 };
Mike Fiore 1:f155d94d6f3a 339
Mike Fiore 1:f155d94d6f3a 340 }
Mike Fiore 1:f155d94d6f3a 341
Mike Fiore 2:10e72dce251d 342 #endif /* CELLULAR_H */