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

Dependents:   mtsas mtsas mtsas mtsas

Revision:
23:8333593dd86f
Parent:
18:fa0d8120f81f
Child:
26:2b769ed8de4f
--- a/Cellular/Cellular.cpp	Thu Jun 19 14:59:35 2014 +0000
+++ b/Cellular/Cellular.cpp	Thu Jun 19 21:24:21 2014 +0000
@@ -273,10 +273,17 @@
     string cmd = "AT+CMGS=\"+";
     cmd.append(phoneNumber);
     cmd.append("\",145");
-    string response1 = sendCommand(cmd, 1000);
-    if (response1.find('>') == string::npos) {
-        logError("CMGS phone number failed");
-        return MTS_NO_RESPONSE;
+    for (int i = 0; i < 5; i++) {
+        string response1 = sendCommand(cmd, 1000);
+        if (response1.find('>') != string::npos) {
+            break;
+        }
+        if (i >= 5) {
+            logError("CMGS phone number failed");
+            return MTS_NO_RESPONSE;
+        }
+
+        wait(1);
     }
     wait(.2);
     string  response2 = sendCommand(message, 4000, CTRL_Z);