for testing wifi

Dependents:   ESP8266_Test_WIFI

Fork of ESP8266Interface by Steve Kim

Revision:
20:d764237405c2
Parent:
19:fb8d5bff2076
Child:
22:c4360e61486a
--- a/ESP8266/ESP8266.cpp	Mon Dec 01 08:56:54 2014 +0000
+++ b/ESP8266/ESP8266.cpp	Mon Dec 01 09:28:02 2014 +0000
@@ -66,7 +66,6 @@
     attach_rx(false);
     
     wifi.baud(9600); // initial baud rate of the ESP8266 
-    pc.printf("ESP8266 test\r\n");
 }
 
 bool ESP8266::join()
@@ -173,7 +172,7 @@
     while (wifi.readable()){
         c=wifi.getc();
         buf_ESP8266.queue(c);
-        pc.printf("%c",c);
+        pc.printf("%c",c); //debug echo
     }
 }
 
@@ -205,7 +204,7 @@
 
 int ESP8266::putc(char c)
 {
-    while (!wifi.writeable() || wifi.readable());
+    while (!wifi.writeable() || wifi.readable()); //wait for echoed command characters to be read first
     return wifi.putc(c);
 }
 
@@ -243,10 +242,10 @@
     if (!ACK || !strcmp(ACK, "NO")) {
         for (int i = 0; i < strlen(cmd); i++){
             result = (putc(cmd[i]) == cmd[i]) ? result + 1 : result;
-            wait(.005);
+            wait(.005); // prevents stuck recieve ready (?) need to let echoed character get read first
         }
         putc(13); //CR
-        wait(.005);
+        wait(.005); // wait for echo
         putc(10); //LF
 
     } else {
@@ -257,10 +256,10 @@
         tmr.start();
         for (int i = 0; i < strlen(cmd); i++){
             result = (putc(cmd[i]) == cmd[i]) ? result + 1 : result;
-            wait(.005);
+            wait(.005); // wait for echo
         }
         putc(13); //CR
-        wait(.005);
+        wait(.005); // wait for echo
         putc(10); //LF
 
         while (1) {