cc

Dependencies:   ATParser

Revision:
6:258b093eec08
Parent:
5:f17d6351e942
Child:
7:551de95939e2
--- a/SPWFSA01.cpp	Thu Jun 30 08:54:08 2016 +0000
+++ b/SPWFSA01.cpp	Thu Jun 30 10:08:10 2016 +0000
@@ -274,9 +274,13 @@
     uint32_t recv_amount;
     int recv_id;
 
-    if (!(_parser.recv("+IPD,%d,%d:", &recv_id, &recv_amount)
-        && recv_id == id
+    if (!(_parser.recv("+WIND:55:Pending Data:%d:%d", &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)
+        //&& _parser.recv("OK")
         && recv_amount <= amount
+        && _parser.send("AT+S.SOCKR=%d,%d", id, recv_amount)
         && _parser.read((char*)data, recv_amount)
         && _parser.recv("OK"))) {
         return -1;
@@ -293,6 +297,7 @@
             && _parser.recv("OK")) {
             return true;
         }
+        //TODO: Deal with "ERROR: Pending data" (Closing a socket with pending data)
     }
 
     return false;