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 51:54ca82a7644c, committed 2012-09-27
- Comitter:
- donatien
- Date:
- Thu Sep 27 14:48:19 2012 +0000
- Parent:
- 50:8ad4cb12749d
- Child:
- 52:bd474c9fe51e
- Child:
- 72:fa234ae33eb6
- Commit message:
- Fixes in ATCommandInterface.cpp
Changed in this revision
at/ATCommandsInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
link/LinkMonitor.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/at/ATCommandsInterface.cpp Thu Sep 27 13:11:44 2012 +0000 +++ b/at/ATCommandsInterface.cpp Thu Sep 27 14:48:19 2012 +0000 @@ -387,10 +387,21 @@ } } //Process line - processReadLine(); - //Shift remaining data to beginning of buffer - memmove(m_inputBuf, m_inputBuf + crPos + lfOff + 1, (m_inputPos + 1) - (crPos + lfOff + 1)); //Move null-terminating char as well - m_inputPos = m_inputPos - (crPos + lfOff + 1); //Adjust m_inputPos + int ret = processReadLine(); + if(ret) + { + m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer + lineDetected = false; + return ret; + } + + //If sendData has been called, all incoming data has been discarded + if(m_inputPos > 0) + { + memmove(m_inputBuf, m_inputBuf + crPos + lfOff + 1, (m_inputPos + 1) - (crPos + lfOff + 1)); //Move null-terminating char as well + m_inputPos = m_inputPos - (crPos + lfOff + 1); //Adjust m_inputPos + } DBG("One line was successfully processed"); lineProcessed = true; //Line was processed with success lineDetected = false; //Search now for a new line @@ -442,6 +453,7 @@ if(ret) { m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer lineDetected = false; return ret; } @@ -490,6 +502,7 @@ if(ret) { m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer lineDetected = false; return ret; } @@ -515,6 +528,7 @@ { //Discard everything m_inputPos = 0; + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer WARN("Incoming buffer is too short to process incoming line"); //Look for a new line lineDetected = false; @@ -721,13 +735,17 @@ if(ret) { WARN("Could not read from stream (returned %d)", ret); + m_inputPos = 0; //Reset input buffer state + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer return ret; - }; + } if( memcmp(m_inputBuf, data + dataPos, readLen) != 0 ) { //Echo does not match output WARN("Echo does not match output"); + m_inputPos = 0; //Reset input buffer state + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer return NET_DIFF; } @@ -739,6 +757,7 @@ DBG("String sent successfully"); m_inputPos = 0; //Reset input buffer state + m_inputBuf[0] = '\0'; //Always have a null-terminating char at start of buffer return OK; }
--- a/link/LinkMonitor.cpp Thu Sep 27 13:11:44 2012 +0000 +++ b/link/LinkMonitor.cpp Thu Sep 27 14:48:19 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__ 4 +#define __DEBUG__ 0 #ifndef __MODULE__ #define __MODULE__ "LinkMonitor.cpp" #endif @@ -41,9 +41,8 @@ // we need to make sure that we setup the operator selection to be in 'numeric' format. // i.e. it is made up of a network and country code when returned by the modem e.g. Operator = 23415. This allows easy logic parsing for // setting up other network parameters in future. - DBG("LinkMonitor::init() being called. This should only happen once: executinging AT+COPS=0,2"); - int ret = m_pIf->execute("AT+COPS=0,2", this, NULL, DEFAULT_TIMEOUT); //Configure to set the operator string to Country Code and mobile network code + int ret = m_pIf->executeSimple("AT+COPS=0,2", NULL, DEFAULT_TIMEOUT); //Configure to set the operator string to Country Code and mobile network code if(ret != OK) { WARN(" NET_PROTOCOL error from sending the AT+COPS command to the modem. "); @@ -137,7 +136,7 @@ m_rssi = 0; m_registrationState = REGISTRATION_STATE_UNKNOWN; m_bearer = BEARER_UNKNOWN; - int ret = m_pIf->execute("AT+CREG=0;+CREG?;+COPS?;+CSQ", this, NULL, DEFAULT_TIMEOUT); //Configure to get registration info & get it; get signal quality + int ret = m_pIf->execute("AT+CREG?;+COPS?;+CSQ", this, NULL, DEFAULT_TIMEOUT); //Configure to get registration info & get it; get signal quality if(ret != OK) { return NET_PROTOCOL;