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

Dependents:   mtsas mtsas mtsas mtsas

Files at this revision

API Documentation at this revision

Comitter:
Vanger
Date:
Mon Aug 11 19:54:54 2014 +0000
Parent:
53:1aee5fe47adb
Child:
55:85c04afa939a
Commit message:
Added for loop check to ensure context is closed under EasyIP.cpp, added 100ms wait after leaving data mode with sendEscapeCommand() under EasyIP.cpp (due to AT command not being received by radio without slight wait)

Changed in this revision

Cellular/EasyIP.cpp Show annotated file Show diff for this revision Revisions of this file
Cellular/UIP.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Cellular/EasyIP.cpp	Mon Aug 11 16:27:27 2014 +0000
+++ b/Cellular/EasyIP.cpp	Mon Aug 11 19:54:54 2014 +0000
@@ -138,8 +138,12 @@
     }
     
     //Sends AT#SGACT=1,0 command
-    if (sendBasicCommand("AT#SGACT=1,0", 1000) == MTS_SUCCESS) {
-        logDebug("Successfully closed PPP Connection");
+    for (int y = 0; y < 5; y++) {
+        Code code = sendBasicCommand("AT#SGACT=1,0", 1000);
+        if (code == MTS_SUCCESS) {
+            logDebug("Successfully closed PPP Connection");
+            break;
+        }
     }
     
     /* Ensure PPP link is down, else ping commands will put radio in unknown state
@@ -377,7 +381,7 @@
         socketOpened = false;
     }
     
-    if(sendBasicCommand("AT#SH=1", 2000) != MTS_SUCCESS) {
+    if (sendBasicCommand("AT#SH=1", 2000) != MTS_SUCCESS) {
         logDebug("Failed to close socket connection");
     }
     
@@ -661,10 +665,10 @@
         if(size > 0) {
             result.append(tmp, size);
         }
-        if(result.find("OK") != std::string::npos) {
+        if(result.find("OK\r\n") != std::string::npos) {
             exitmode = true;
             done = true;
-        } else if(result.find("NO CARRIER") != std::string::npos) {
+        } else if(result.find("NO CARRIER\r\n") != std::string::npos) {
             socketOpened = false;
             exitmode = true;
             done = true;
@@ -679,6 +683,8 @@
         }
     } while (!done);
     
+    wait(0.1); //Without a slight wait time after receiving OK, radio would
+               //fail to correctly receive and respond to the next AT command
     return exitmode;
 }
 
@@ -710,7 +716,7 @@
     } else if(socketInfo == SOCKETCLOSED || socketInfo == SOCKETINCOMING) {
         status = false;
     } else {
-        logError("Could not determine socket status");
+        logError("Could not determine socket status[%d]",socketInfo);
         status = false;
     }
     
--- a/Cellular/UIP.cpp	Mon Aug 11 16:27:27 2014 +0000
+++ b/Cellular/UIP.cpp	Mon Aug 11 19:54:54 2014 +0000
@@ -298,7 +298,7 @@
 bool UIP::isOpen()
 {
     if(io->readable()) {
-        logDebug("Assuming open, data available to read.\n\r");
+        logDebug("Assuming open, data available to read.");
         return true;
     }
     return socketOpened;