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.
Revision 61:0bcb8c5216d4, committed 2012-11-01
- Comitter:
- donatien
- Date:
- Thu Nov 01 13:01:03 2012 +0000
- Parent:
- 60:763eefc845b1
- Child:
- 62:6f42a974eea6
- Commit message:
- Fixed race condition within the timeout mechanism of the ATCommandsInterface.cpp module; Added retries for setting the PDP context
Changed in this revision
--- a/USBHostWANDongleLib.lib Wed Oct 24 14:15:53 2012 +0000 +++ b/USBHostWANDongleLib.lib Thu Nov 01 13:01:03 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/USBHostWANDongle_bleedingedge/#c154e7f2e42f +http://mbed.org/users/donatien/code/USBHostWANDongle_bleedingedge/#c154e7f2e42f \ No newline at end of file
--- a/VodafoneUSBModem.cpp Wed Oct 24 14:15:53 2012 +0000 +++ b/VodafoneUSBModem.cpp Thu Nov 01 13:01:03 2012 +0000 @@ -214,9 +214,13 @@ { DBG("Connected to %s with %s", copsProcessor.getNetwork(), copsProcessor.getBearer()); char cmd[48]; + int tries = 3; sprintf(cmd, "AT+CGDCONT=1,\"IP\",\"%s\"", copsProcessor.getAPN()); - ret = m_at.executeSimple(cmd, &result); - DBG("Result of command: Err code=%d", ret); + do //Try 3 times because for some reasons it can fail with the K3772-Z dongle + { + ret = m_at.executeSimple(cmd, &result); + DBG("Result of command: Err code=%d", ret); + } while(ret && --tries); DBG("ATResult: AT return=%d (code %d)", result.result, result.code); DBG("APN set to %s", copsProcessor.getAPN()); } @@ -224,9 +228,17 @@ if(apn != NULL) { char cmd[48]; + int tries = 30; sprintf(cmd, "AT+CGDCONT=1,\"IP\",\"%s\"", apn); - ret = m_at.executeSimple(cmd, &result); - DBG("Result of command: Err code=%d", ret); + do //Try 30 times because for some reasons it can fail *a lot* with the K3772-Z dongle + { + ret = m_at.executeSimple(cmd, &result); + DBG("Result of command: Err code=%d", ret); + if(ret) + { + Thread::wait(500); + } + } while(ret && --tries); DBG("ATResult: AT return=%d (code %d)", result.result, result.code); DBG("APN set to %s", apn); }
--- a/at/ATCommandsInterface.cpp Wed Oct 24 14:15:53 2012 +0000 +++ b/at/ATCommandsInterface.cpp Thu Nov 01 13:01:03 2012 +0000 @@ -110,6 +110,12 @@ } DBG("Closing AT interface"); + + //Lock transaction mutex + m_transactionMtx.lock(); + + //Disable events handling and advertize this to the events handlers + disableEvents(); //Stop processing m_processingThread.signal_set(AT_SIG_PROCESSING_STOP); @@ -123,9 +129,9 @@ m_pStream->abortRead(); //This is thread-safe m_processingMtx.lock(); m_open = false; - - //Disable events handling and advertize this to the events handlers - disableEvents(); + + //Unlock transaction mutex + m_transactionMtx.unlock(); DBG("AT interface closed"); return OK; @@ -250,6 +256,15 @@ DBG("Trying to enter abortRead()"); //Unlock process routine (abort read) m_pStream->abortRead(); //This is thread-safe + + //Wait for acknowledge + int msgResult; + do + { + evt = m_AT2Env.get(osWaitForever); + msgResult = *((int*) evt.value.p); + m_AT2Env.free((int*)evt.value.p); + } while(msgResult != AT_TIMEOUT); WARN("Command returned no message"); return NET_TIMEOUT; @@ -564,8 +579,12 @@ m_pStream->write((uint8_t*)&cr, 1, osWaitForever); //Carriage return line terminator m_transactionState = COMMAND_SENT; } - else + else //Timeout { + //Acknowledge + int* msg = m_AT2Env.alloc(osWaitForever); + *msg = AT_TIMEOUT; + m_AT2Env.put(msg); //Command has timed out m_transactionState = IDLE; //State-machine reset } m_env2AT.free(msg);
--- a/serial/usb/USBSerialStream.cpp Wed Oct 24 14:15:53 2012 +0000 +++ b/serial/usb/USBSerialStream.cpp Thu Nov 01 13:01:03 2012 +0000 @@ -17,7 +17,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define __DEBUG__ 0 //Maximum verbosity +#define __DEBUG__ 0 #ifndef __MODULE__ #define __MODULE__ "USBSerialStream.cpp" #endif