Own fork of C027_Support

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of C027_Support by u-blox

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Thu May 15 07:06:07 2014 +0000
Parent:
71:041de9a6d93c
Child:
73:2b32e0a21df2
Commit message:
save gprs attach status

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	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]);
--- a/MDM.h	Thu May 15 06:16:10 2014 +0000
+++ b/MDM.h	Thu May 15 07:06:07 2014 +0000
@@ -51,9 +51,12 @@
     typedef enum { REG_UNKNOWN, REG_DENIED, REG_NONE, REG_HOME, REG_ROAMING } Reg; 
     //! Access Technology
     typedef enum { ACT_UNKNOWN, ACT_GSM, ACT_EDGE, ACT_UTRAN, ACT_CDMA } AcT; 
+    //! Gprs Attach Status
+    typedef enum { GPRS_UNKNOWN, GPRS_DETACHED, GPRS_ATTACHED } Gprs; 
     //! Network Status
     typedef struct { 
         Reg reg;        //!< Registration Status
+        Gprs gprs;      //!< Gprs Attach status
         AcT act;        //!< Access Technology
         int rssi;       //!< Received Signal Strength Indication (in dBm, range -113..-53)
         int ber;        //!< Bit Error Rate (BER), see 3GPP TS 45.008 [20] subclause 8.2.4
@@ -438,7 +441,7 @@
     static int _cbCSQ(int type, const char* buf, int len, NetStatus* status);
     static int _cbCOPS(int type, const char* buf, int len, NetStatus* status);
     static int _cbCNUM(int type, const char* buf, int len, char* num);
-    static int _cbCGATT(int type, const char* buf, int len, int* state);
+    static int _cbCGATT(int type, const char* buf, int len, Gprs* gprs);
     // sockets
     static int _cbCMIP(int type, const char* buf, int len, IP* ip);
     static int _cbUPSND(int type, const char* buf, int len, int* act);