Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IoT_Ex BatteryModelTester BatteryModelTester
Fork of WiflyInterface by
Revision 34:a22a6343e3d4, committed 2016-07-10
- Comitter:
- defrost
- Date:
- Sun Jul 10 11:13:33 2016 +0000
- Parent:
- 33:26a14bc6d90e
- Child:
- 35:ce3afc021ec2
- Commit message:
- - updated debug messages
Changed in this revision
--- 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;
}
--- a/WiflyInterface.cpp Tue Jun 28 16:22:27 2016 +0000
+++ b/WiflyInterface.cpp Sun Jul 10 11:13:33 2016 +0000
@@ -2,22 +2,11 @@
//#define DEBUG
#define INFOMESSAGES
-//Debug is disabled by default
-#ifdef DEBUG
-#define DBG(x, ...) pc.printf("[WiflyInterface : DBG] "x"\r\n", ##__VA_ARGS__);
-#define WARN(x, ...) pc.printf("[WiflyInterface : WARN] "x"\r\n", ##__VA_ARGS__);
-#define ERR(x, ...) pc.printf("[WiflyInterface : ERR] "x"\r\n", ##__VA_ARGS__);
-#else
-#define DBG(x, ...)
-#define WARN(x, ...)
-#define ERR(x, ...)
-#endif
+#define WARNMESSAGES
+#define ERRMESSAGES
+#define FUNCNAME "WiflyInterface"
+#include "messages.h"
-#ifdef INFOMESSAGES
-#define INFO(x, ...) pc.printf("[WiflyInterface : INFO] "x"\r\n", ##__VA_ARGS__);
-#else
-#define INFO(x, ...)
-#endif
WiflyInterface::WiflyInterface( PinName tx, PinName rx, PinName reset, PinName tcp_status,
const char * ssid, const char * phrase, Security sec) :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/messages.h Sun Jul 10 11:13:33 2016 +0000
@@ -0,0 +1,38 @@
+// **************
+// * messages.h *
+// **************
+//
+// Created: 2016/06/29
+// By: Damien Frost
+//
+// Description:
+// Used to display different levels of debugging messages to the terminal.
+
+#ifndef IQ_MESSAGES_H
+#define IQ_MESSAGES_H
+
+#ifdef DEBUG
+#define DBG(x, ...) printf("["FUNCNAME" : DBG] "x" <line %d>\r\n", ##__VA_ARGS__,__LINE__);
+#else
+#define DBG(x, ...)
+#endif
+
+#ifdef ERRMESSAGES
+#define ERR(x, ...) printf("["FUNCNAME" : ERR] "x"\r\n", ##__VA_ARGS__);
+#else
+#define ERR(x, ...)
+#endif
+
+#ifdef WARNMESSAGES
+#define WARN(x, ...) printf("["FUNCNAME" : WARN] "x"\r\n", ##__VA_ARGS__);
+#else
+#define WARN(x, ...)
+#endif
+
+#ifdef INFOMESSAGES
+#define INFO(x, ...) printf("["FUNCNAME" : INFO] "x"\r\n", ##__VA_ARGS__);
+#else
+#define INFO(x, ...)
+#endif
+
+#endif /* IQ_MESSAGES_H */
\ No newline at end of file
