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:
5:93e889a5abc6
Parent:
4:6561c9128c6f
Child:
8:3fe68d6130a8
--- a/cellular/Cellular.cpp	Wed Dec 11 16:49:21 2013 +0000
+++ b/cellular/Cellular.cpp	Wed Dec 11 17:36:18 2013 +0000
@@ -40,6 +40,10 @@
     return value;
 }
 
+std::string Cellular::getPhoneNumber() {
+    return "unknown";
+}
+
 Cellular::Registration Cellular::getRegistration()
 {
     string response = sendCommand("AT+CREG?", 1000);
@@ -141,14 +145,18 @@
 
 std::vector<Cellular::Sms> Cellular::getReceivedSms() {
     int lineNumber = 0;
-    size_t pos = 0;
-    bool done = false;
     std::vector<Sms> vSms;
     std::string received = sendCommand("AT+CMGL=\"ALL\"", 4000);
+    size_t pos = received.find("+CMGL: ");
     
-    while (pos != std::string::npos && !done) {
+    printf("SMS RECEIVED: [%s]", received.c_str());
+    
+    while (pos != std::string::npos) {
         Cellular::Sms sms;
         std::string line(Text::getLine(received, pos, pos));
+        if(line.size() == 0 || line == "OK") {
+            break;
+        }
         if(line.find("+CMGL: ") == std::string::npos) {
             //Searching for SMS start
             printf("[WARNING] Expected +CMGL. LINE[%d] DATA[%s]. Continuing ...", lineNumber, line.c_str());
@@ -167,6 +175,7 @@
         
         size_t bodyEnd = received.find("+CMGL: ", pos);
         sms.message = received.substr(pos, bodyEnd);
+        vSms.push_back(sms);
         pos = bodyEnd;
     }
     return vSms;