Changes to support Vodafone K4606

Dependencies:   Socket USBHostWANDongle lwip-sys lwip

Fork of VodafoneUSBModem by mbed official

Revision:
27:37d3ac289e86
Parent:
26:d37501dc6c61
Child:
33:f505faeda8e7
--- a/VodafoneUSBModem.cpp	Wed Aug 29 16:28:13 2012 +0000
+++ b/VodafoneUSBModem.cpp	Thu Aug 30 09:16:05 2012 +0000
@@ -455,25 +455,15 @@
   {
     return NET_INVALID; //A pin name has not been provided in the constructor
   }
-  
-  if(!enable && m_ppp.isConnected())
+
+  if(!enable) //Will force components to re-init
   {
-    WARN("Data connection is still open"); //Try to encourage good behaviour from the user
-    m_ppp.disconnect(); 
+    cleanup();
   }
   
   DigitalOut powerGatingOut(m_powerGatingPin);
   powerGatingOut = enable;
-  if(!enable) //Will force components to re-init
-  {
-    m_dongleConnected = false;
-    m_smsInit = false;
-    m_ussdInit = false;
-    m_linkMonitorInit = false;
-    m_atOpen = false;
-    //We don't reset m_ipInit as PPPIPInterface::init() only needs to be called once
-  }
-  
+
   return OK;
 }
 
@@ -589,4 +579,28 @@
   return OK;
 }
 
+int VodafoneUSBModem::cleanup()
+{
+  if(m_ppp.isConnected())
+  {
+    WARN("Data connection is still open"); //Try to encourage good behaviour from the user
+    m_ppp.disconnect(); 
+  }
+  
+  m_smsInit = false;
+  m_ussdInit = false;
+  m_linkMonitorInit = false;
+  //We don't reset m_ipInit as PPPIPInterface::init() only needs to be called once
+  
+  if(m_atOpen)
+  {
+    m_at.close();
+    m_atOpen = false;
+  }
+  
+  m_dongle.disconnect();
+  m_dongleConnected = false;
+  
+  return OK;
+}