Own fork of C027_Support

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of C027_Support by u-blox

Revision:
68:33a96cf64986
Parent:
66:69072b3c5bca
Child:
69:4d6fa520dfca
--- a/MDM.cpp	Tue May 13 16:03:40 2014 +0000
+++ b/MDM.cpp	Tue May 13 16:25:56 2014 +0000
@@ -770,31 +770,43 @@
 int MDMParser::socketSend(int socket, const char * buf, int len)
 {
     TRACE("socketSend(%d,,%d)\r\n", socket,len);
-    if(len > 0) {
-        sendFormated("AT+USOWR=%d,%d\r\n",socket,len);
+    int cnt = len;
+    while (cnt > 0) {
+        int blk = MAX_SIZE;
+        if (cnt < blk) 
+            blk = cnt;
+        sendFormated("AT+USOWR=%d,%d\r\n",socket,blk);
         if (RESP_PROMPT != waitFinalResp())
             return SOCKET_ERROR;
         WAIT_MS(50);
-        send(buf, len);
+        send(buf, blk);
         if (RESP_OK != waitFinalResp()) 
             return SOCKET_ERROR;
+        buf += blk;
+        cnt -= blk;
     }
-    return len;
+    return (len - cnt);
 }
 
 int MDMParser::socketSendTo(int socket, IP ip, int port, const char * buf, int len)
 {
     TRACE("socketSendTo(%d," IPSTR ",%d,,%d)\r\n", socket, IPNUM(ip),port,len);
-    if(len > 0) {
-        sendFormated("AT+USOST=%d,\"" IPSTR "\",%d,%d\r\n",socket,IPNUM(ip),port,len);
+    int cnt = len;
+    while (cnt > 0) {
+        int blk = MAX_SIZE;
+        if (cnt < blk) 
+            blk = cnt;
+       sendFormated("AT+USOST=%d,\"" IPSTR "\",%d,%d\r\n",socket,IPNUM(ip),port,blk);
         if (RESP_PROMPT != waitFinalResp())
             return SOCKET_ERROR;
         WAIT_MS(50);
-        send(buf, len);
+        send(buf, blk);
         if (RESP_OK != waitFinalResp())
             return SOCKET_ERROR;
+        buf += blk;
+        cnt -= blk;
     }
-    return len;
+    return (len - cnt);
 }
 
 int MDMParser::socketReadable(int socket)