Add a bunch of APNs
Fork of C027_Support by
Diff: MDM.cpp
- Revision:
- 81:3966a5c17037
- Parent:
- 80:34985b4d821e
- Child:
- 82:055dcfcf9dcc
diff -r 34985b4d821e -r 3966a5c17037 MDM.cpp --- a/MDM.cpp Tue May 27 08:21:53 2014 +0000 +++ b/MDM.cpp Wed May 28 07:09:38 2014 +0000 @@ -539,13 +539,46 @@ sendFormated("AT+CSS?\r\n"); if (RESP_OK != waitFinalResp()) return false; - // get the Telephone number - sendFormated("AT$MDN?\r\n"); - if (RESP_OK != waitFinalResp(_cbString, _net.num)) - return false; - // check if we have a Mobile Directory Number - if (!*_net.num || (memcmp(_net.num, "000000", 6) == 0)) - return false; + while (1) { + // get the Telephone number + sendFormated("AT$MDN?\r\n"); + if (RESP_OK != waitFinalResp(_cbString, _net.num)) + return false; + // check if we have a Mobile Directory Number + if (*_net.num && (memcmp(_net.num, "000000", 6) != 0)) + break; + + INFO("Device not yet activated\r\n"); + INFO("Make sure you have a valid contract with the network operator for this device.\r\n"); + // Check if the the version contains a V for Verizon + // Verizon: E0.V.xx.00.xxR, + // Sprint E0.S.xx.00.xxR + if (_dev.ver[3] == 'V') { + int i; + INFO("Start device over-the-air activation (this can take a few minutes)\r\n"); + sendFormated("AT+CDV=*22899\r\n"); + i = 1; + if (RESP_OK != waitFinalResp(_cbUACTIND, &i, 120*1000) || (i == 1)) { + ERROR("Device over-the-air activation failed\r\n"); + return false; + } + INFO("Device over-the-air activation successful\r\n"); + + INFO("Start PRL over-the-air update (this can take a few minutes)\r\n"); + sendFormated("AT+CDV=*22891\r\n"); + i = 1; + if (RESP_OK != waitFinalResp(_cbUACTIND, &i, 120*1000) || (i == 1)) { + ERROR("PRL over-the-air update failed\r\n"); + return false; + } + INFO("PRL over-the-air update successful\r\n"); + + } else { + // Sprint or Aeris + INFO("Wait for OMA-DM over-the-air activation (this can take a few minutes)\r\n"); + RELAX_MS(120*1000); + } + } // get the the Network access identifier string char nai[64]; sendFormated("AT$QCMIPNAI?\r\n"); @@ -610,6 +643,15 @@ return WAIT; } +int MDMParser::_cbUACTIND(int type, const char* buf, int len, int* i) +{ + if ((type == TYPE_PLUS) && i){ + if (sscanf(buf, "\r\n+UACTIND: %d", i) == 1) { + } + } + return WAIT; +} + // ---------------------------------------------------------------- // internet connection