![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A simple project for sending button input up to AT&T Flow
Dependencies: FXOS8700CQ MODSERIAL mbed
For instructions on using this program, see the AT&T Starter Kit tutorial on it.
Diff: wnc_control.cpp
- Revision:
- 34:1a4498e3580e
- Parent:
- 32:1e052a3e73fe
- Child:
- 36:d4782eabff43
diff -r fa964b8b3b19 -r 1a4498e3580e wnc_control.cpp --- a/wnc_control.cpp Fri Jul 22 17:12:26 2016 +0000 +++ b/wnc_control.cpp Fri Jul 22 18:01:07 2016 +0000 @@ -331,13 +331,10 @@ unsigned at_sockread_wnc(string * pS, unsigned n, unsigned retries = 0) { - unsigned i; + unsigned i, numBytes = 0; string * pRespStr; string cmd_str("AT@SOCKREAD=1,"); - // Clean slate - pS->erase(); - if (n <= 1500) { char num2str[6]; @@ -355,10 +352,11 @@ send_wnc_cmd(cmd_str.c_str(), &pRespStr, WNC_TIMEOUT_MS); size_t pos_start = pRespStr->find("\"") + 1; size_t pos_end = pRespStr->rfind("\"") - 1; - i = pos_end - pos_start + 1; + i = (pos_end - pos_start + 1); // Num hex chars, 2 per byte if (i > 0) { - retries = 0; // If any data found stop retrying + retries = 1; // If any data found retry 1 more time to catch data that might be in another + // WNC payload string byte; while (pos_start < pos_end) { @@ -366,9 +364,10 @@ *pS += (char)strtol(byte.c_str(), NULL, 16); pos_start += 2; } - return i; + numBytes += i/2; } } + return numBytes; } else pc.puts("sockread Err, to many to read\r\n");