Coap
Fork of C027_Support by
Diff: MDM.cpp
- Revision:
- 25:4045d02e44f1
- Parent:
- 24:0e287a85ac9e
- Child:
- 26:07be5faf8925
--- a/MDM.cpp Tue Apr 08 11:15:33 2014 +0000 +++ b/MDM.cpp Tue Apr 08 11:59:28 2014 +0000 @@ -30,9 +30,11 @@ _model = MODEL_UNKNOWN; _sim = SIM_UNKNOWN; _net = NET_UNKNOWN; + _act = ACT_UNKNOWN; _ip = 0; _rssi = 0; *_num = '\0'; + *_opr = '\0'; for (int socket = 0; socket < sizeof(_sockets)/sizeof(*_sockets); socket++) { _sockets[socket].state = SOCK_FREE; _sockets[socket].pending = 0; @@ -114,6 +116,7 @@ else if (a == 2) _net = NET_NONE; // not registered, but MT is currently searching a new operator to register to else if (a == 3) _net = NET_DENIED; // registration denied else if (a == 5) _net = NET_ROAMING; // registered, roaming + _act = ACT_CDMA; // +CSS: <mode>[,<format>,<oper>[,<AcT>]] } else if (sscanf(cmd, "CSS %*c,%2s,%*d",s) == 1) { //_net = (strcmp("Z", s) == 0) ? NET_UNKNOWN : NET_HOME; @@ -134,17 +137,18 @@ else if (a == 4) _net = NET_UNKNOWN; // 4: unknown else if (a == 5) _net = NET_ROAMING; // 5: registered, roaming // access technology - if (b == 0) ; // 0: GSM - else if (b == 1) ; // 1: GSM COMPACT - else if (b == 2) ; // 2: UTRAN - else if (b == 3) ; // 3: GSM with EDGE availability - else if (b == 4) ; // 4: UTRAN with HSDPA availability - else if (b == 5) ; // 5: UTRAN with HSUPA availability - else if (b == 6) ; // 6: UTRAN with HSDPA and HSUPA availability + if (b == 0) _act = ACT_GSM; // 0: GSM + else if (b == 1) _act = ACT_GSM; // 1: GSM COMPACT + else if (b == 2) _act = ACT_UTRAN; // 2: UTRAN + else if (b == 3) _act = ACT_EDGE; // 3: GSM with EDGE availability + else if (b == 4) _act = ACT_UTRAN; // 4: UTRAN with HSDPA availability + else if (b == 5) _act = ACT_UTRAN; // 5: UTRAN with HSUPA availability + else if (b == 6) _act = ACT_UTRAN; // 6: UTRAN with HSDPA and HSUPA availability // +COPS: <mode>[,<format>,<oper>[,<AcT>]] - } else if (sscanf(cmd, "COPS: %*d,%*d,\"%*[^\"]\",%d",&a) == 1) { - // if (a == 0) ; // 0: GSM, - // else if (a == 2) ; // 2: UTRAN + } else if (sscanf(cmd, "COPS: %*d,%*d,\"%[^\"]\",%d",s,&b) >= 1) { + strcpy(_opr,s); + if (a == 0) _act = ACT_GSM; // 0: GSM, + else if (a == 2) _act = ACT_UTRAN; // 2: UTRAN // +CPIN: <code> } else if (sscanf(cmd, "CPIN: %7s",s) == 1) { _sim = (strcmp("READY", s) == 0) ? SIM_READY : SIM_UNKNOWN; @@ -288,7 +292,7 @@ return true; } -bool MDMParser::checkNetStatus(void) +bool MDMParser::checkNetStatus(Status* info /*= NULL*/) { // check registration sendFormated("AT+CREG?\r\n"); @@ -317,10 +321,13 @@ sendFormated("AT+CSQ\r\n"); if (OK != waitFinalResp()) return false; - if (*_num) - TRACE("Phone number: \"%s\"\n", _num); - if (_rssi) - TRACE("Signal Strength: %d dBm\n", _rssi); + if (info) { + info->num = _num; + info->opr = _opr; + info->rssi = _rssi; + info->net = _net; + info->act = _act; + } return true; }