Add a bunch of APNs
Fork of C027_Support by
Diff: MDM.cpp
- Revision:
- 32:8f12ac182bbb
- Parent:
- 31:a0bed6c1e05d
- Child:
- 33:fb8fb5021b09
diff -r a0bed6c1e05d -r 8f12ac182bbb MDM.cpp --- a/MDM.cpp Wed Apr 09 11:48:04 2014 +0000 +++ b/MDM.cpp Wed Apr 09 13:03:48 2014 +0000 @@ -121,7 +121,7 @@ TRACE("Socket %d: closed by remote host\r\n", a); _sockets[a].state = SOCK_CREATED/*=CLOSED*/; } - if (_dev.model == MODEL_LISA_C200) { + if (_dev.dev == DEV_LISA_C200) { // CDMA Specific ------------------------------------------- // +CREG: <n><SID>,<NID>,<stat> if (sscanf(cmd, "CREG: %*d,%*d,%*d,%d",&a) == 1) { @@ -220,16 +220,28 @@ wait_ms(40); // identify the module sendFormated("ATI\r\n"); - if (OK != waitFinalResp(_cbATI, &_dev.model)) + if (OK != waitFinalResp(_cbATI, &_dev.dev)) return false; - if (_dev.model == MODEL_UNKNOWN) + if (_dev.dev == DEV_UNKNOWN) return false; - // model specific init - if (_dev.model == MODEL_LISA_C200) { + // device specific init + if (_dev.dev == DEV_LISA_C200) { // disable flow control sendFormated("AT+IFC=0,0\r\n"); if (OK != waitFinalResp()) return false; + // get the manufacturer + sendFormated("AT+GMI\r\n"); + if (OK != waitFinalResp(_cbString, _dev.manu)) + return false; + // get the model identification + sendFormated("AT+GMM\r\n"); + if (OK != waitFinalResp(_cbString, _dev.model)) + return false; + // get the sw version + sendFormated("AT+GMR\r\n"); + if (OK != waitFinalResp(_cbString, _dev.ver)) + return false; // Return the pseudo ESN or MEID sendFormated("AT+GSN\r\n"); if (OK != waitFinalResp(_cbString, _dev.imei)) @@ -244,7 +256,7 @@ if (OK != waitFinalResp()) return false; // enable the network identification feature - if (_dev.model == MODEL_LISA_U200) { + if (_dev.dev == DEV_LISA_U200) { sendFormated("AT+UGPIOC=20,2\r\n"); if (OK != waitFinalResp()) return false; @@ -273,6 +285,18 @@ } if (_dev.sim != SIM_READY) return false; + // get the manufacturer + sendFormated("AT+CGMI\r\n"); + if (OK != waitFinalResp(_cbString, _dev.manu)) + return false; + // get the model identification + sendFormated("AT+CGMM\r\n"); + if (OK != waitFinalResp(_cbString, _dev.model)) + return false; + // get the + sendFormated("AT+CGMR\r\n"); + if (OK != waitFinalResp(_cbString, _dev.ver)) + return false; // Returns the ICCID (Integrated Circuit Card ID) of the SIM-card. // ICCID is a serial number identifying the SIM. sendFormated("AT+CCID\r\n"); @@ -305,18 +329,18 @@ return true; } -int MDMParser::_cbATI(int type, const char* buf, int len, Model* model) +int MDMParser::_cbATI(int type, const char* buf, int len, Dev* dev) { - if ((type == TYPE_UNKNOWN) && model) { + if ((type == TYPE_UNKNOWN) && dev) { if (strstr(buf, "SARA-G350")) { - *model = MODEL_SARA_G350; - /*TRACE("Identified Model: SARA-G350 2G\\n")*/; + *dev = DEV_SARA_G350; + /*TRACE("Identified Device: SARA-G350 2G\\n")*/; } else if (strstr(buf, "LISA-U200")) { - *model = MODEL_LISA_U200; - /*TRACE("Identified Model: LISA-U200 2G/3G\r\n")*/; + *dev = DEV_LISA_U200; + /*TRACE("Identified Device: LISA-U200 2G/3G\r\n")*/; } else if (strstr(buf, "LISA-C200")) { - *model= MODEL_LISA_C200; - /*TRACE("Identified Model: LISA-C200 CDMA\r\n")*/; + *dev= DEV_LISA_C200; + /*TRACE("Identified Device: LISA-C200 CDMA\r\n")*/; } } return WAIT; @@ -351,10 +375,22 @@ if ((_net.reg != REG_ROAMING) && (_net.reg != REG_HOME)) return false; // check modem specific status messages - if (_dev.model == MODEL_LISA_C200) { + if (_dev.dev == DEV_LISA_C200) { sendFormated("AT+CSS?\r\n"); if (OK != waitFinalResp()) return false; + // get the Telephone number + sendFormated("AT$MDN?\r\n"); + if (OK != waitFinalResp(_cbString, _net.num)) + return false; + // check if we have a Mobile Directory Number + if (memcmp(_net.num, "0000", 4) == 0); + return false; + // get the the Network access identifier string + char nai[64]; + sendFormated("AT$QCMIPNAI?\r\n"); + if (OK != waitFinalResp(_cbString, nai)) + return false; } else { // check GPRS attach status int state = 0; @@ -440,20 +476,14 @@ MDMParser::IP MDMParser::join(const char* apn /*= NULL*/, const char* user /*= NULL*/, const char* password /*= NULL*/) { - IP ip = NOIP; - if (_dev.model == MODEL_LISA_C200) { -#ifdef TODO // TODO implement - // enable the - sendFormated("AT$QCMIPEP=1\r\n"); - if (OK != waitFinalResp()) - return NOIP; + _ip = NOIP; + if (_dev.dev == DEV_LISA_C200) { + // TODO: is there something to do here? + //Get local IP address sendFormated("AT+CMIP?\r\n"); - // extract: +CMIP: xxx.xxx.xxx.xxx - if (OK != waitFinalResp()) + if (OK != waitFinalResp(_cbCMIP, &_ip)) return NOIP; - -#endif } else { // check gprs attach status sendFormated("AT+CGATT?\r\n"); @@ -497,12 +527,22 @@ return NOIP; //Get local IP address sendFormated("AT+UPSND=" PROFILE ",0\r\n"); - if (OK != waitFinalResp(_cbUPSND, &ip)) + if (OK != waitFinalResp(_cbUPSND, &_ip)) return NOIP; } - return ip; + return _ip; } +int MDMParser::_cbCMIP(int type, const char* buf, int len, IP* ip) +{ + if ((type == TYPE_PLUS) && ip) { + int a,b,c,d; + if (sscanf(buf, "\r\n+CMIP: " IPSTR, &a,&b,&c,&d) == 4) + *ip = IPADR(a,b,c,d); + } + return WAIT; +} + int MDMParser::_cbUPSND(int type, const char* buf, int len, int* act) { if ((type == TYPE_PLUS) && act) { @@ -537,15 +577,13 @@ { if (_ip == NOIP) return true; - if (_dev.model == MODEL_LISA_C200) { -#ifdef TODO // TODO implement - sendFormated("AT$QCMIPEP=0\r\n"); -#endif + if (_dev.dev == DEV_LISA_C200) { + // TODO: is there something to do here? } else { sendFormated("AT+UPSDA=" PROFILE ",4\r\n"); + if (OK != waitFinalResp()) + return false; } - if (OK != waitFinalResp()) - return false; _ip = NOIP; return true; }