wifly/socket interface for wifly modules

Dependents:   WiFi neurGAI_WIFI thingspeak thingspeak2

Revision:
11:b912f91e3212
Parent:
9:aeddb7353e6e
--- a/Socket/TCPSocketConnection.cpp	Thu Aug 23 16:03:52 2012 +0000
+++ b/Socket/TCPSocketConnection.cpp	Fri Aug 24 13:07:01 2012 +0000
@@ -22,38 +22,9 @@
 TCPSocketConnection::TCPSocketConnection() {}
 
 int TCPSocketConnection::connect(const char* host, const int port)
-{
-    //open the connection
-    char cmd[30];
-    char rcv[40];
-
-    if (wifi->dnsLookup(host, rcv)) {
-        sprintf(cmd, "set ip host %s\r", rcv);
-        if (!wifi->sendCommand(cmd, "AOK"))
-            return -1;
-    } else {
-        return -1;
-    }
-
-    sprintf(cmd, "set ip remote %d\r", port);
-    if (!wifi->sendCommand(cmd, "AOK"))
+{  
+    if (!wifi->connect(host, port))
         return -1;
-
-    if (wifi->sendCommand("open\r", NULL, rcv)) {
-        if (strstr(rcv, "OPEN") == NULL) {
-            if (strstr(rcv, "Connected") != NULL) {
-                if (!wifi->sendCommand("close\r", "CLOS"))
-                    return -1;
-                if (!wifi->sendCommand(cmd, "OPEN"))
-                    return -1;
-            } else {
-                return -1;
-            }
-        }
-    } else {
-        return -1;
-    }
-
     wifi->flush();
     return 0;
 }