FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.
Dependencies: mbed FXOS8700CQ MODSERIAL
Revision 34:1a4498e3580e, committed 2016-07-22
- Comitter:
- fkellermavnet
- Date:
- Fri Jul 22 18:01:07 2016 +0000
- Parent:
- 33:fa964b8b3b19
- Child:
- 35:c9c2eb8fb0a8
- Child:
- 36:d4782eabff43
- Commit message:
- Potential solution for missing characters at end of socket read payload.
Changed in this revision
wnc_control.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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");