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.
Diff: wnc_control.cpp
- Revision:
- 35:d0d86a2bcdb3
- Parent:
- 33:eaf45dab650a
--- a/wnc_control.cpp Sat Jul 23 01:10:53 2016 +0000 +++ b/wnc_control.cpp Tue Aug 30 22:02:03 2016 +0000 @@ -13,7 +13,7 @@ int reinitialize_mdm(void); enum WNC_ERR_e { - WNC_OK =0, + WNC_OK = 0, WNC_CMD_ERR = -1, WNC_NO_RESPONSE = -2 }; @@ -264,12 +264,14 @@ str += "\"\r\n"; if (send_wnc_cmd(str.c_str(), &pRespStr, WNC_TIMEOUT_MS) == 0) { - size_t pos_start = pRespStr->find(":\"") + 2; + size_t pos_start = pRespStr->find(":\""); if (pos_start != string::npos) { - size_t pos_end = pRespStr->rfind("\"") - 1; + pos_start += 2; + size_t pos_end = pRespStr->find("\"", pos_start + 1); if (pos_end != string::npos) { + --pos_end; if (pos_end > pos_start) { // Make a copy for use later (the source string is re-used) @@ -323,7 +325,6 @@ unsigned at_sockread_wnc(string * pS, unsigned n, unsigned retries = 0) { - unsigned i; string * pRespStr; string cmd_str("AT@SOCKREAD=1,"); @@ -345,9 +346,16 @@ wait_ms(10); 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; + size_t pos_start = pRespStr->find("\""); + size_t i = 0; + size_t pos_end = pos_start; + if (pos_start != pRespStr->npos) { + ++pos_start; + pos_end = pRespStr->rfind("\""); + if (pos_end != pRespStr->npos) { + i = pos_end - pos_start + 1; + } + } if (i > 0) { retries = 0; // If any data found stop retrying