Forked mbed official WiflyInterface (interface for Roving Networks Wifly modules) which includes the possibility to use TCPSocketServer::accept as a non-blocking cal.

Dependents:   WiFlyHTTPServerSample MultiThreadingHTTPServer

Fork of WiflyInterface by mbed official

Files at this revision

API Documentation at this revision

Comitter:
leihen
Date:
Thu Jun 27 00:31:02 2013 +0000
Parent:
11:63a7dc9e45dd
Commit message:
Logger working locally
;

Changed in this revision

Wifly/Wifly.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 63a7dc9e45dd -r 4f95e6a365db Wifly/Wifly.cpp
--- a/Wifly/Wifly.cpp	Wed Jun 26 21:12:21 2013 +0000
+++ b/Wifly/Wifly.cpp	Thu Jun 27 00:31:02 2013 +0000
@@ -21,20 +21,13 @@
 #include <string>
 #include <algorithm>
 
+#ifndef DEBUG
+#define DEBUG
+#endif
+#include "debug.h"
+
 DigitalOut  ledrx(LED3);
 
-//Debug is disabled by default
-#if (1 && !defined(TARGET_LPC11U24))
-#define DBG(x, ...) std::printf("[Wifly : DBG]"x"\r\n", ##__VA_ARGS__);
-#define WARN(x, ...) std::printf("[Wifly : WARN]"x"\r\n", ##__VA_ARGS__);
-#define ERR(x, ...) std::printf("[Wifly : ERR]"x"\r\n", ##__VA_ARGS__);
-#define INFO(x, ...) printf("[Wifly : INFO]"x"\r\n", ##__VA_ARGS__);
-#else
-#define DBG(x, ...)
-#define WARN(x, ...)
-#define ERR(x, ...)
-#define INFO(x, ...)
-#endif
 
 #define MAX_TRY_JOIN 3
 
@@ -129,7 +122,7 @@
 
         // if no dhcp, set ip, netmask and gateway
         if (!state.dhcp) {
-            DBG("not dhcp\r");
+            INFO("not dhcp\r");
 
             sprintf(cmd, "set i a %s\r\n", ip);
             if (!sendCommand(cmd, "AOK"))
@@ -363,17 +356,17 @@
         char * begin = strstr(rcv, "=") + 1;
         for (int i = 0; i < 3; i++) {
             point = strstr(begin + l, ".");
-            DBG("str: %s", begin + l);
+            INFO("str: %s", begin + l);
             l += point - (begin + l) + 1;
         }
-        DBG("str: %s", begin + l);
+        INFO("str: %s", begin + l);
         while(*(begin + l + nb_digits) >= '0' && *(begin + l + nb_digits) <= '9') {
-            DBG("digit: %c", *(begin + l + nb_digits));
+            INFO("digit: %c", *(begin + l + nb_digits));
             nb_digits++;
         }
         memcpy(ip, begin, l + nb_digits);
         ip[l+nb_digits] = 0;
-        DBG("ip from dns: %s", ip);
+        INFO("ip from dns: %s", ip);
     }
     return true;
 }
@@ -545,7 +538,7 @@
     Timer tmr;
     int result = 0;
 
-    DBG("will send: %s\r\n",str);
+    INFO("will send: %s\r\n",str);
 
     attach_rx(false);
 
@@ -579,7 +572,7 @@
                     INFO("Flushing : %c",c);
                 }
 
-                DBG("check: %s\r\n", checking.c_str());
+                INFO("check: %s\r\n", checking.c_str());
 
                 attach_rx(true);
                 return -1;
@@ -601,7 +594,7 @@
                 }
             }
         }
-        DBG("check: %s\r\n", checking.c_str());
+        INFO("check: %s\r\n", checking.c_str());
 
         attach_rx(true);
         return result;
@@ -620,13 +613,13 @@
                     break;
                 }
                 res[i] = '\0';
-                DBG("user str 1: %s\r\n", res);
+                INFO("user str 1: %s\r\n", res);
 
                 break;
             } else {
                 if (tmr.read_ms() > 300) {
                     res[i] = '\0';
-                    DBG("user str: %s\r\n", res);
+                    INFO("user str: %s\r\n", res);
 
                     break;
                 }
@@ -641,7 +634,7 @@
                 }
             }
         }
-        DBG("user str: %s\r\n", res);
+        INFO("user str: %s\r\n", res);
     }
 
     //We flush the buffer
@@ -651,7 +644,7 @@
     }
 
     attach_rx(true);
-    DBG("result: %d\r\n", result)
+    INFO("result: %d\r\n", result)
     return result;
 }