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:
Fri Jul 06 08:56:32 2012 +0000
Parent:
8:04b6a042595f
Child:
11:565b2ec40dea
Commit message:
Dual serial ports support

Changed in this revision

LwIPNetworking.lib Show annotated file Show diff for this revision Revisions of this file
USBHostWANDongleLib.lib Show annotated file Show diff for this revision Revisions of this file
VodafoneK3770.cpp Show annotated file Show diff for this revision Revisions of this file
ip/PPPIPInterface.cpp Show annotated file Show diff for this revision Revisions of this file
lwipopts.h Show diff for this revision Revisions of this file
lwipopts_conf.h Show annotated file Show diff for this revision Revisions of this file
serial/io/IOSerialStream.cpp Show annotated file Show diff for this revision Revisions of this file
serial/usb/USBSerialStream.cpp Show annotated file Show diff for this revision Revisions of this file
sms/SMSInterface.h Show annotated file Show diff for this revision Revisions of this file
ussd/USSDInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/LwIPNetworking.lib	Tue Jun 26 13:44:59 2012 +0000
+++ b/LwIPNetworking.lib	Fri Jul 06 08:56:32 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/LwIPNetworking/#cf5f669a30bc
+http://mbed.org/users/mbed_official/code/LwIPNetworking/#eb7131dbf6ae
--- a/USBHostWANDongleLib.lib	Tue Jun 26 13:44:59 2012 +0000
+++ b/USBHostWANDongleLib.lib	Fri Jul 06 08:56:32 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/USBHostWANDongle_bleedingedge/#a8b2d0cd9bbd
+http://mbed.org/users/donatien/code/USBHostWANDongle_bleedingedge/#4394986752db
--- a/VodafoneK3770.cpp	Tue Jun 26 13:44:59 2012 +0000
+++ b/VodafoneK3770.cpp	Fri Jul 06 08:56:32 2012 +0000
@@ -31,8 +31,8 @@
 #include "VodafoneK3770.h"
 
 VodafoneK3770::VodafoneK3770() : m_dongle(),
-m_atStream(m_dongle.getSerial(1)), m_pppStream(m_dongle.getSerial(0)), m_at(&m_atSream),
-m_ppp(&m_pppStream), m_sms(&m_at), m_ussd(&m_at),
+m_atStream(m_dongle.getSerial(1)), m_pppStream(m_dongle.getSerial(0)), m_at(&m_atStream),
+m_sms(&m_at), m_ussd(&m_at), m_ppp(&m_pppStream), 
 m_dongleConnected(false), m_ipInit(false), m_smsInit(false), m_atOpen(false)
 {
 
--- a/ip/PPPIPInterface.cpp	Tue Jun 26 13:44:59 2012 +0000
+++ b/ip/PPPIPInterface.cpp	Fri Jul 06 08:56:32 2012 +0000
@@ -37,8 +37,6 @@
 #include "netif/ppp/ppp.h"
 }
 
-#if NET_PPP
-
 PPPIPInterface::PPPIPInterface(IOStream* pStream) : LwIPInterface(), m_linkStatusSphre(1), m_pppErrCode(0), m_pStream(pStream), m_streamAvail(true), m_pppd(-1)
 {
   m_linkStatusSphre.wait();
@@ -154,28 +152,28 @@
     DBG("Remote IP address: %s", inet_ntoa(addrs->his_ipaddr));
     DBG("Primary DNS: %s", inet_ntoa(addrs->dns1));
     DBG("Secondary DNS: %s", inet_ntoa(addrs->dns2));
-    setConnected(true);
-    setIPAddress(inet_ntoa(addrs->our_ipaddr));
+    pIf->setConnected(true);
+    pIf->setIPAddress(inet_ntoa(addrs->our_ipaddr));
     break;
   case PPPERR_CONNECT: //Connection lost
     WARN("Connection lost/terminated");
-    setConnected(false);
+    pIf->setConnected(false);
     break;
   case PPPERR_AUTHFAIL: //Authentication failed
     WARN("Authentication failed");
-    setConnected(false);
+    pIf->setConnected(false);
     break;
   case PPPERR_PROTOCOL: //Protocol error
     WARN("Protocol error");
-    setConnected(false);
+    pIf->setConnected(false);
     break;
   case PPPERR_USER:
     WARN("Disconnected by user");
-    setConnected(false);
+    pIf->setConnected(false);
     break;
   default:
     WARN("Unknown error (%d)", errCode);
-    setConnected(false);
+    pIf->setConnected(false);
     break;
   }
 
@@ -265,5 +263,3 @@
 
 }
 
-#endif
-
--- a/lwipopts.h	Tue Jun 26 13:44:59 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/* lwipopts.h */
-/*
- Copyright (C) 2012 ARM Limited.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do
- so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
-
-#ifndef LWIPOPTS_H_
-#define LWIPOPTS_H_
- 
-#include "lwipopts_common.h" //Get common options
-
-///PPP Options
-
-#define TCP_SND_BUF                     (3 * 536)
-#define TCP_WND                         (2 * 536)
-
-#define LWIP_ARP 0
-
-#define PPP_SUPPORT 1
-#define CHAP_SUPPORT                    1
-#define PAP_SUPPORT                     1
-#define PPP_THREAD_STACKSIZE            4*192
-#define PPP_THREAD_PRIO 0
-
-#define MAXNAMELEN                      64     /* max length of hostname or name for auth */
-#define MAXSECRETLEN                    64
-
-#endif /* LWIPOPTS_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lwipopts_conf.h	Fri Jul 06 08:56:32 2012 +0000
@@ -0,0 +1,29 @@
+/* lwipopts.h */
+/*
+ Copyright (C) 2012 ARM Limited.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do
+ so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
+
+#ifndef LWIPOPTS_CONF_H_
+#define LWIPOPTS_CONF_H_
+ 
+#define LWIP_TRANSPORT_PPP 1
+
+#endif /* LWIPOPTS_CONF_H_ */
\ No newline at end of file
--- a/serial/io/IOSerialStream.cpp	Tue Jun 26 13:44:59 2012 +0000
+++ b/serial/io/IOSerialStream.cpp	Fri Jul 06 08:56:32 2012 +0000
@@ -55,7 +55,7 @@
   int ret = waitAvailable(timeout);
   if(ret)
   {
-    WARN("Error %d while waiting for incoming data");
+    WARN("Error %d while waiting for incoming data", ret);
     return ret;
   }
   int readLen = MIN( available(), maxLength );
