* add C027_Support fork
Fork of C027_Support by
Diff: MDM.cpp
- Revision:
- 123:66cef6353b13
- Parent:
- 122:5f6804915d77
- Child:
- 124:65eb7d58f2da
diff -r 5f6804915d77 -r 66cef6353b13 MDM.cpp --- a/MDM.cpp Thu Mar 12 17:29:29 2015 +0000 +++ b/MDM.cpp Thu Aug 20 07:53:34 2015 +0000 @@ -218,7 +218,8 @@ r = sscanf(cmd, "%s %d,\"%X\",\"%X\",%d",s,&a,&b,&c,&d); if (r >= 2) { Reg *reg = !strcmp(s, "CREG:") ? &_net.csd : - !strcmp(s, "CGREG:") ? &_net.psd : NULL; + !strcmp(s, "CGREG:") ? &_net.psd : + !strcmp(s, "CEREG:") ? &_net.eps : NULL; if (reg) { // network status if (a == 0) *reg = REG_NONE; // 0: not registered, home network @@ -227,6 +228,7 @@ else if (a == 3) *reg = REG_DENIED; // 3: registration denied else if (a == 4) *reg = REG_UNKNOWN; // 4: unknown else if (a == 5) *reg = REG_ROAMING; // 5: registered, roaming + else if (a == 6) *reg = REG_HOME; // 6: registered, sms only, home if ((r >= 3) && (b != 0xFFFF)) _net.lac = b; // location area code if ((r >= 4) && (c != 0xFFFFFFFF)) _net.ci = c; // cell ID // access technology @@ -238,6 +240,7 @@ else if (d == 4) _net.act = ACT_UTRAN; // 4: UTRAN with HSDPA availability else if (d == 5) _net.act = ACT_UTRAN; // 5: UTRAN with HSUPA availability else if (d == 6) _net.act = ACT_UTRAN; // 6: UTRAN with HSDPA and HSUPA availability + else if (d == 7) _net.act = ACT_LTE; // 7: LTE } } } @@ -404,6 +407,12 @@ sendFormated("AT+UGPIOC=16,2\r\n"); if (RESP_OK != waitFinalResp()) goto failure; + } else if ((_dev.dev == DEV_TOBY_L200) || (_dev.dev == DEV_TOBY_L201) || + (_dev.dev == DEV_TOBY_L210)) { + // enable the network identification feature + //sendFormated("AT+UGPIOC=20,2\r\n"); + //if (RESP_OK != waitFinalResp()) + // goto failure; } // check the sim card for (int i = 0; (i < 5) && (_dev.sim != SIM_READY); i++) { @@ -514,6 +523,9 @@ else if (strstr(buf, "SARA-U260")) *dev = DEV_SARA_U260; else if (strstr(buf, "SARA-U270")) *dev = DEV_SARA_U270; else if (strstr(buf, "LEON-G200")) *dev = DEV_LEON_G200; + else if (strstr(buf, "TOBY-L200") || strstr(buf, "MPCI-L200")) *dev = DEV_TOBY_L200; + else if (strstr(buf, "TOBY-L201") || strstr(buf, "MPCI-L201")) *dev = DEV_TOBY_L201; + else if (strstr(buf, "TOBY-L210") || strstr(buf, "MPCI-L210")) *dev = DEV_TOBY_L210; } return WAIT; } @@ -551,7 +563,8 @@ wait_ms(1000); if (_net.csd == REG_DENIED) ERROR("CSD Registration Denied\r\n"); if (_net.psd == REG_DENIED) ERROR("PSD Registration Denied\r\n"); - return REG_OK(_net.csd) || REG_OK(_net.psd); + if (_net.eps == REG_DENIED) ERROR("EPS Registration Denied\r\n"); + return REG_OK(_net.csd) || REG_OK(_net.psd) || REG_OK(_net.eps); } bool MDMParser::checkNetStatus(NetStatus* status /*= NULL*/) @@ -569,7 +582,13 @@ sendFormated("AT+CGREG?\r\n"); waitFinalResp(); // don't fail as service could be not subscribed } - if (REG_OK(_net.csd) || REG_OK(_net.psd)) + if ((_dev.dev == DEV_TOBY_L201) || (_dev.dev == DEV_TOBY_L210)|| + (_dev.dev == DEV_TOBY_L201)) { + // check EPS network registration + sendFormated("AT+CEREG?\r\n"); + waitFinalResp(); // don't fail as service could be not subscribed + } + if (REG_OK(_net.csd) || REG_OK(_net.psd) || REG_OK(_net.eps)) { // check modem specific status messages if (_dev.dev == DEV_LISA_C200) { @@ -638,7 +657,8 @@ if (status) { memcpy(status, &_net, sizeof(NetStatus)); } - ok = REG_DONE(_net.csd) && REG_DONE(_net.psd); + ok = REG_DONE(_net.csd) && + (REG_DONE(_net.psd) || REG_DONE(_net.eps)); UNLOCK(); return ok; failure: @@ -646,6 +666,17 @@ return false; } +int MDMParser::_cbUACTIND(int type, const char* buf, int len, int* i) +{ + if ((type == TYPE_PLUS) && i){ + int a; + if (sscanf(buf, "\r\n+UACTIND: %d", &a) == 1) { + *i = a; + } + } + return WAIT; +} + int MDMParser::_cbCOPS(int type, const char* buf, int len, NetStatus* status) { if ((type == TYPE_PLUS) && status){ @@ -654,6 +685,7 @@ if (sscanf(buf, "\r\n+COPS: %*d,%*d,\"%[^\"]\",%d",status->opr,&act) >= 1) { if (act == 0) status->act = ACT_GSM; // 0: GSM, else if (act == 2) status->act = ACT_UTRAN; // 2: UTRAN + else if (act == 7) status->act = ACT_LTE; // 2: UTRAN } } return WAIT; @@ -684,17 +716,6 @@ return WAIT; } -int MDMParser::_cbUACTIND(int type, const char* buf, int len, int* i) -{ - if ((type == TYPE_PLUS) && i){ - int a; - if (sscanf(buf, "\r\n+UACTIND: %d", &a) == 1) { - *i = a; - } - } - return WAIT; -} - // ---------------------------------------------------------------- // internet connection @@ -1391,20 +1412,21 @@ bool MDMParser::setDebug(int level) { #ifdef MDM_DEBUG - if ((_debugLevel >= -1) && (level >= -1) && - (_debugLevel <= 3) && (level <= 3)) { - _debugLevel = level; - return true; - } + _debugLevel = (level < -1) ? -1 : + (level > 3) ? 3 : + level; #endif - return false; + return _debugLevel == level; } void MDMParser::dumpDevStatus(MDMParser::DevStatus* status, _DPRINT dprint, void* param) { dprint(param, "Modem::devStatus\r\n"); - const char* txtDev[] = { "Unknown", "SARA-G350", "LISA-U200", "LISA-C200", "SARA-U260", "SARA-U270", "LEON-G200" }; + const char* txtDev[] = { "Unknown", + "SARA-G350", "LISA-U200", "LISA-C200", + "SARA-U260", "SARA-U270", "LEON-G200", + "TOBY-L200", "TOBY-L201", "TOBY-L210" }; if (status->dev < sizeof(txtDev)/sizeof(*txtDev) && (status->dev != DEV_UNKNOWN)) dprint(param, " Device: %s\r\n", txtDev[status->dev]); const char* txtLpm[] = { "Disabled", "Enabled", "Active" }; @@ -1438,7 +1460,9 @@ dprint(param, " CSD Registration: %s\r\n", txtReg[status->csd]); if (status->psd < sizeof(txtReg)/sizeof(*txtReg) && (status->psd != REG_UNKNOWN)) dprint(param, " PSD Registration: %s\r\n", txtReg[status->psd]); - const char* txtAct[] = { "Unknown", "GSM", "Edge", "3G", "CDMA" }; + if (status->eps < sizeof(txtReg)/sizeof(*txtReg) && (status->eps != REG_UNKNOWN)) + dprint(param, " EPS Registration: %s\r\n", txtReg[status->eps]); + const char* txtAct[] = { "Unknown", "GSM", "Edge", "3G", "CDMA", "LTE" }; if (status->act < sizeof(txtAct)/sizeof(*txtAct) && (status->act != ACT_UNKNOWN)) dprint(param, " Access Technology: %s\r\n", txtAct[status->act]); if (status->rssi)