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.

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Thu Sep 27 13:11:44 2012 +0000
Parent:
49:978bffab17a8
Child:
51:54ca82a7644c
Commit message:
Fixed deadlock in SMS receiving routine; delete message even if cannot be read

Changed in this revision

at/ATCommandsInterface.cpp Show annotated file Show diff for this revision Revisions of this file
at/ATCommandsInterface.h Show annotated file Show diff for this revision Revisions of this file
sms/SMSInterface.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/at/ATCommandsInterface.cpp	Thu Sep 27 10:13:44 2012 +0000
+++ b/at/ATCommandsInterface.cpp	Thu Sep 27 13:11:44 2012 +0000
@@ -33,7 +33,7 @@
 
 ATCommandsInterface::ATCommandsInterface(IOStream* pStream) :
    m_pStream(pStream), m_open(false), m_env2AT(), m_AT2Env(), m_processingMtx(),
-   m_processingThread(&ATCommandsInterface::staticCallback, this, (osPriority)AT_THREAD_PRIORITY, 6*192),
+   m_processingThread(&ATCommandsInterface::staticCallback, this, (osPriority)AT_THREAD_PRIORITY, 4*192),
    m_eventsMtx()
 {
   memset(m_eventsHandlers, 0, MAX_AT_EVENTS_HANDLERS * sizeof(IATEventsHandler*));
--- a/at/ATCommandsInterface.h	Thu Sep 27 10:13:44 2012 +0000
+++ b/at/ATCommandsInterface.h	Thu Sep 27 13:11:44 2012 +0000
@@ -51,7 +51,7 @@
   friend class ATCommandsInterface;
 };
 
-#define AT_INPUT_BUF_SIZE 64
+#define AT_INPUT_BUF_SIZE 192//64
 
 //Signals to be sent to the processing thread
 #define AT_SIG_PROCESSING_START 1
--- a/sms/SMSInterface.cpp	Thu Sep 27 10:13:44 2012 +0000
+++ b/sms/SMSInterface.cpp	Thu Sep 27 13:11:44 2012 +0000
@@ -157,29 +157,29 @@
 
   if (m_state != SMS_CMD_PROCESSED)
   {
-    WARN(" State variable is not 'SMS_CMD_PROCESSED' - returning 'NET_EMPTY'");
-    m_state = SMS_IDLE;
-    m_inboxMtx.unlock();
-    return NET_EMPTY;
+    WARN("State variable is not 'SMS_CMD_PROCESSED' - returning 'NET_EMPTY'");
   }
 
-  m_state = SMS_IDLE;
-
   DBG("Deleting message from index number: %d", m_msgRefList[0] );
   //Delete message from outbox
   std::sprintf(cmd, "AT+CMGD=%d", m_msgRefList[0]);
   ret = m_pIf->executeSimple(cmd, NULL, DEFAULT_TIMEOUT);
   if(ret != OK)
   {
-    m_inboxMtx.unlock();
-    WARN("Could not delete message");
+    ERR("Could not delete message");
   }
-  else
-  {
   //Remove message from list
   std::memmove(m_msgRefList, m_msgRefList+1, m_msgRefListCount-1);
   m_msgRefListCount--;
-  }  
+  
+  if (m_state != SMS_CMD_PROCESSED)
+  {
+    m_state = SMS_IDLE;
+    m_inboxMtx.unlock();
+    return NET_EMPTY;
+  }
+  
+  m_state = SMS_IDLE;
   m_inboxMtx.unlock();
 
   return OK;
@@ -342,18 +342,25 @@
   if( std::sscanf(evt, "\"SM\",%d", &msgRef) == 1 )
   {
     DBG("Adding message to list (ref %d)", msgRef);
-    m_inboxMtx.lock();
-    //Add message to list
-    if(m_msgRefListCount < MAX_SM)
+    if(m_inboxMtx.trylock())
     {
-      m_msgRefList[m_msgRefListCount] = msgRef;
+      //Add message to list
+      if(m_msgRefListCount < MAX_SM)
+      {
+        m_msgRefList[m_msgRefListCount] = msgRef;
+      }
+      else
+      {
+        m_needsUpdate = true;
+      }
+      m_msgRefListCount++; //Always count message
+      m_inboxMtx.unlock();
     }
     else
     {
+      WARN("Could not get lock");
       m_needsUpdate = true;
     }
-    m_msgRefListCount++; //Always count message
-    m_inboxMtx.unlock();
   }
 }
 
@@ -363,6 +370,7 @@
 
   DBG("Updating inbox");
   m_msgRefListCount = 0; //Reset list
+  m_needsUpdate = false; //Assume we won't need update after this routine (can be set to true by an incoming SM event)
 
   //First list the "REC READ" messages that were not processed in the previous session
   m_state = SMS_GET_COUNT_CMD_SENT;
@@ -376,7 +384,7 @@
     return NET_PROTOCOL;
   }
   
-  //Now list the "REC UNREAD" messages that were received modem since
+  //Now list the "REC UNREAD" messages that were received by the modem since
   m_state = SMS_GET_COUNT_CMD_SENT;
   ret = m_pIf->execute("AT+CMGL=\"REC UNREAD\"", this, NULL, DEFAULT_TIMEOUT);
   if( ret != OK )
@@ -394,10 +402,6 @@
   {
     m_needsUpdate = true;
   }
-  else
-  {
-    m_needsUpdate = false;
-  }
 
   m_state = SMS_IDLE;