local fork
Dependencies: Socket USBHostWANDongle_bleedingedge lwip-sys lwip
Fork of VodafoneUSBModem_bleedingedge by
Diff: sms/SMSInterface.cpp
- Revision:
- 28:c94ffb45a848
- Parent:
- 26:d37501dc6c61
- Child:
- 39:85dc5ca10b7f
diff -r 37d3ac289e86 -r c94ffb45a848 sms/SMSInterface.cpp --- a/sms/SMSInterface.cpp Thu Aug 30 09:16:05 2012 +0000 +++ b/sms/SMSInterface.cpp Thu Aug 30 10:48:35 2012 +0000 @@ -233,7 +233,7 @@ { DBG("Header: %s", line); int msgRef; - if( std::sscanf(line, "+CMGL: %d", &msgRef) == 1 ) + if( std::sscanf(line, "+CMGL: %d,\"REC", &msgRef) == 1 ) //Filter on REC READ and REC UNREAD messages { m_state = SMS_GET_COUNT_HDR_RECEIVED; //Add message to list @@ -355,12 +355,25 @@ int SMSInterface::updateInbox() { //Get memory indexes of unread messages - m_state = SMS_GET_COUNT_CMD_SENT; DBG("Updating inbox"); m_msgRefListCount = 0; //Reset list - int ret = m_pIf->execute("AT+CMGL=\"REC UNREAD\"", this, NULL, DEFAULT_TIMEOUT); + //First list the "REC READ" messages that were not processed in the previous session + m_state = SMS_GET_COUNT_CMD_SENT; + int ret = m_pIf->execute("AT+CMGL=\"REC READ\"", this, NULL, DEFAULT_TIMEOUT); + if( ret != OK ) + { + WARN("AT+CMGL returned %d", ret); + m_state = SMS_IDLE; + m_msgRefListCount = 0; //List could be invalid + m_needsUpdate = true; + return NET_PROTOCOL; + } + + //Now list the "REC UNREAD" messages that were received modem since + m_state = SMS_GET_COUNT_CMD_SENT; + ret = m_pIf->execute("AT+CMGL=\"REC UNREAD\"", this, NULL, DEFAULT_TIMEOUT); if( ret != OK ) { WARN("AT+CMGL returned %d", ret);