for testing wifi

Dependents:   ESP8266_Test_WIFI

Fork of ESP8266Interface by Steve Kim

Revision:
27:9c6cefc12f0c
Parent:
23:de9221771e96
Child:
30:c035696b9397
--- a/Socket/UDPSocket.cpp	Tue Dec 30 03:21:33 2014 +0000
+++ b/Socket/UDPSocket.cpp	Mon Apr 20 20:27:11 2015 +0000
@@ -68,8 +68,16 @@
     int idx = 0;
     int nb_available = 0;
     int time = -1;
+    
+    //make this the non-blocking case and return if <= 0
+    // remember to change the config to blocking
+    // if ( ! _blocking) {
+        // if ( wifi.readable <= 0 ) {
+            // return (wifi.readable);
+        // }
+    // }
+    //---
     tmr.start();
-    
     if (_blocking) {
         while (1) {
             nb_available = wifi->readable();
@@ -78,6 +86,8 @@
             }
         }
     }
+    //---
+    // blocking case
     else {
         tmr.reset();
         
@@ -91,7 +101,19 @@
         if (nb_available == 0) return nb_available;  
     } 
     
+    // change this to < 20 mS timeout per byte to detect end of packet gap
+    // this may not work due to buffering at the UART interface
     tmr.reset();
+    // while ( tmr.read_ms() < 20 ) {
+        // if ( wifi.readable() && (idx < length) ) {
+            // buffer[idx++] = wifi->getc();
+            // tmr.reset();
+        // }
+        // if ( idx == length ) {
+            // break;
+        // }
+    // }
+    //---
     while (time < _timeout) {
 
         nb_available = wifi->readable();
@@ -105,6 +127,7 @@
         }
         time = tmr.read_ms();
     }
+    //---
     readEndpoint(remote);
     return (idx == 0) ? -1 : idx;
 }