@@ -146,7 +146,7 @@
   int ret = waitSpace(timeout);
   if(ret)
   {
-    WARN("Error %d while waiting for space");
+    WARN("Error %d while waiting for space", ret);
     return ret;
   }
   DBG("Writing %d chars", length);
@@ -163,7 +163,7 @@
       ret = waitSpace(timeout);
       if(ret)
       {
-        WARN("Error %d while waiting for space");
+        WARN("Error %d while waiting for space", ret);
         return ret;
       }
       setupWriteableISR(false);
--- a/serial/usb/USBSerialStream.cpp	Tue Jun 26 13:44:59 2012 +0000
+++ b/serial/usb/USBSerialStream.cpp	Fri Jul 06 08:56:32 2012 +0000
@@ -57,7 +57,8 @@
     WARN("Error %d while waiting for incoming data", ret);
     return ret;
   }
-  int readLen = MIN( available(), maxLength );
+  int a = available(); //Prevent macro issues
+  int readLen = MIN( a, maxLength );
   *pLength = readLen;
 
   setupReadableISR(false);
@@ -84,7 +85,7 @@
   int ret;
   if(available()) //Is data already available?
   {
-    m_availableSphre.wait(0); //Clear the queue as data is available
+    while( m_availableSphre.wait(0) > 0 ); //Clear the queue as data is available
     return OK;
   }
 
@@ -101,7 +102,7 @@
     return NET_INTERRUPTED;
   }
   DBG("Finished waiting");
-  m_availableSphre.wait(0); //Clear the queue as data is available
+  while( m_availableSphre.wait(0) > 0 ); //Clear the queue as data is available
   return OK;
 }
 
@@ -142,11 +143,12 @@
     int ret = waitSpace(timeout);
     if(ret)
     {
-      WARN("Error %d while waiting for space");
+      WARN("Error %d while waiting for space", ret);
       return ret;
     }
-    int writeLen = MIN( space(), length );
-    DBG("Writing %d chars", length);
+    int s = space(); //Prevent macro issues
+    int writeLen = MIN( s, length );
+    DBG("Writing %d chars", writeLen);
     setupWriteableISR(false);
     while(writeLen)
     {
@@ -155,15 +157,14 @@
       length--;
       writeLen--;
     }
+    //If m_serial tx fifo is empty we need to start the packet write
+    if( m_outBuf.available() && m_serialTxFifoEmpty )
+    {
+      writeable();
+    }
     setupWriteableISR(true);
   } while(length);
-  //If m_serial tx fifo is empty we need to start the packet write
-  setupWriteableISR(false);
-  if( m_outBuf.available() && m_serialTxFifoEmpty )
-  {
-    writeable();
-  }
-  setupWriteableISR(true);
+
   DBG("Write successful");
   return OK;
 }
@@ -181,7 +182,7 @@
   int ret;
   if(space()) //Is still space already left?
   {
-    m_spaceSphre.wait(0); //Clear the queue as space is available
+    while( m_spaceSphre.wait(0) > 0); //Clear the queue as space is available
     return OK;
   }
 
@@ -197,7 +198,7 @@
     DBG("Aborted");
     return NET_INTERRUPTED;
   }
-  m_spaceSphre.wait(0); //Clear the queue as space is available
+  while( m_spaceSphre.wait(0) > 0); //Clear the queue as space is available
   return OK;
 }
 
@@ -230,8 +231,10 @@
       m_outBuf.dequeue(&c);
       m_serial.putc((char)c);
     }
-    static volatile int i=0;
     m_serial.writePacket(); //Start packet write
   }
-  m_spaceSphre.release(); //Force exiting the waiting state
+  if(!m_outBuf.isFull())
+  {
+    m_spaceSphre.release(); //Force exiting the waiting state
+  }
 }
--- a/sms/SMSInterface.h	Tue Jun 26 13:44:59 2012 +0000
+++ b/sms/SMSInterface.h	Fri Jul 06 08:56:32 2012 +0000
@@ -28,7 +28,7 @@
 
 #include "rtos.h"
 
-#include "drv/at/ATCommandsInterface.h"
+#include "at/ATCommandsInterface.h"
 
 #define MAX_SM 8
 
--- a/ussd/USSDInterface.h	Tue Jun 26 13:44:59 2012 +0000
+++ b/ussd/USSDInterface.h	Fri Jul 06 08:56:32 2012 +0000
@@ -28,7 +28,7 @@
 
 #include "rtos.h"
 
-#include "drv/at/ATCommandsInterface.h"
+#include "at/ATCommandsInterface.h"
 
 /** Component to send/receive Unstructured Supplementary Service Data (USSD)
  *