blabla

Fork of ESP8266Interface by ESP8266

Files at this revision

API Documentation at this revision

Comitter:
blownelco
Date:
Tue Dec 06 15:41:58 2016 +0000
Parent:
48:03fd9333670d
Child:
50:3e59ddd16330
Commit message:
test mqqt

Changed in this revision

ESP8266/ESP8266.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ESP8266/ESP8266.cpp	Wed Jun 10 15:47:33 2015 +0000
+++ b/ESP8266/ESP8266.cpp	Tue Dec 06 15:41:58 2016 +0000
@@ -23,25 +23,32 @@
 #include <algorithm>
 
 //Debug is disabled by default
-#if 0
+
 #define DBG(x, ...)  printf("[ESP8266 : DBG]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__); 
 #define WARN(x, ...) printf("[ESP8266 : WARN]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__); 
 #define ERR(x, ...)  printf("[ESP8266 : ERR]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__); 
-#else
-#define DBG(x, ...) //wait_us(10);
-#define WARN(x, ...) //wait_us(10);
-#define ERR(x, ...)
-#endif
+//#else
+//#define DBG(x, ...) //wait_us(10);
+//#define WARN(x, ...) //wait_us(10);
+//#define ERR(x, ...)
+
 
-#if 0
+
 #define INFO(x, ...) printf("[ESP8266 : INFO]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__); 
-#else
-#define INFO(x, ...)
-#endif
+//#else
+//#define INFO(x, ...)
+
 
 #define ESP_MAX_TRY_JOIN 3
 #define ESP_MAXID 4 // the largest possible ID Value (max num of sockets possible)
 
+
+DigitalOut led4(PTA14); // RGB LED
+DigitalOut led3(PTA13); // RGB LED
+
+
+
+
 ESP8266 * ESP8266::inst;
 char* ip = NULL;
 
@@ -71,6 +78,10 @@
         // successfully joined the network
         state.associated = true;
         INFO("ssid: %s, phrase: %s", this->ssid, this->phrase);
+        sendCommand("AT+CIFSR", "OK", NULL, 1000);
+        
+        
+        
         return true;
     }
     return false;
@@ -401,14 +412,14 @@
                 //We flush the buffer
                 while (readable())
                     getc();
-
+                led4 = !led4;
                 DBG("check:\t %s", checking.c_str());
 
                 attach_rx(true);
                 return -1;
             } else if (readable()) {
                 read = getc();
-                //printf("%c",read); //debug echo
+                printf("%c",read); //debug echo
                 if ( read != '\r' && read != '\n') {
                     checking += read;
                     found = checking.find(ACK);
@@ -418,7 +429,8 @@
                         //We flush the buffer
                         while (readable())
                             read = getc();
-                        //printf("%c",read); //debug echo
+                            led4 = !led4;                        
+                        printf("%c",read); //debug echo
                         break;
                     }
                 }