cc

Dependencies:   ATParser

Revision:
7:551de95939e2
Parent:
6:258b093eec08
Child:
8:a4425b8dd2e4
--- a/SPWFSA01.cpp	Thu Jun 30 10:08:10 2016 +0000
+++ b/SPWFSA01.cpp	Thu Jun 30 10:52:43 2016 +0000
@@ -249,6 +249,7 @@
                 break;
             //TODO:implement time-out functionality in case of no response
             //if(timeout) return false;
+            //TODO: deal with errors like "ERROR: Failed to resolve name"
         }
     //printf("\r\nsock id = %d\r\n", *id);
 
@@ -259,9 +260,9 @@
 {
     //May take a second try if device is busy
     for (unsigned i = 0; i < 2; i++) {
-        if (_parser.send("AT+CIPSEND=%d,%d", id, amount)
-            && _parser.recv(">")
-            && _parser.write((char*)data, (int)amount) >= 0) {
+        if (_parser.send("AT+S.SOCKW=%d,%d", id, amount)
+            && _parser.write((char*)data, (int)amount) >= 0
+            && _parser.recv("OK")) {
             return true;
         }
     }
@@ -274,7 +275,7 @@
     uint32_t recv_amount;
     int recv_id;
 
-    if (!(_parser.recv("+WIND:55:Pending Data:%d:%d", &recv_id, &recv_amount)
+    if (!(_parser.recv("+WIND:55:Pending Data:%d:%u", &recv_id, &recv_amount)
         && recv_id == id        
         //&& _parser.send("AT+S.SOCKQ=%d", id)//send a query (will be required for secure sockets)
         //&& _parser.recv(" DATALEN: %d", &recv_amount)
@@ -297,6 +298,12 @@
             && _parser.recv("OK")) {
             return true;
         }
+        else
+            {
+                if(_parser.recv("ERROR: Pending data"))
+                    printf("\r\nERROR!!!!\r\n");
+                    return false;
+                }
         //TODO: Deal with "ERROR: Pending data" (Closing a socket with pending data)
     }