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

Dependents:   mtsas mtsas mtsas mtsas

Revision:
66:8c55e2bf7270
Parent:
60:250c17af30fb
Child:
67:7c705fe2acec
--- a/Cellular/EasyIP.cpp	Mon Aug 18 19:42:44 2014 +0000
+++ b/Cellular/EasyIP.cpp	Tue Oct 21 17:26:05 2014 +0000
@@ -134,7 +134,7 @@
     Timer tmr;
        
     if(socketOpened) {
-        close();
+        close(true);
     }
     
     //Sends AT#SGACT=1,0 command
@@ -351,7 +351,7 @@
 }
 
 //Closes socket connection
-bool EasyIP::close()
+bool EasyIP::close(bool clearBuffer)
 {
     
     if(io == NULL) {
@@ -381,19 +381,21 @@
     }
     
     //Clear receive buffer
-    Timer tmr;
-    int counter = 0;
-    char tmp[256];
-    tmr.start();
-    do {
-        if(socketOpened == false) {
-            break;
-        }
-        read(tmp, 256, 1000);
-    } while(counter++ < 10);
-
-    io->rxClear();
-    io->txClear();
+    if (clearBuffer) {
+        Timer tmr;
+        int counter = 0;
+        char tmp[256];
+        tmr.start();
+        do {
+            if(socketOpened == false) {
+                break;
+            }
+            read(tmp, 256, 1000);
+        } while(counter++ < 10);
+    
+        io->rxClear();
+        io->txClear();
+    }
 
     return !socketOpened;
 }