Damien Frost / WiflyInterface

Dependents:   IoT_Ex BatteryModelTester BatteryModelTester

Fork of WiflyInterface by Components

Revision:
23:cb8522185c56
Parent:
22:6c5bcfa33922
Child:
24:705480e2e482
diff -r 6c5bcfa33922 -r cb8522185c56 Wifly/Wifly.cpp
--- a/Wifly/Wifly.cpp	Wed Mar 30 10:39:39 2016 +0000
+++ b/Wifly/Wifly.cpp	Thu Mar 31 12:38:56 2016 +0000
@@ -21,8 +21,9 @@
 #include <string>
 #include <algorithm>
 
+#define DEBUG
 //Debug is disabled by default
-#if (defined(DEBUG))
+#ifdef DEBUG
 #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__);
@@ -32,8 +33,8 @@
 #define ERR(x, ...)
 #endif
 
-#if defined(DEBUG)
-#define INFO(x, ...) printf("[Wifly : INFO]"x"\r\n", ##__VA_ARGS__);
+#ifdef DEBUG
+#define INFO(x, ...) std::printf("[Wifly : INFO]"x"\r\n", ##__VA_ARGS__);
 #else
 #define INFO(x, ...)
 #endif
@@ -65,6 +66,7 @@
     state.cmd_mode = false;
 }
 
+
 void Wifly::setBaud(int baudrate)
 {
     char cmd[28];
@@ -335,7 +337,7 @@
         cmdMode();
     }
     if (send(cmd, strlen(cmd), ack, res, timeout) == -1) {
-        ERR("sendCommand: cannot %s\r\n", cmd);
+        ERR("sendCommand: cannot (%s)", cmd);
         exit();
         return false;
     }
@@ -447,8 +449,11 @@
 char Wifly::getc()
 {
     char c;
+    DBG("Waiting for buf_wifly.available() to return true...");
     while (!buf_wifly.available());
+    DBG("Dequeue-ing c...");
     buf_wifly.dequeue(&c);
+    DBG("Return c:(%c)",c);
     return c;
 }
 
@@ -476,7 +481,7 @@
     Timer tmr;
     int result = 0;
 
-    DBG("will send: %s\r\n",str);
+    DBG("will send: %s",str);
 
     attach_rx(false);
 
@@ -502,8 +507,8 @@
                 while (wifi.readable())
                     wifi.getc();
 
-                DBG("check: %s\r\n", checking.c_str());
-                DBG("result ignored: %d\r\n", result)
+                DBG("check: %s", checking.c_str());
+                DBG("result ignored: %d", result)
                 attach_rx(true);
                 return -1;
             } else if (wifi.readable()) {
@@ -523,8 +528,8 @@
                 }
             }
         }
-        DBG("check: %s\r\n", checking.c_str());
-        DBG("result: %d\r\n", result)
+        DBG("check: %s", checking.c_str());
+        DBG("result: %d", result)
         attach_rx(true);
         return result;
     }
@@ -542,13 +547,13 @@
                     break;
                 }
                 res[i] = '\0';
-                DBG("user str 1: %s\r\n", res);
+                DBG("user str 1: %s", res);
 
                 break;
             } else {
                 if (tmr.read_ms() > 300) {
                     res[i] = '\0';
-                    DBG("user str2: %s\r\n", res);
+                    DBG("user str2: %s", res);
 
                     break;
                 }
@@ -563,7 +568,7 @@
                 }
             }
         }
-        DBG("user str3: %s\r\n", res);
+        DBG("user str3: %s", res);
     }
 
     //We flush the buffer
@@ -571,6 +576,6 @@
         wifi.getc();
 
     attach_rx(true);
-    DBG("result: %d\r\n", result)
+    DBG("result: %d", result)
     return result;
 }
\ No newline at end of file