Vodafone K3770/K3772-Z modems driver & networking library

Dependencies:   Socket USBHostWANDongle lwip-sys lwip

Dependents:   VodafoneUSBModemHTTPClientTest VodafoneUSBModemNTPClientTest VodafoneUSBModemSMSTest VodafoneUSBModemUSSDTest ... more

Fork of VodafoneUSBModem_bleedingedge by Donatien Garnier

This is the driver for the Vodafone K3700 & K3772-Z Dongles:

K3770

More details and instructions can be found here.

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;