PHS module SMA-01 library. see: https://developer.mbed.org/users/phsfan/notebook/abitusbmodem/
Dependencies: Socket lwip-sys lwip
Dependents: AbitUSBModem_HTTPTest AbitUSBModem_MQTTTest AbitUSBModem_WebsocketTest AbitUSBModem_SMSTest
Fork of VodafoneUSBModem by
Diff: sms/SMSInterface.cpp
- Revision:
- 58:f1965f3f4504
- Parent:
- 50:8ad4cb12749d
- Child:
- 59:593fb493172f
--- a/sms/SMSInterface.cpp Mon Oct 22 10:15:53 2012 +0000 +++ b/sms/SMSInterface.cpp Mon Oct 22 15:47:01 2012 +0000 @@ -117,9 +117,9 @@ DBG("Get next message"); m_inboxMtx.lock(); - if(m_msgRefListCount == 0 && m_needsUpdate) + if( ((m_msgRefListCount == 0) && m_needsUpdate) || ((m_msgRefListCount > 0) && (m_msgRefList[0] == -1)) ) { - DBG("Message list count is 0 and needs updating. Running updateInbox."); + DBG("Message list count is 0 and needs updating or next index is unknown, calling updateInbox()"); ret = updateInbox(); if (ret) @@ -128,6 +128,8 @@ return ret; } } + + DBG("%d messages to read", m_msgRefListCount); if(m_msgRefListCount == 0) { @@ -169,9 +171,17 @@ ERR("Could not delete message"); } //Remove message from list - std::memmove(m_msgRefList, m_msgRefList+1, m_msgRefListCount-1); + std::memmove(&m_msgRefList[0], &m_msgRefList[1], MIN(m_msgRefListCount-1,MAX_SM-1)*sizeof(m_msgRefList[0])); m_msgRefListCount--; + if(m_msgRefListCount > MAX_SM - 1) //Last message index is unknown, so put -1 to tell the lib to fetch it when needed + { + DBG("Last message index is unknown, will need to be updated"); + m_msgRefList[MAX_SM - 1] = -1; + } + + DBG("%d messages to read", m_msgRefListCount); + if (m_state != SMS_CMD_PROCESSED) { m_state = SMS_IDLE; @@ -349,10 +359,6 @@ { m_msgRefList[m_msgRefListCount] = msgRef; } - else - { - m_needsUpdate = true; - } m_msgRefListCount++; //Always count message m_inboxMtx.unlock(); } @@ -398,11 +404,6 @@ DBG("%d incoming messages in inbox", m_msgRefListCount); - if( m_msgRefListCount > MAX_SM ) - { - m_needsUpdate = true; - } - m_state = SMS_IDLE; return OK;