Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Socket USBHostWANDongle lwip-sys lwip
Fork of VodafoneUSBModem by
Revision 58:f1965f3f4504, committed 2012-10-22
- Comitter:
- donatien
- Date:
- Mon Oct 22 15:47:01 2012 +0000
- Parent:
- 55:07b9b48cfe09
- Child:
- 59:593fb493172f
- Commit message:
- Fixed messages indexes' list shifting bug
Changed in this revision
| sms/SMSInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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;
