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
This is the driver for the Vodafone K3700 & K3772-Z Dongles:
More details and instructions can be found here.
Diff: VodafoneUSBModem.cpp
- Revision:
- 84:39e28d162195
- Parent:
- 83:897a0de9d668
- Parent:
- 74:b70519f17a22
- Child:
- 87:62af9b9d3e13
--- a/VodafoneUSBModem.cpp Tue Mar 05 14:54:15 2013 +0000 +++ b/VodafoneUSBModem.cpp Fri Mar 08 10:21:36 2013 +0000 @@ -17,7 +17,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #define __DEBUG__ 0 + #ifndef __MODULE__ #define __MODULE__ "VodafoneUSBModem.cpp" #endif @@ -442,6 +444,7 @@ int VodafoneUSBModem::getLinkState(int* pRssi, LinkMonitor::REGISTRATION_STATE* pRegistrationState, LinkMonitor::BEARER* pBearer) { + DBG("Entering getLinkState."); int ret = init(); if(ret) { @@ -504,8 +507,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 +518,43 @@ 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 - I've tried %d times to connect", x); + 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); + } + if (!detectConnectedModem) + { + // 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?"); + Thread:wait(1000); + //DBG("Last ditch attempt to re-initialise the USB Subsystem"); + //m_dongle.init(); + return HARDWARE_NO_RESPONSE; + } } + + + //while( !m_dongle.connected() ) + //{ + // DBG("Trying to connect the dongle"); + // m_dongle.tryConnect(); + // Thread::wait(10); + //} + + } if(m_atOpen)