now this shit works

Dependencies:   BufferedSerial

Dependents:   IoTWeatherStation

Fork of ESP8266NodeMCUInterface by ESP8266

Revision:
44:16da10e7b3f7
Parent:
33:727aac1996b8
Child:
48:6031f70e3914
--- a/Socket/TCPSocketConnection.cpp	Fri May 01 18:29:38 2015 +0000
+++ b/Socket/TCPSocketConnection.cpp	Wed Jun 03 21:44:20 2015 +0000
@@ -51,7 +51,7 @@
 //        return -1;
 //    }
 //    _is_connected = true;
-    _is_connected = ESP8266->start(ESP_TCP_TYPE,_ipAddress,_port);
+    _is_connected = ESP8266->open(ESP_TCP_TYPE,_ipAddress,_port);
     if(_is_connected) { //success
         return 0;
     } else { // fail
@@ -71,16 +71,14 @@
         return -1;
     }
     Timer tmr;
-    int idx = 0;
     tmr.start();
     while ((tmr.read_ms() < _timeout) || _blocking) {
 
-        idx += wifi->send(data, length);
-
-        if (idx == length)
-            return idx;
+        if (wifi->send(data, length))
+            return length;
     }
-    return (idx == 0) ? -1 : idx;
+    
+    return -1;
 
     //return wifi->send(data,length);
 //
@@ -211,7 +209,6 @@
 //    _is_connected = (n != 0);
 //
 //    return n;
-
 }
 
 // -1 if unsuccessful, else number of bytes received
@@ -240,5 +237,8 @@
 //        }
 //    }
 //    return readLen;
-    return 0;
+    if (!wifi->recv(data, &length))
+        return -1;
+        
+    return length;
 }