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:
- 6:a656e820d7ff
- Parent:
- 5:20207cc5502e
- Child:
- 7:e6f22159ef23
diff -r 20207cc5502e -r a656e820d7ff WncController.cpp --- a/WncController.cpp Tue Sep 06 19:11:14 2016 +0000 +++ b/WncController.cpp Thu Sep 08 18:57:56 2016 +0000 @@ -320,6 +320,11 @@ } } +void WncController::setWncCmdTimeout(uint16_t toMs) +{ + m_sCmdTimeoutMs = toMs; +} + /** * \brief Opens a WNC socket. * @@ -963,12 +968,12 @@ return (false); } -size_t WncController::readSMSText(const char ** log) +size_t WncController::readSMSText(const char n, const char ** msg) { - size_t n; + size_t i; - n = at_readSMStext_wnc(log); - if (n == 0) + i = at_readSMStext_wnc(n,msg); + if (i == 0) dbgPuts("readSMSText: Failed!"); return (n); @@ -1173,7 +1178,6 @@ bool WncController::at_saveSMStext_wnc(const char * const phoneNum, const char * const text, char * msgIdx) { string respStr; - string * pRespStr; size_t l = strlen(text); if (l <= MAX_WNC_SMS_LENGTH) @@ -1181,8 +1185,6 @@ // Check to see if the SMS service is available checkCellLink(); if (m_sReadyForSMS == true) { - at_send_wnc_cmd("AT+CMGF=1", &pRespStr, m_sCmdTimeoutMs); - at_send_wnc_cmd("AT+CPMS=\"SM\",\"SM\",\"SM\"", &pRespStr, m_sCmdTimeoutMs); string cmdStr("AT+CMGW=\""); cmdStr += phoneNum; cmdStr += "\""; @@ -1222,19 +1224,27 @@ size_t WncController::at_readSMSlog_wnc(const char ** log) { string * pRespStr; + static string smsLogStr; + + smsLogStr.erase(); if (at_send_wnc_cmd("AT+CMGL", &pRespStr, m_sCmdTimeoutMs) == WNC_AT_CMD_OK) - *log = pRespStr->c_str(); - else - *log = "\0"; + smsLogStr = *pRespStr; + *log = smsLogStr.c_str(); + return (pRespStr->size()); } -size_t WncController::at_readSMStext_wnc(const char ** log) +size_t WncController::at_readSMStext_wnc(const char n, const char ** log) { + static string smsReadTxtStr; string * pRespStr; - + string cmdStr; + + smsReadTxtStr.erase(); + cmdStr = "AT+CMGR"; + cmdStr += '1'; if (at_send_wnc_cmd("AT+CMGR", &pRespStr, m_sCmdTimeoutMs) == WNC_AT_CMD_OK) *log = pRespStr->c_str(); else @@ -1267,6 +1277,11 @@ // Quick commands below do not need to check cellular connectivity at_send_wnc_cmd("ATE0", &pRespStr, WNC_QUICK_CMD_TIMEOUT_MS); // Echo Off at_send_wnc_cmd("AT+CMEE=2", &pRespStr, m_sCmdTimeoutMs); // 2 - verbose error, 1 - numeric error, 0 - just ERROR + + // Setup 3 memory slots in the WNC SIM for SMS usage. + at_send_wnc_cmd("AT+CMGF=1", &pRespStr, m_sCmdTimeoutMs); + at_send_wnc_cmd("AT+CPMS=\"SM\",\"SM\",\"SM\"", &pRespStr, m_sCmdTimeoutMs); + cmdRes = at_send_wnc_cmd("AT", &pRespStr, WNC_QUICK_CMD_TIMEOUT_MS); // Heartbeat? // If the simple commands are not working, no chance of more complex. @@ -1401,9 +1416,9 @@ cmd_str += _to_string(numSock + 1); cmd_str += ","; cmd_str += _to_string(n); - cmd_str += num2str; cmd_str += ",\""; - while(*s != '\0') { + while(n > 0) { + n--; num2str = _to_hex_string((uint8_t)*s++); // Always 2-digit ascii hex: if (strlen(num2str) == 1)