summaryrefslogtreecommitdiff
path: root/src/atcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/atcmd.c')
-rw-r--r--src/atcmd.c84
1 files changed, 82 insertions, 2 deletions
diff --git a/src/atcmd.c b/src/atcmd.c
index 7ec49c7..595a91a 100644
--- a/src/atcmd.c
+++ b/src/atcmd.c
@@ -1243,6 +1243,63 @@ int atcmd_plus_gmm_read(int fd)
return 0;
}
+/* ICCID needed for LNA3 to determine carrier */
+int atcmd_plus_iccid_read(int fd)
+{
+ char buf[ATCMD_LINE_SIZE];
+ char *save;
+ char *token;
+ int tmp;
+
+ atcmd_writeline(fd, "AT#CCID");
+ //Swallow extra "\r\n"
+ tmp = atcmd_readline(fd, buf, sizeof(buf));
+ if (tmp <= 0) {
+ log_debug("expected \\r\\n but it was not received");
+ return -1;
+ }
+
+ //Read iccid string
+ tmp = atcmd_readline(fd, buf, sizeof(buf));
+ if (tmp <= 0) {
+ log_debug("expected ICCID but it was not received");
+ /* Currently only LNA3 models will need the ICCID */
+ return -1;
+ }
+
+ save = buf;
+ log_debug("buf=%s for %d", buf,strlen(buf));
+ token = atcmd_value_tok(&save);
+ if (!token) {
+ log_debug("atcmd_value_tok model");
+ return -1;
+ } else
+ log_debug("token is %s",token);
+ tmp = strrchr(token,' ');
+ if(tmp){
+ token = ++tmp;
+ log_debug("Found blank, incrementing tmp");
+ } else {
+ tmp = strrchr(token,'\t');
+ log_debug("Found tab, incrementing tmp");
+ if(tmp)
+ token = ++tmp;
+ }
+ log_debug("token[0]=%2.2x token[1]=%2.2x",token[0],token[1]);
+ free(Global.core.iccid);
+ Global.core.iccid = strdup(token);
+
+ log_debug("iccid: %s", Global.core.iccid);
+
+ tmp = atcmd_expect_line(fd, buf, sizeof(buf), "OK");
+ if (tmp <= 0) {
+ log_debug("expected OK but it was not received");
+ return -1;
+ }
+
+ return 0;
+}
+
int atcmd_init(int fd, int read_timeout)
{
int tmp;
@@ -1297,6 +1354,12 @@ static int sms_atcmd_init(int fd)
return -1;
}
+ tmp = atcmd_plus_iccid_read(fd);
+ if (tmp < 0) {
+ log_error("failed to read SIM ICCID");
+ return -1;
+ }
+
tmp = atcmd_plus_cmgf_write(fd, SMS_PDU_MODE);
if (tmp < 0) {
return -1;
@@ -1407,10 +1470,27 @@ int sms_device_open(void)
return fd;
}
+is_vzw_lte(void)
+{
+ if (!strcmp(Global.core.model, "LE910-NA1")) {
+ log_debug("Found LE910-NA1");
+ /* Verizon Wireless SIM */
+ if (strncmp(Global.core.iccid,"891480",6) == 0) {
+ log_debug("Found VZW SIM");
+ return 1;
+ }
+ }
+
+ return (!strcmp(Global.core.model, "LE910-SVG"));
+}
+
int isCdmaTypeModel()
{
- return (!strcmp(Global.core.model, "LE910-SVG") ||
- !strcmp(Global.core.model, "DE910-DUAL") ||
+ /* Test for possible dual firmware model */
+ if (is_vzw_lte())
+ return 1;
+
+ return (!strcmp(Global.core.model, "DE910-DUAL") ||
!strcmp(Global.core.model, "CE910-DUAL"));
}