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:
- 19:83a52353b97e
- Parent:
- 18:ca2899c353c2
- Child:
- 20:ca2db38d6802
diff -r ca2899c353c2 -r 83a52353b97e WncController.cpp --- a/WncController.cpp Tue Sep 13 19:10:34 2016 +0000 +++ b/WncController.cpp Wed Sep 14 02:31:35 2016 +0000 @@ -859,6 +859,16 @@ bool WncController::getICCID(string * iccid) { + if (at_geticcid_wnc(iccid) == false) { + dbgPuts("getICCID error!"); + return (false); + } + + return (true); +} + +bool WncController::at_geticcid_wnc(string * iccid) +{ string * respStr; iccid->erase(); @@ -882,6 +892,7 @@ return (true); } + bool WncController::convertICCIDtoMSISDN(const string & iccid, string * msisdn) { msisdn->erase(); @@ -933,12 +944,13 @@ size_t pos = logStr->find("+CMGL:"); 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 = logStr->find(",\"", pos); if (pos == string::npos) return (false); - pos += 3; // Advance to the text we want + pos += 2; // Advance to the text we want pos2 = logStr->find("\",", pos); if ((pos2 == string::npos) || (pos >= pos2)) return (false); @@ -949,10 +961,12 @@ log->e[i].unsent = false; s = logStr->substr(pos, pos2 - pos); - if (s.find("READ") != string::npos) + if (s.find("REC READ") != string::npos) log->e[i].incoming = true; - if (s.find("REC UNREAD") != string::npos) + if (s.find("REC UNREAD") != string::npos) { log->e[i].unread = true; + log->e[i].incoming = true; + } if (s.find("STO UNSENT") != string::npos) log->e[i].unsent = true; @@ -966,36 +980,47 @@ else log->e[i].number = logStr->substr(pos2, pos - pos2); - // Timestamp - pos = pos2 + 4; // Beginning of timestamp field - pos2 = logStr->find("\",", pos); // End of timestamp field + + // Date + pos += 4; // Beginning of date field + pos2 = logStr->find(",", pos); // End of timestamp field if ((pos2 == string::npos) || (pos > pos2)) return (false); if (pos == pos2) - log->e[i].timestamp.erase(); + log->e[i].date.erase(); else - log->e[i].timestamp = logStr->substr(pos, pos2 - pos); + log->e[i].date = logStr->substr(pos, pos2 - pos); + + // Timestamp + pos2 += 1; // Beginning of time field + pos = logStr->find("\",", pos2); // End of timestamp field + if ((pos == string::npos) || (pos2 > pos)) + return (false); + if (pos == pos2) + log->e[i].time.erase(); + else + log->e[i].time = logStr->substr(pos2, pos - pos2); // Message field // We don't know how many messages we have so the next search // could end with +CMGL or OK. - pos2 += 2; // Advanced to message text - pos = logStr->find("+CMGL", pos2); - if (pos == string::npos) { - pos = logStr->find("OK", pos2); - if (pos == string::npos) { + pos += 2; // Advanced to message text + pos2 = logStr->find("+CMGL", pos); + if (pos2 == string::npos) { + pos2 = logStr->find("OK", pos); + if (pos2 == string::npos) { dbgPuts("Strange SMS Log Ending!"); return (false); } i = MAX_WNC_SMS_MSG_SLOTS; // break } - if (pos2 > pos) + if (pos > pos2) return (false); - if (pos2 == pos) + if (pos == pos2) log->e[log->msgCount].msg.erase(); else - log->e[log->msgCount].msg = logStr->substr(pos2, pos - pos2); + log->e[log->msgCount].msg = logStr->substr(pos, pos2 - pos); log->msgCount++; // Message complete } @@ -1003,7 +1028,7 @@ return (true); } -bool WncController::readUnreadSMSText(struct WncSmsList * w) +bool WncController::readUnreadSMSText(struct WncSmsList * w, bool deleteRead) { struct WncController::WncSmsList tmp; @@ -1015,10 +1040,14 @@ if (tmp.e[i].unread == true) { w->e[w->msgCount] = tmp.e[i]; w->msgCount++; + if (deleteRead == true) { + // Clean up message that was copied out and read + deleteSMSTextFromMem(w->e[i].idx); + } } } - return (true); + return (w->msgCount > 0); } size_t WncController::getSignalQuality(const char ** log)