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:
69:9b475f458fbc
Parent:
61:0bcb8c5216d4
Child:
71:0da249386019
--- a/VodafoneUSBModem.cpp	Tue Nov 13 12:00:34 2012 +0000
+++ b/VodafoneUSBModem.cpp	Wed Feb 06 16:51:39 2013 +0000
@@ -17,7 +17,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#define __DEBUG__ 3
+#define __DEBUG__ 4
 #ifndef __MODULE__
 #define __MODULE__ "VodafoneUSBModem.cpp"
 #endif
@@ -442,6 +442,7 @@
 
 int VodafoneUSBModem::getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer)
 {
+  DBG("Entering getLinkState.");
   int ret = init();
   if(ret)
   {
@@ -504,8 +505,10 @@
 
 int VodafoneUSBModem::init()
 {
+  DBG("Entering init method for the VodafoneUSBModme");
   if( !m_dongleConnected )
   {
+    DBG("Dongle is not connected");
     if(!power())
     {
       //Obviously cannot initialize the dongle if it is disconnected...
@@ -513,11 +516,38 @@
       return NET_INVALID;
     }
     m_dongleConnected = true;
-    while( !m_dongle.connected() )
+    bool detectConnectedModem = false;          // local variable to use to create a while loop that we can break out of - this is used to detect if we can see a modem or not
+    
+    while(!detectConnectedModem)
     {
-      m_dongle.tryConnect();
-      Thread::wait(10);
+        for (int x=0; x<100;x++)
+        {
+            DBG("Trying to connect the dongle");
+            m_dongle.tryConnect();
+            if (m_dongle.connected())
+            {
+                DBG("Great the dongle is connected");
+                detectConnectedModem = true;        // OK we can break out this while loop now - the dongle has been connected
+                break;                              // Break out of the for loop once the dongle is connected - otherwise try for a while more
+            }
+            Thread::wait(10);
+        }
+        
+        // OK we got this far - so give up trying and let someone know you can't see the modem
+        m_dongleConnected = false;                  // set the member variable of this object to false - so if we get called again we know we have to try to detect again
+        ERR("There is no dongle pluged into the board, or the module does not respond. Is the module/modem switched on?");
+        return HARDWARE_NO_RESPONSE;
     }
+        
+    
+    //while( !m_dongle.connected() )
+    //{
+    //  DBG("Trying to connect the dongle");
+    //  m_dongle.tryConnect();
+    //  Thread::wait(10);
+    //}
+    
+    
   }
 
   if(m_atOpen)