C027 support

Fork of C027_Support by u-blox

Revision:
58:e38a2e942fbb
Parent:
57:869bd35f44cc
Child:
59:382695f1ce85
--- a/MDM.cpp	Mon May 12 13:58:47 2014 +0000
+++ b/MDM.cpp	Tue May 13 06:14:13 2014 +0000
@@ -21,6 +21,9 @@
         else                 printf("\\x%02x", ch);
     }
 }
+
+Timer dbgTime; 
+
  #if 1 // colored terminal output using ANSI escape sequences
   #define COL(c,t) "\33[" c t "\33[" "39m"
  #else
@@ -47,11 +50,15 @@
     _net.ci = 0xFFFFFFFF;
     _ip        = NOIP;
     memset(_sockets, 0, sizeof(_sockets));
+#ifdef DEBUG
+    dbgTime.start();    
+#endif
 }
 
 int MDMParser::send(const char* buf, int len)
 {
 #ifdef DEBUG
+    printf("%10.3f ", dbgTime.read_ms()*0.001);
     printf("AT send    %4d \"", len);
     dump(buf,len);
     printf("\"\r\n");
@@ -89,6 +96,7 @@
                             (type == TYPE_PLUS)   ? CYA(" + ") : 
                             (type == TYPE_PROMPT) ? BLU(" > ") : 
                                                         "..."  ;
+            printf("%10.3f ", dbgTime.read_ms()*0.001);
             printf("AT read %s %3d \"", s, len);
             dump(buf, len);
             printf("\"\r\n");
@@ -454,13 +462,13 @@
         // check GPRS attach status
         int state = 0;
         sendFormated("AT+CGATT?\r\n");
-        if (RESP_OK != waitFinalResp(_cbCGATT, &state))
+        if (RESP_OK != waitFinalResp(_cbCGATT, &state, 3*60*1000))
             return false;
         if (state != 1)
             return false;
         // check operator selection 
         sendFormated("AT+COPS?\r\n");
-        if (RESP_OK != waitFinalResp(_cbCOPS, &_net))
+        if (RESP_OK != waitFinalResp(_cbCOPS, &_net, 3*60*1000))
             return false;
         // Returns the MSISDNs related to this subscriber
         sendFormated("AT+CNUM\r\n");
@@ -558,7 +566,7 @@
         if (a == 1) {
             // disconnect the profile already if it is connected 
             sendFormated("AT+UPSDA=" PROFILE ",4\r\n");
-            if (RESP_OK != waitFinalResp())
+            if (RESP_OK != waitFinalResp(NULL,NULL,40*1000))
                 return NOIP;;
         }
         // Set up the APN
@@ -583,7 +591,7 @@
             return NOIP;
         // Activate the profile and make connection
         sendFormated("AT+UPSDA=" PROFILE ",3\r\n");
-        if (RESP_OK != waitFinalResp())
+        if (RESP_OK != waitFinalResp(NULL,NULL,150*1000))
             return NOIP;
         //Get local IP address
         sendFormated("AT+UPSND=" PROFILE ",0\r\n");
@@ -841,6 +849,7 @@
             len = 0; // no more data and socket closed or timed-out
         }
     }
+    
     timer.stop();
     timer.reset();
     return cnt;
@@ -931,7 +940,7 @@
 bool MDMParser::smsSend(const char* num, const char* buf)
 {
     sendFormated("AT+CMGS=\"%s\"\r",num);
-    if (RESP_PROMPT != waitFinalResp()) {
+    if (RESP_PROMPT != waitFinalResp(NULL,NULL,150*1000)) {
         return false;
     }
     send(buf, strlen(buf));