modified by ohneta

Dependencies:   ATParser

Dependents:   ESP8266Interface

Fork of ESP8266 by NetworkSocketAPI

Files at this revision

API Documentation at this revision

Comitter:
ohneta
Date:
Wed Nov 11 03:40:18 2015 +0000
Parent:
14:71474261a9d7
Commit message:
check of disconnected on close()

Changed in this revision

ESP8266.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 71474261a9d7 -r 1ff5d44d5e30 ESP8266.cpp
--- a/ESP8266.cpp	Tue Nov 10 14:42:20 2015 +0000
+++ b/ESP8266.cpp	Wed Nov 11 03:40:18 2015 +0000
@@ -145,6 +145,18 @@
 
 bool ESP8266::close(int id)
 {
+    // if status = Disconnected , port was closed.
+    {
+        int status;
+        atParser.send("AT+CIPSTATUS");
+        atParser.recv("STATUS:%d", &status);
+        atParser.recv("OK");
+        if (status == 4) {
+            return true;
+        }
+   }
+
+
     //IDs only 0-4
     if(id > 4) {
         return false;
@@ -154,7 +166,6 @@
     string close_command = "AT+CIPCLOSE="+(string)idstr;
     string closed_response = (string)idstr + ",CLOSED OK";
 
-    //return (atParser.send(close_command.c_str()) && atParser.recv("OK"));
     return (atParser.send(close_command.c_str()) && atParser.recv(closed_response.c_str()));
 }