tester

Fork of GPRSInterface by -deleted-

Revision:
3:acf2ea413e72
Parent:
0:8ccbd963e74d
Child:
4:1142bdd07989
diff -r 8cb3c0d45988 -r acf2ea413e72 GPRS/GPRS.cpp
--- a/GPRS/GPRS.cpp	Tue Feb 25 06:00:32 2014 +0000
+++ b/GPRS/GPRS.cpp	Wed Feb 26 09:12:46 2014 +0000
@@ -142,8 +142,8 @@
 bool GPRS::is_connected(int socket)
 {
     char cmd[16];
-    char resp[64];
-    snprintf(cmd,16,"AT+CIPSTAUTS=%d\r\n",socket);
+    char resp[96];
+    snprintf(cmd,16,"AT+CIPSTATUS=%d\r\n",socket);
     sendCmd(cmd);
     readBuffer(resp,sizeof(resp),DEFAULT_TIMEOUT);
     if(NULL != strstr(resp,"CONNECTED")) {
@@ -228,15 +228,16 @@
     char cmd[32];
     char resp[16];
     wait(1);
-    snprintf(cmd,sizeof(cmd),"AT+CIPSEND=%d,%d\r\n",socket,len);
-    if(0 != sendCmdAndWaitForResp(cmd,">",DEFAULT_TIMEOUT,CMD)) {
-        return false;
+    if(len > 0){
+        snprintf(cmd,sizeof(cmd),"AT+CIPSEND=%d,%d\r\n",socket,len);
+        if(0 != sendCmdAndWaitForResp(cmd,">",DEFAULT_TIMEOUT,CMD)) {
+            return false;
+        }
+        snprintf(resp,sizeof(resp),"%d, SEND OK",socket);
+        if(0 != sendCmdAndWaitForResp(str,resp,DEFAULT_TIMEOUT,DATA)) {
+            return -1;
+        }
     }
-    snprintf(resp,sizeof(resp),"%d, SEND OK",socket);
-    if(0 != sendCmdAndWaitForResp(str,resp,DEFAULT_TIMEOUT,DATA)) {
-        return -1;
-    }
-
     return len;
 }