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 08 00:53:07 2014 +0000
Parent:
22:c4360e61486a
Child:
24:03585a13ff3b
Commit message:
Added CWMODE command to join()

Changed in this revision

ESP8266/ESP8266.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/UDPSocket.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ESP8266/ESP8266.cpp	Tue Dec 02 16:02:21 2014 +0000
+++ b/ESP8266/ESP8266.cpp	Mon Dec 08 00:53:07 2014 +0000
@@ -73,6 +73,7 @@
 
 bool ESP8266::join()
 {
+    sendCommand( "AT+CWMODE=1", "change", NULL, 1000);
     string cmd="AT+CWJAP=\""+(string)this->ssid+"\",\""+(string)this->phrase+"\"";
     if( sendCommand( cmd.c_str(), "OK", NULL, 10000) ){
         // successfully joined the network
--- a/Socket/UDPSocket.cpp	Tue Dec 02 16:02:21 2014 +0000
+++ b/Socket/UDPSocket.cpp	Mon Dec 08 00:53:07 2014 +0000
@@ -95,15 +95,14 @@
     while (time < _timeout) {
 
         nb_available = wifi->readable();
-        for (int i = 0; i < min(nb_available, length); i++) {
+        //for (int i = 0; i < min(nb_available, length); i++) {
+        for (int i = 0; i < min(nb_available, (length-idx)); i++) {
             buffer[idx] = wifi->getc();
             idx++;
         }
-
         if (idx == length) {
             break;
         }
-        
         time = tmr.read_ms();
     }
     readEndpoint(remote);