Simple detection for LE910-NA1 modules

Fork of MTS-Cellular by MultiTech

Committer:
Mike Fiore
Date:
Mon May 19 14:40:54 2014 -0500
Revision:
2:10e72dce251d
Parent:
1:f155d94d6f3a
Child:
3:04046eebaef5
add CellUtils.h, replace inclusion of Vars.h with CellUtils.h

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