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

Revision:
82:5aa75004e553
Parent:
71:82205735732b
Child:
87:5db6c084adc7
--- a/cellular/Cellular.h	Fri Dec 27 15:19:49 2013 +0000
+++ b/cellular/Cellular.h	Fri Dec 27 15:41:24 2013 +0000
@@ -38,7 +38,7 @@
 * #include "MTSSerialFlowControl.h"
 *
 * using namespace mts;
-* 
+*
 * main() {
 *   //Wait for radio to boot up
 *   wait(30);
@@ -58,7 +58,7 @@
 *   printf("Registration State: %s\n\r", Cellular::getRegistrationNames(cellular->getRegistration()).c_str());
 *   printf("Send Basic Command (AT): %s\n\r", Cellular::getCodeNames(cellular->sendBasicCommand("AT", 1000)).c_str());
 *   printf("Send Command (AT+CSQ): %s\n\r", cellular->sendCommand("AT+CSQ", 1000).c_str());
-* 
+*
 *   //Start Test
 *   printf("Start Network Connectivity Test\n\r");
 *   printf("Set APN: %s\n\r", cellular->getCodeNames(cellular->setApn("wap.cingular")).c_str()); //Use APN from service provider!!!
@@ -84,7 +84,7 @@
 * #include "MTSSerialFlowControl.h"
 *
 * using namespace mts;
-* 
+*
 * main() {
 *   //Wait for radio to boot up
 *   wait(30);
@@ -96,31 +96,31 @@
 *   //Setup Cellular class
 *   Cellular* cellular = Cellular::getInstance();
 *   cellular->init(serial);
-* 
+*
 *   //Start test
 *   printf("Test: %s\n\r", Cellular::getCodeNames(cellular->test()).c_str());
-*   
+*
 *   //Send SMS Message
 *   Cellular::Code code;
 *   std::string sMsg("Hello from Multi-Tech MBED!");
 *   std::string sPhoneNum("16128675309"); //Put your phone number here or leave Jenny's...
-*    
+*
 *   printf("Sending message [%s] to [%s]\r\n", sMsg.c_str(), sPhoneNum.c_str());
 *   code = cellular->sendSMS(sPhoneNum, sMsg);
-*    
+*
 *   if(code != Cellular::CELL_OK) {
 *       printf("Error during SMS send [%s]\r\n", Cellular::getCodeNames(code).c_str());
 *   } else {
 *       printf("Success!\r\n");
 *   }
-* 
+*
 *   //Try and receive SMS messages
 *   //To determine your radio's phone number send yourself an SMS and check the received #
 *   printf("Checking Received Messages\r\n");
 *   std::vector<Cellular::Sms> vSms = cellular->getReceivedSms();
 *   printf("\r\n");
 *   for(unsigned int i = 0; i < vSms.size(); i++) {
-*       printf("[%d][%s][%s][%s]\r\n", i, vSms[i].timestamp.c_str(), 
+*       printf("[%d][%s][%s][%s]\r\n", i, vSms[i].timestamp.c_str(),
 *               vSms[i].phoneNumber.c_str(), vSms[i].message.c_str());
 *   }
 *   printf("End Program\n\r");
@@ -135,12 +135,12 @@
 * #include "MTSSerialFlowControl.h"
 *
 * using namespace mts;
-* 
+*
 * main() {
 *   //Define connection parameters
 *   Cellular::Code code;
 *   const int TEST_PORT = 7000;
-*   //const std::string TEST_SERVER("204.26.122.5"); 
+*   //const std::string TEST_SERVER("204.26.122.5");
 *   const std::string TEST_SERVER("ws://echo.websocket.org");
 *
 *   //Wait for radio to boot up
@@ -153,10 +153,10 @@
 *   //Setup Cellular class
 *   Cellular* cellular = Cellular::getInstance();
 *   cellular->init(serial);
-* 
+*
 *   //Start test
 *   printf("Test: %s\n\r", Cellular::getCodeNames(cellular->test()).c_str());
-* 
+*
 *   printf("Setting APN\r\n");
 *   code = cellular->setApn("wap.cingular"); // Use from your service provider
 *   if(code == Cellular::CELL_OK) {
@@ -173,24 +173,24 @@
 *   while (cellular->connect()) {
 *       wait(1);
 *   }
-*   printf("Connected to the Network!\n\r"); 
-*   
+*   printf("Connected to the Network!\n\r");
+*
 *   printf("Opening a TCP Socket\r\n");
 *   if(cellular->open(TEST_SERVER, TEST_PORT, IPStack::TCP)) {
-*       printf("Success!\r\n");   
+*       printf("Success!\r\n");
 *   } else {
 *       printf("Error during TCP socket open [%s:%d]\r\n", TEST_SERVER.c_str(), TEST_PORT);
 *   }
-*     
+*
 *   printf("Writing to socket\r\n");
 *   char data[] = "My Test Echo Message!!!";
 *   int bytesWritten = cellular->write(data, sizeof(data), 10000);
 *   if(bytesWritten == sizeof(data)) {
 *       printf("Successfully wrote message!\r\n");
 *   } else {
-*       printf("Failed to write message!\r\n");   
+*       printf("Failed to write message!\r\n");
 *   }
-*    
+*
 *   printf("Waiting 5 seconds\r\n");
 *   wait(5);
 *
@@ -198,13 +198,13 @@
 *   char response[sizeof(data)];
 *   int bytesRead = cellular->read(response, sizeof(data), 10000);
 *   printf("READ: [%d] [%s]\r\n", bytesRead, response);
-* 
+*
 *   printf("Closing socket\r\n");
 *   cellular->close();
-* 
+*
 *   printf("Disconnecting\r\n");
 *   cellular->disconnect();
-* 
+*
 *   printf("End Program\n\r");
 * }
 * @endcode
@@ -255,18 +255,24 @@
     * @returns a reference to the single Cellular obect that has been created.
     */
     static Cellular* getInstance();
-    
+
     /** This method initializes the object with the underlying radio
     * interface to use. Note that this function MUST be called before
     * any other calls will function correctly on an Cellular object. Also
     * note that MTSBufferedIO is abstract, so you must use one of
-    * its inherited classes like MTSSerial or MTSSerialFlowControl. 
+    * its inherited classes like MTSSerial or MTSSerialFlowControl.
     *
     * @param io the buffered io interface that is attached to the cellular
     * radio.
+    * @param DCD this is the dcd signal from the radio. If attached the
+    * the pin must be passed in here for this class to operate correctly.
+    * The default is not connected.
+    * @param DTR this is the dtr signal from the radio. If attached the
+    * the pin must be passed in here for this class to operate correctly.
+    * The default is not connected.
     * @returns true if the init was successful, otherwise false.
     */
-    bool init(MTSBufferedIO* io);
+    bool init(MTSBufferedIO* io, PinName DCD = NC, PinName DTR = NC);
 
     // Radio link related commands
     /** This method establishes a data connection on the cellular radio.