phs fan / AbitModemInterface

Dependencies:   Socket lwip-sys lwip

Fork of AbitUSBModem by phs fan

Revision:
100:dbd92e9515ef
Parent:
98:1b851249d70b
--- a/ip/PPPIPInterface.cpp	Wed Feb 25 14:34:13 2015 +0000
+++ b/ip/PPPIPInterface.cpp	Mon May 11 14:07:07 2015 +0000
@@ -40,7 +40,7 @@
 #define CONNECT_CMD "ATD" MSISDN "\x0D"
 #define EXPECTED_RESP CONNECT_CMD "\x0D" "\x0A" "CONNECT" "\x0D" "\x0A"
 #define EXPECTED_RESP_DATARATE CONNECT_CMD "\x0D" "\x0A" "CONNECT %d" "\x0D" "\x0A"
-#define EXPECTED_RESP_MIN_LEN 30
+#define EXPECTED_RESP_MIN_LEN 32
 #define OK_RESP "\x0D" "\x0A" "OK" "\x0D" "\x0A"
 #define ESCAPE_SEQ "+++"
 #define HANGUP_CMD "ATH" "\x0D"
@@ -109,6 +109,7 @@
     DBG("Trying to connect with PPP");
 
     cleanupLink();
+    Thread::wait(1000);
 
     DBG("Sending %s", CONNECT_CMD);
 
@@ -122,15 +123,17 @@
     Thread::wait(100);
     len = 0;
     size_t readLen;
-    ret = m_pStream->read((uint8_t*)buf + len, &readLen, EXPECTED_RESP_MIN_LEN, DEFAULT_TIMEOUT);
+    ret = m_pStream->read((uint8_t*)buf + len, &readLen, sizeof(buf) - 1, DEFAULT_TIMEOUT);
     if( ret != OK ) {
         return NET_UNKNOWN;
     }
     len += readLen;
     while( (len < EXPECTED_RESP_MIN_LEN) || (buf[len-1] != LF) ) {
-        ret = m_pStream->read((uint8_t*)buf + len, &readLen, 1, DEFAULT_TIMEOUT);
+        Thread::wait(100);
+        ret = m_pStream->read((uint8_t*)buf + len, &readLen, sizeof(buf) - len - 1, DEFAULT_TIMEOUT);
         if( ret != OK ) {
-            return NET_UNKNOWN;
+            break;
+//            return NET_UNKNOWN;
         }
         len += readLen;
     }