easy connect wnc added to http request with debug mode enabled. traces collected for AT%CGEQOS, AT%MEAS, AT%PCONI
Fork of WncControllerLibrary by
Diff: WncController.cpp
- Revision:
- 27:c2b9ef5ccbef
- Parent:
- 23:aa2d716e234c
- Child:
- 28:eece2151e1e5
--- a/WncController.cpp Mon Sep 19 18:04:07 2016 +0000 +++ b/WncController.cpp Wed Sep 21 02:31:23 2016 +0000 @@ -941,33 +941,57 @@ return (false); } - dbgPuts(logStr->c_str()); - // Clean slate log->msgCount = 0; + if (logStr->size() == 0) + return (false); + // Pick out the stuff from the string and convert to struct string s; size_t pos2; size_t pos = logStr->find("+CMGL:"); + + for(i=0; i<MAX_WNC_SMS_MSG_SLOTS; i++) { + // Start with a clean slate, let parsing fill out later. + log->e[i].unread = false; + log->e[i].incoming = false; + log->e[i].unsent = false; + log->e[i].pduMode = false; + log->e[i].msgReceipt = false; - for(i=0; i<MAX_WNC_SMS_MSG_SLOTS; i++) { log->e[i].idx = logStr->at(pos + 7); if (pos == string::npos) return (false); - pos = logStr->find(",\"", pos); - if (pos == string::npos) - return (false); + pos2 = logStr->find(",\"", pos); + if (pos2 == string::npos) { + // If the WNC acts wrong and receives a PDU mode + // SMS there will not be any quotes in the response, + // just take the whole reply and make it the message body for + // now, mark it as an unread message, set the pdu flag! + log->e[log->msgCount].unread = true; + log->e[log->msgCount].pduMode = true; + log->msgCount++; + + pos2 = logStr->find("+CMGL", pos + 5); + if (pos2 == string::npos) { + pos2 = logStr->find("OK", pos + 5); + if (pos2 == string::npos) { + dbgPuts("Strange SMS Log Ending!"); + return (false); + } + i = MAX_WNC_SMS_MSG_SLOTS; + } + log->e[log->msgCount].msg = logStr->substr(0, pos2 - pos); + pos = pos2; // for loop starts off expecting pos to point to next log msg + continue; + } pos += 2; // Advance to the text we want pos2 = logStr->find("\",", pos); if ((pos2 == string::npos) || (pos >= pos2)) return (false); - + // Setup attributes - log->e[i].unread = false; - log->e[i].incoming = false; - log->e[i].unsent = false; - s = logStr->substr(pos, pos2 - pos); if (s.find("REC READ") != string::npos) log->e[i].incoming = true; @@ -977,6 +1001,8 @@ } if (s.find("STO UNSENT") != string::npos) log->e[i].unsent = true; + if (logStr->find(",,") == string::npos) + log->e[i].msgReceipt = true; // Tele number pos2 = logStr->find(",\"", pos2); @@ -991,7 +1017,6 @@ else log->e[i].number = logStr->substr(pos2, pos - pos2); - // Date pos = logStr->find(",\"", pos); if (pos == string::npos) @@ -1006,12 +1031,11 @@ log->e[i].date = logStr->substr(pos, pos2 - pos); // Timestamp - pos2 = logStr->find(",\""); - if (pos2 == string::npos) + pos = logStr->find("\",", pos2); // End of timestamp + if (pos == string::npos) return (false); - pos2 += 2; // Beginning of time field - pos = logStr->find("\",", pos2); // End of timestamp field - if ((pos == string::npos) || (pos2 > pos)) + pos2 += 1; // Beginning of time field + if (pos < pos2) return (false); if (pos == pos2) log->e[i].time.erase(); @@ -1022,9 +1046,6 @@ // We don't know how many messages we have so the next search // could end with +CMGL or OK. - pos = logStr->find(",\"", pos); - if (pos == string::npos) - return (false); pos += 2; // Advanced to message text pos2 = logStr->find("+CMGL", pos); if (pos2 == string::npos) {