Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of VodafoneUSBModem by
Diff: ip/PPPIPInterface.cpp
- Revision:
- 9:3f077dde13c9
- Parent:
- 8:04b6a042595f
- Child:
- 11:565b2ec40dea
--- a/ip/PPPIPInterface.cpp Tue Jun 26 13:44:59 2012 +0000 +++ b/ip/PPPIPInterface.cpp Wed Jul 11 12:44:33 2012 +0000 @@ -67,9 +67,45 @@ return OK; } -/*virtual*/ int PPPIPInterface::connect() +/*virtual*/ int PPPIPInterface::connect(const char* msisdn) { + int ret; + char buf[32]; + size_t len; DBG("Trying to connect with PPP"); + + do //Clear buf + { + ret = m_pStream->read(buf, &len, 32, 0) > 0 + } while( (ret == OK) && (len > 0) ); + + sprintf(buf, "ATD %16s\x0D"); + + ret = m_pStream->write(buf, strlen(buf), osWaitForever); + if( ret != OK ) + { + return NET_UNKNOWN; + } + + const char expected = "\x0D\0x0ACONNECT\x0D\0x0A"; + + ret = m_pStream->read(buf, strlen(expected), &len, 3000); + if( ret != OK ) + { + return NET_UNKNOWN; + } + + if( (len < strlen(expected)) || (memcmp(expected, buf) != 0) ) + { + //Discard buffer + do //Clear buf + { + ret = m_pStream->read(buf, &len, 32, 0) > 0 + } while( (ret == OK) && (len > 0) ); + return NET_CONN; + } + + DBG("Transport link open"); m_linkStatusSphre.wait(0); if((m_pppd != -1) && (m_pppErrCode == 0)) //Already connected {