now this shit works

Dependencies:   BufferedSerial

Dependents:   IoTWeatherStation

Fork of ESP8266NodeMCUInterface by ESP8266

Files at this revision

API Documentation at this revision

Comitter:
michaeljkoster
Date:
Mon Dec 01 09:28:02 2014 +0000
Parent:
19:fb8d5bff2076
Child:
21:690526f05fe6
Commit message:
cleanup

Changed in this revision

ESP8266/ESP8266.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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) {