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.
Fork of WebSocketClient by
Diff: Websocket.cpp
- Revision:
- 15:9df4ffc6ce48
- Parent:
- 14:bf42271bde6a
- Child:
- 16:a8c6ee37356f
--- a/Websocket.cpp Thu Mar 31 20:38:54 2016 +0000
+++ b/Websocket.cpp Fri Apr 01 00:56:01 2016 +0000
@@ -3,18 +3,24 @@
#define MAX_TRY_WRITE 20
#define MAX_TRY_READ 10
+// #define DEBUG
+#define INFOMESSAGES
//Debug is disabled by default
-#if 1
-#define DBG(x, ...) pc.printf("[WebSocket : DBG]"x"\r\n", ##__VA_ARGS__);
-#define WARN(x, ...) pc.printf("[WebSocket : WARN]"x"\r\n", ##__VA_ARGS__);
-#define ERR(x, ...) pc.printf("[WebSocket : ERR]"x"\r\n", ##__VA_ARGS__);
+#ifdef DEBUG
+#define DBG(x, ...) pc.printf("[WebSocket : DBG] "x"\r\n", ##__VA_ARGS__);
+#define WARN(x, ...) pc.printf("[WebSocket : WARN] "x"\r\n", ##__VA_ARGS__);
+#define ERR(x, ...) pc.printf("[WebSocket : ERR] "x"\r\n", ##__VA_ARGS__);
#else
#define DBG(x, ...)
#define WARN(x, ...)
#define ERR(x, ...)
#endif
-#define INFO(x, ...) pc.printf("[WebSocket : INFO]"x"\r\n", ##__VA_ARGS__);
+#ifdef INFOMESSAGES
+#define INFO(x, ...) pc.printf("[WebSocket : INFO] "x"\r\n", ##__VA_ARGS__);
+#else
+#define INFO(x, ...)
+#endif
Websocket::Websocket(char * url) {
fillFields(url);
@@ -30,6 +36,11 @@
socket.set_blocking(false, 400);
}
+void Websocket::setBaud(int baudrate){
+ socket.setBaud(baudrate);
+ return;
+}
+
void Websocket::fillFields(char * url) {
int ret = parseURL(url, scheme, sizeof(scheme), host, sizeof(host), &port, path, sizeof(path));
if(ret)
