final 1
Fork of C027_Support by
Diff: MDM.cpp
- Revision:
- 72:d1e943ad6558
- Parent:
- 71:041de9a6d93c
- Child:
- 73:2b32e0a21df2
diff -r 041de9a6d93c -r d1e943ad6558 MDM.cpp --- 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]);