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
Diff: Wifly/Wifly.cpp
- Revision:
- 18:cf3bd54703a5
- Parent:
- 16:de16e8b077c1
- Child:
- 20:3616a765c1b8
--- a/Wifly/Wifly.cpp Tue Mar 22 23:22:42 2016 +0000 +++ b/Wifly/Wifly.cpp Fri Mar 25 11:14:33 2016 +0000 @@ -20,7 +20,7 @@ #include "Wifly.h" #include <string> #include <algorithm> - +#define DEBUG //Debug is disabled by default #if (defined(DEBUG)) #define DBG(x, ...) std::printf("[Wifly : DBG]"x"\r\n", ##__VA_ARGS__); @@ -67,7 +67,7 @@ void Wifly::setBaud(int baudrate) { - char cmd[20]; + char cmd[28]; // This sets the baud rate 'instantly' sprintf(cmd, "set u i %d\r", baudrate); // This one sets it some other way that does not work @@ -83,7 +83,7 @@ bool Wifly::join() { - char cmd[20]; + char cmd[28]; for (int i= 0; i < MAX_TRY_JOIN; i++) { @@ -236,20 +236,21 @@ bool Wifly::connect(const char * host, int port) { - char rcv[20]; - char cmd[20]; + char rcv[28]; + char cmd[28]; // try to open sprintf(cmd, "open %s %d\r", host, port); - if (sendCommand(cmd, "OPEN", NULL, 10000)) { + DBG("CMD1: %s\n\r",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); // if failed, retry and parse the response if (sendCommand(cmd, NULL, rcv, 5000)) { if (strstr(rcv, "OPEN") == NULL) { @@ -500,7 +501,7 @@ wifi.getc(); DBG("check: %s\r\n", checking.c_str()); - + DBG("result ignored: %d\r\n", result) attach_rx(true); return -1; } else if (wifi.readable()) { @@ -521,7 +522,7 @@ } } DBG("check: %s\r\n", checking.c_str()); - + DBG("result: %d\r\n", result) attach_rx(true); return result; } @@ -545,7 +546,7 @@ } else { if (tmr.read_ms() > 300) { res[i] = '\0'; - DBG("user str: %s\r\n", res); + DBG("user str2: %s\r\n", res); break; } @@ -560,7 +561,7 @@ } } } - DBG("user str: %s\r\n", res); + DBG("user str3: %s\r\n", res); } //We flush the buffer