Added monitoring feature of ESP8266's UART

Dependents:   ESP8266_W7500_Example DualNetworkInterface-Basic

Fork of ESP8266Interface by ESP8266

Revision:
15:37a7a56a424f
Parent:
14:4d1128f72e00
Child:
16:3f0efaa57a12
--- a/ESP8266/ESP8266.cpp	Sun Nov 30 21:37:16 2014 +0000
+++ b/ESP8266/ESP8266.cpp	Sun Nov 30 21:56:03 2014 +0000
@@ -83,6 +83,32 @@
     return join();
 }
 
+bool ESP8266::is_connected()
+{
+    return true;
+}
+
+bool ESP8266::close()
+{
+    return true;
+}
+
+bool ESP8266::disconnect()
+{
+    // if already disconnected, return
+    if (!state.associated)
+        return true;
+    // send command to quit AP
+    //    
+    state.associated = false;
+    return true;
+}
+
+char* ESP8266::getIPAddress()
+{
+    return ipString;
+}
+
 bool ESP8266::gethostbyname(const char * host, char * ip)
 {
     string h = host;
@@ -105,43 +131,6 @@
     }
 }
 
-void ESP8266::flush()
-{
-    buf_ESP8266.flush();
-}
-
-bool ESP8266::sendCommand(const char * cmd, const char * ack, char * res, int timeout)
-{
-    return true;
-}
-
-bool ESP8266::close()
-{
-    return true;
-}
-
-bool ESP8266::disconnect()
-{
-    // if already disconnected, return
-    if (!state.associated)
-        return true;
-    // send command to quit AP
-    //    
-    state.associated = false;
-    return true;
-
-}
-
-bool ESP8266::is_connected()
-{
-    return true;
-}
-
-char* ESP8266::getIPAddress()
-{
-    return ipString;
-}
-
 void ESP8266::reset()
 {
     reset_pin = 0;
@@ -155,10 +144,19 @@
     return true;
 }
 
-int ESP8266::putc(char c)
+void ESP8266::handler_rx(void)
 {
-    while (!wifi.writeable());
-    return wifi.putc(c);
+    //read characters
+    while (wifi.readable())
+        buf_ESP8266.queue(wifi.getc());
+}
+
+void ESP8266::attach_rx(bool callback)
+{
+    if (!callback)
+        wifi.attach(NULL);
+    else
+        wifi.attach(this, &ESP8266::handler_rx);
 }
 
 int ESP8266::readable()
@@ -179,21 +177,21 @@
     return c;
 }
 
-void ESP8266::handler_rx(void)
+int ESP8266::putc(char c)
 {
-    //read characters
-    while (wifi.readable())
-        buf_ESP8266.queue(wifi.getc());
+    while (!wifi.writeable());
+    return wifi.putc(c);
 }
 
-void ESP8266::attach_rx(bool callback)
+void ESP8266::flush()
 {
-    if (!callback)
-        wifi.attach(NULL);
-    else
-        wifi.attach(this, &ESP8266::handler_rx);
+    buf_ESP8266.flush();
 }
 
+bool ESP8266::sendCommand(const char * cmd, const char * ack, char * res, int timeout)
+{
+    return true;
+}
 
 int ESP8266::send(const char * str, int len, const char * ACK, char * res, int timeout)
 {
@@ -300,4 +298,4 @@
     attach_rx(true);
     DBG("result: %d\r\n", result)
     return result;
-}
\ No newline at end of file
+}