Damien Frost / WiflyInterface

Dependents:   IoT_Ex BatteryModelTester BatteryModelTester

Fork of WiflyInterface by Components

Revision:
34:a22a6343e3d4
Parent:
33:26a14bc6d90e
Child:
35:ce3afc021ec2
--- a/Wifly/Wifly.cpp	Tue Jun 28 16:22:27 2016 +0000
+++ b/Wifly/Wifly.cpp	Sun Jul 10 11:13:33 2016 +0000
@@ -21,24 +21,12 @@
 #include <string>
 #include <algorithm>
 
-#define DEBUG
+//#define DEBUG
 #define INFOMESSAGES
-//Debug is disabled by default
-#ifdef DEBUG
-#define DBG(x, ...) pc.printf("[Wifly : DBG] "x"\r\n", ##__VA_ARGS__);
-#define WARN(x, ...) pc.printf("[Wifly : WARN] "x"\r\n", ##__VA_ARGS__);
-#define ERR(x, ...) pc.printf("[Wifly : ERR] "x"\r\n", ##__VA_ARGS__);
-#else
-#define DBG(x, ...)
-#define WARN(x, ...)
-#define ERR(x, ...)
-#endif
-
-#ifdef INFOMESSAGES
-#define INFO(x, ...) pc.printf("[Wifly : INFO] "x"\r\n", ##__VA_ARGS__);
-#else
-#define INFO(x, ...)
-#endif
+#define WARNMESSAGES
+#define ERRMESSAGES
+#define FUNCNAME "Wifly"
+#include "messages.h"
 
 #define MAX_TRY_JOIN 3
 
@@ -246,17 +234,17 @@
 
     // try to open
     sprintf(cmd, "open %s %d\r", host, port);
-    DBG("CMD1: %s\n\r",cmd);
+    DBG("CMD1: %s",cmd);
     if (sendCommand(cmd, "OPEN", rcv, 10000)) {
         state.tcp = true;
         state.cmd_mode = false;
         return true;
     }
-    DBG("CMD2: %s\n\r",cmd);
-    DBG("CMD4: %s\n\r",rcv);
+    DBG("CMD2: %s",cmd);
+    DBG("CMD4: %s",rcv);
     // if failed, retry and parse the response
     if (sendCommand(cmd, NULL, rcv, 5000)) {
-        DBG("CMD5: %s\n\r",rcv);
+        DBG("CMD5: %s",rcv);
         if (strstr(rcv, "OPEN") == NULL) {
             if (strstr(rcv, "Connected") != NULL) {
                 wait(0.25);
@@ -270,7 +258,7 @@
             }
         }
     } else {
-        DBG("CMD5: %s\n\r",rcv);
+        DBG("CMD5: %s",rcv);
         return false;
     }
     
@@ -351,7 +339,7 @@
         return true;
         
     if (send("$$$", 3, "CMD") == -1 && send("\r",1,">") != true) {
-        ERR("cannot enter in cmd mode\r\n");
+        ERR("cannot enter in cmd mode");
         exit();
         return false;
     }