support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.

Dependents:   HTTPClient_Cellular_HelloWorld Cellular_HelloMQTT MbedSmartRestMain Car_Bon_car_module ... more

This library is intended to be used with u-blox products such as the C027 or a shield with u-blox cellular and GPS modules like the cellular and positioning shield from Embedded Artist.

For 2G/GSM and 3G/UMTS you need to:

  • have a SIM card and know its PIN number
  • need to know you network operators APN setting These setting should be passed to the connect or init and join functions. You can also extend the APN database in MDMAPN.h.

For CDMA products you need to make sure that you have provisioned and activated the modem with either Sprint or Verizon.

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Tue May 13 06:14:13 2014 +0000
Parent:
57:869bd35f44cc
Child:
59:382695f1ce85
Commit message:
fix some timeouts

Changed in this revision

MDM.cpp Show annotated file Show diff for this revision Revisions of this file
MDM.h Show annotated file Show diff for this revision Revisions of this file
--- 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));
--- a/MDM.h	Mon May 12 13:58:47 2014 +0000
+++ b/MDM.h	Tue May 13 06:14:13 2014 +0000
@@ -364,11 +364,12 @@
     /** Wait for a final respons
         \param cb the optional callback function
         \param param the optional callback function parameter
-        \param timeout_ms the timeout to wait 
+        \param timeout_ms the timeout to wait (See Estimated command 
+               response time of AT manual)
     */
     int waitFinalResp(_CALLBACKPTR cb = NULL, 
                       void* param = NULL, 
-                      int timeout_ms = 5000);
+                      int timeout_ms = 10000);
 
     /** template version of #waitFinalResp when using callbacks, 
         This template will allow the compiler to do type cheking but 
@@ -379,7 +380,7 @@
     template<class T>
     int waitFinalResp(int (*cb)(int type, const char* buf, int len, 
                       T* param), 
-                      T* param, int timeout_ms = 5000) 
+                      T* param, int timeout_ms = 10000) 
     {
         return waitFinalResp((_CALLBACKPTR)cb, (void*)param, timeout_ms);
     }