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:
ashleymills
Date:
Fri Sep 20 10:40:58 2013 +0000
Parent:
90:f8d65dc86a97
Child:
92:ed0443728c60
Commit message:
Added support for Ublox LISA U200 module. Fixed bug for modules that throw away blocked unsolicited messages.

Changed in this revision

USBHostWANDongle.lib Show annotated file Show diff for this revision Revisions of this file
VodafoneUSBModem.cpp Show annotated file Show diff for this revision Revisions of this file
at/ATCommandsInterface.cpp Show annotated file Show diff for this revision Revisions of this file
core/MtxCircBuffer.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/USBHostWANDongle.lib	Thu Jun 27 12:16:30 2013 +0000
+++ b/USBHostWANDongle.lib	Fri Sep 20 10:40:58 2013 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/USBHostWANDongle/#b241a57c465b
+https://mbed.org/users/mbed_official/code/USBHostWANDongle/#980fe31c14f7
--- a/VodafoneUSBModem.cpp	Thu Jun 27 12:16:30 2013 +0000
+++ b/VodafoneUSBModem.cpp	Fri Sep 20 10:40:58 2013 +0000
@@ -507,7 +507,7 @@
 
 int VodafoneUSBModem::init()
 {
-  DBG("Entering init method for the VodafoneUSBModem");
+  //DBG("Entering init method for the VodafoneUSBModem");
   if( !m_dongleConnected )
   {
     DBG("Dongle is not connected");
@@ -576,7 +576,7 @@
     return ret;
   }
 
-  if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_VODAFONEK3770)
+  if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_VODAFONE_K3770)
   {
     INFO("Using a Vodafone K3770 Dongle");
     #if USE_ONE_PORT
@@ -596,7 +596,7 @@
     }  
     #endif
   }
-  else if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_VODAFONEK3772Z)
+  else if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_VODAFONE_K3772Z)
   {
     INFO("Using a Vodafone K3772-Z Dongle");
     //FIXME this returns %USBMODEM: [0] MODEM DRIVER<CR><LF><CR><LF><CR><LF>OK<CR><LF> which is not a compliant response
@@ -609,7 +609,7 @@
     }
     */
   }
-  else if(m_dongle.getDongleType()== WAN_DONGLE_TYPE_VODAFONEK3773)
+  else if(m_dongle.getDongleType()== WAN_DONGLE_TYPE_VODAFONE_K3773)
   {
      INFO("Using a Vodafone K3773 M2M dongle.");
      INFO("Disabling sim toolkit notifications");
@@ -623,7 +623,7 @@
         return NET_PROTOCOL;
      }
   }
-  else if(m_dongle.getDongleType()== WAN_DONGLE_TYPE_VODAFONEMU509)
+  else if(m_dongle.getDongleType()== WAN_DONGLE_TYPE_HUAWEI_MU509)
   {
      INFO("Using a Huawei MU509 module.");
      m_ppp.setHangupViaATPort(true);
@@ -642,6 +642,18 @@
       return NET_PROTOCOL;
      } 
   }
+  else if(m_dongle.getDongleType() == WAN_DONGLE_TYPE_UBLOX_LISAU200)
+  {
+    INFO("Using a u-blox LISA-U");
+    
+     /*
+     // change SMS storage to SIM
+     ret = m_at.executeSimple("at+cpms=\"mt\",\"mt\",\"sm\"",NULL);
+     if(ret!=0) {
+        return NET_PROTOCOL;
+     }
+     */
+  }
   else
   {
     WARN("Using an Unknown Dongle");
--- a/at/ATCommandsInterface.cpp	Thu Jun 27 12:16:30 2013 +0000
+++ b/at/ATCommandsInterface.cpp	Fri Sep 20 10:40:58 2013 +0000
@@ -297,7 +297,7 @@
   }
 
   DBG("Command returned successfully");
-
+  
   return ret;
 }
 
@@ -318,7 +318,20 @@
   {
     m_inputPos+=readLen;
     m_inputBuf[m_inputPos] = '\0'; //Add null terminating character to ease the use of str* functions
-    DBG("In buffer: [%s]", m_inputBuf);
+    #if __DEBUG__ >= 4
+    DBGX("In buffer: [");
+    if __DEBUG__
+    for(int i=0; i<strlen(m_inputBuf); i++) {
+       if(m_inputBuf[i]=='\r') {
+          DBGX("<CR>");
+       } else if(m_inputBuf[i]=='\n') {
+          DBGX("<LF>");
+       } else {
+          DBGX("%c",m_inputBuf[i]);
+       }
+    }
+    DBGX("]\r\n");
+    #endif
   }
 
   if( ret == NET_INTERRUPTED ) //It is worth checking readLen as data might have been read even though the read was interrupted
@@ -484,6 +497,7 @@
             m_inputBuf[crPos] = '\0';
             //Process line
             int ret = processReadLine();
+            // ret is non-zero in case of error
             if(ret)
             {
               m_inputPos = 0;
--- a/core/MtxCircBuffer.h	Thu Jun 27 12:16:30 2013 +0000
+++ b/core/MtxCircBuffer.h	Fri Sep 20 10:40:58 2013 +0000
@@ -54,6 +54,10 @@
 
   void queue(T k)
   {
+    // XXX Some modems spew stuff out on multiple interfaces
+    // which can cause the circular buffer to block if
+    // the unread queues are not flushed. Need to make this
+    // non-blocking: just overwrite oldest chars for example.
     mtx.lock();
     while (((write + 1) % size) == read) //if (isFull())
     {
--- a/sms/SMSInterface.cpp	Thu Jun 27 12:16:30 2013 +0000
+++ b/sms/SMSInterface.cpp	Fri Sep 20 10:40:58 2013 +0000
@@ -103,6 +103,8 @@
   }
 
   DBG("SM sent");
+  // since unsolicited events are blocked during send SM events,it makes sense to update the mailbox
+  m_needsUpdate = true;
   m_state = SMS_IDLE;
   return OK;
 }
@@ -281,7 +283,7 @@
     {
       int crPos = crPtr - m_msg;
       //Replace m_inputBuf[crPos] with null-terminating char
-      m_msg[crPos] = '\x0';
+      m_msg[crPos] = '\0';
 
       //If there is a CR char, split message there
 
@@ -363,7 +365,8 @@
 
   //Get index
   int msgRef;
-  if( std::sscanf(evt, "\"SM\",%d", &msgRef) == 1 )
+  if(( std::sscanf(evt, "\"SM\",%d", &msgRef) == 1 ) || 
+     ( std::sscanf(evt, "\"ME\",%d", &msgRef) == 1 )) // ublox modules preferentially use ME for storage
   {
     DBG("Adding message to list (ref %d)", msgRef);
     if(m_inboxMtx.trylock())