wifly/socket interface for wifly modules

Dependents:   WiFi neurGAI_WIFI thingspeak thingspeak2

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Fri Aug 24 13:25:55 2012 +0000
Parent:
12:5ffaed1456c8
Commit message:
reduce buffer size

Changed in this revision

Socket/TCPSocketServer.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
Wifly/Wifly.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Socket/TCPSocketServer.cpp	Fri Aug 24 13:11:20 2012 +0000
+++ b/Socket/TCPSocketServer.cpp	Fri Aug 24 13:25:55 2012 +0000
@@ -23,16 +23,16 @@
 
 // Server initialization
 int TCPSocketServer::bind(int port) {
-    // use udp auto pairing
     char cmd[20];
-    /*if (!wifi->sendCommand("set ip proto 2\r", "AOK"))
-        return -1;
-    if (!wifi->sendCommand("set ip flags 0x07\r", "AOK"))
-        return -1;*/
+    
+    // set TCP protocol
     wifi->setProtocol(TCP);
-    sprintf(cmd, "set ip local %d\r", port);
+    
+    // set local port
+    sprintf(cmd, "set i l %d\r", port);
     if (!wifi->sendCommand(cmd, "AOK"))
         return -1;
+        
     wifi->exit();
     return 0;
 }
--- a/Socket/UDPSocket.cpp	Fri Aug 24 13:11:20 2012 +0000
+++ b/Socket/UDPSocket.cpp	Fri Aug 24 13:25:55 2012 +0000
@@ -78,8 +78,6 @@
     int nb_available = 0;
     int time = -1;
 
-
-
     if (_blocking) {
         while (1) {
             nb_available = wifi->readable();
--- a/Wifly/Wifly.cpp	Fri Aug 24 13:11:20 2012 +0000
+++ b/Wifly/Wifly.cpp	Fri Aug 24 13:25:55 2012 +0000
@@ -43,7 +43,7 @@
 Wifly * Wifly::inst;
 
 Wifly::Wifly(   PinName tx, PinName rx, PinName _reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec):
-    wifi(tx, rx), reset_pin(_reset), tcp_status(tcp_status), buf_wifly(512)
+    wifi(tx, rx), reset_pin(_reset), tcp_status(tcp_status), buf_wifly(256)
 {
     memset(&state, 0, sizeof(state));
     state.sec = sec;
@@ -67,7 +67,7 @@
 
 bool Wifly::join()
 {
-    char cmd[100];
+    char cmd[20];
 
     for (int i= 0; i < MAX_TRY_JOIN; i++) {
         // set time
@@ -145,10 +145,6 @@
                 continue;
         }
 
-        // save
-        if (!sendCommand("save\r", "Stor"))
-            return false;
-
         //join the network
         sprintf(cmd, "join\r");
         if (!sendCommand(cmd, "Associated", NULL, 3000))