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.

Revision:
72:d1e943ad6558
Parent:
71:041de9a6d93c
Child:
73:2b32e0a21df2
--- a/MDM.cpp	Thu May 15 06:16:10 2014 +0000
+++ b/MDM.cpp	Thu May 15 07:06:07 2014 +0000
@@ -467,15 +467,12 @@
             return false;
     } else {
         // check GPRS attach status
-        int state = 0;
         sendFormated("AT+CGATT?\r\n");
-        if (RESP_OK != waitFinalResp(_cbCGATT, &state, 3*60*1000))
-            return false;
-        if (state != 1)
+        if (RESP_OK != waitFinalResp(_cbCGATT, &_net.gprs))
             return false;
         // check operator selection 
         sendFormated("AT+COPS?\r\n");
-        if (RESP_OK != waitFinalResp(_cbCOPS, &_net, 3*60*1000))
+        if (RESP_OK != waitFinalResp(_cbCOPS, &_net))
             return false;
         // Returns the MSISDNs related to this subscriber
         sendFormated("AT+CNUM\r\n");
@@ -492,11 +489,14 @@
     return true;
 }
 
-int MDMParser::_cbCGATT(int type, const char* buf, int len, int* state)
+int MDMParser::_cbCGATT(int type, const char* buf, int len, Gprs* gprs)
 {
-    if ((type == TYPE_PLUS) && state){
-        if (sscanf(buf, "\r\n+CGATT: %d\r\n", state) == 1)
-            /*TRACE("Got CGATT: %d\r\n", state)*/;
+    if ((type == TYPE_PLUS) && gprs){
+        int i;
+        if (sscanf(buf, "\r\n+CGATT: %d\r\n", &i) == 1) {
+            if      (i == 0) *gprs = GPRS_DETACHED;
+            else if (i == 1) *gprs = GPRS_ATTACHED;
+        }
     }
     return WAIT;
 }
@@ -564,8 +564,8 @@
 #endif
     } else { 
         // check gprs attach status 
-        sendFormated("AT+CGATT?\r\n");
-        if (RESP_OK != waitFinalResp())
+        sendFormated("AT+CGATT=1\r\n");
+        if (RESP_OK != waitFinalResp(NULL,NULL,3*60*1000))
             return NOIP;
         
         // Check the profile
@@ -1069,6 +1069,9 @@
     const char* txtReg[] = { "Unknown", "Denied", "None", "Home", "Roaming" };
     if (status->reg < sizeof(txtReg)/sizeof(*txtReg) && (status->reg != MDMParser::REG_UNKNOWN))
         printf("  Registration:       %s\r\n", txtReg[status->reg]);
+    const char* txtGprs[] = { "Unknown", "Detached", "Attached" };
+    if (status->gprs < sizeof(txtGprs)/sizeof(*txtGprs) && (status->gprs != MDMParser::GPRS_UNKNOWN))
+        printf("  Gprs:               %s\r\n", txtGprs[status->gprs]);
     const char* txtAct[] = { "Unknown", "GSM", "Edge", "3G", "CDMA" };
     if (status->act < sizeof(txtAct)/sizeof(*txtAct) && (status->act != MDMParser::ACT_UNKNOWN))
         printf("  Access Technology:  %s\r\n", txtAct[status->act]);