Libreria basica para el manejo del ESP01

Dependents:   Gateway_Cotosys Gateway_Cotosys_os5

Revision:
8:ef9014a530cf
Parent:
7:8c6f56470ba7
Child:
9:21290fc75c17
--- a/ESP01.cpp	Tue Jun 11 00:22:45 2019 +0000
+++ b/ESP01.cpp	Sun Sep 15 20:54:35 2019 +0000
@@ -42,16 +42,22 @@
 bool ESP01::RcvReply(char* r, int to)
 {
     Timer t;
+    bool ended = 0;
+    char c;
+    
     strcpy(r, "");
     t.start();
-
-    do {
+    while(!ended) {
         if(comm.readable()) {
-            AddChar(r, comm.getc());
+            c = comm.getc();
+            AddChar(r, c);
             t.start();
         }
-    } while(t.read_ms() < to);
-
+        if(t.read_ms() > to) {
+                ended = 1;
+        }
+    }
+    
     AddChar(r, '\0');
     return r[0] != '\0';
 }
@@ -83,7 +89,7 @@
 {
     char cmd[15];
     strcpy(cmd, "AT+CWMODE=");
-    AddChar(cmd, mode + '0'); // Completes command string
+    AddChar(cmd, mode + '0'); // // Converts number into corresponding ASCII character
     SendCMD(cmd);
 }
 
@@ -199,7 +205,7 @@
 // Gets connection status code. Parameter: string to contain status
 void ESP01::GetConnStatusCode(char * st)
 {
-    char cmd[15];
+    char cmd[25];
     strcpy(cmd, "AT+CIPSTATUS");
     SendCMD(cmd);
     RcvSingleReply(st);