summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-08-10 13:08:26 -0500
committerJohn Klug <john.klug@multitech.com>2018-08-10 13:08:26 -0500
commit2267c8ec1d21b8e0367ecdae2cb11b75553088b7 (patch)
tree69809e672aaf569ffac975899b4ecbbb2048b9dc
parent5a1e0b6b0f1a79eb1741236470734821c4480d59 (diff)
downloadsms-utils-2267c8ec1d21b8e0367ecdae2cb11b75553088b7.tar.gz
sms-utils-2267c8ec1d21b8e0367ecdae2cb11b75553088b7.tar.bz2
sms-utils-2267c8ec1d21b8e0367ecdae2cb11b75553088b7.zip
Allow LNA3 to send messages.1.0.5
-rw-r--r--configure.in2
-rw-r--r--src/atcmd.c84
-rw-r--r--src/atcmd.h1
-rw-r--r--src/global.h1
-rw-r--r--src/pdu_decode.c6
-rw-r--r--src/sms_send.c10
6 files changed, 93 insertions, 11 deletions
diff --git a/configure.in b/configure.in
index accba59..b42224e 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
AC_INIT([src/sms_main.c])
-AM_INIT_AUTOMAKE([sms-utils], [1.0.2])
+AM_INIT_AUTOMAKE([sms-utils], [1.0.5])
AM_CONFIG_HEADER([config.h])
AC_PROG_CC
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"));
}
diff --git a/src/atcmd.h b/src/atcmd.h
index 16b991f..c13866e 100644
--- a/src/atcmd.h
+++ b/src/atcmd.h
@@ -117,6 +117,7 @@ int atcmd_plus_gmm_read(int fd);
int atcmd_init(int fd, int read_timeout);
int sms_device_close(int fd);
int sms_device_open(void);
+int is_vzw_lte(void);
#if __ATCMD_C
const char *abort_dfl[] = {
diff --git a/src/global.h b/src/global.h
index 4248c64..fc8df6f 100644
--- a/src/global.h
+++ b/src/global.h
@@ -30,6 +30,7 @@ struct global_core {
char *msg_store_new;
char *pb_store;
char *model;
+ char *iccid; /* Needed for LNA3/Verizon */
char *editor;
char *edit_file;
diff --git a/src/pdu_decode.c b/src/pdu_decode.c
index 5d74a2a..62b60ba 100644
--- a/src/pdu_decode.c
+++ b/src/pdu_decode.c
@@ -237,9 +237,9 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
// CDMA 7-BIT ENCODING
} else if (pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT) {
- if (!strcmp(Global.core.model, "LE910-SVG")) {
+ if (is_vzw_lte()) {
// LE910-SVG stores data length as # of septets
- log_debug("counting PDU length byte as number of septets (LE910-SVG)");
+ log_debug("counting PDU length byte as number of septets (LE910-SVG/LE910-NA1/VZW)");
*nr_octets = octets_from_septets(pdu->user_data_len);
}
else {
@@ -336,7 +336,7 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
}
//Remove padded byte for data length of 7 characters if not LE910-SVG
- if (strcmp(Global.core.model, "LE910-SVG") && (pdu->user_data[i-1] == 0)) {
+ if (!is_vzw_lte() && (pdu->user_data[i-1] == 0)) {
log_debug("Removing padded char");
i--;
pdu->user_data_len--;
diff --git a/src/sms_send.c b/src/sms_send.c
index 3933786..bc98cb4 100644
--- a/src/sms_send.c
+++ b/src/sms_send.c
@@ -225,11 +225,11 @@ static int do_send(int fd, struct send_options *options, int argc, char **argv)
}
//LE910-SVG SMS SEND WORKAROUND
- if (!strcmp(Global.core.model, "LE910-SVG")) {
- log_info("setting text mode for LE910-SVG");
+ if (is_vzw_lte()) {
+ log_info("setting text mode for Verizon LTE");
tmp = atcmd_plus_cmgf_write(fd, SMS_TEXT_MODE);
if (tmp < 0) {
- log_error("failed to set text mode for sending with LE910-SVG");
+ log_error("failed to set text mode for sending with Verizon LTE.");
return false;
}
}
@@ -253,7 +253,7 @@ static int do_send(int fd, struct send_options *options, int argc, char **argv)
}
//LE910-SVG SMS SEND WORKAROUND
- if (!strcmp(Global.core.model, "LE910-SVG")) {
+ if (is_vzw_lte()) {
mem_index = atcmd_plus_cmgw_write_text(fd, NULL, SMS_ADDR_UNSPEC, NULL, pdu.user_data, pdu.user_data_len);
}
else {
@@ -313,7 +313,7 @@ static int do_send(int fd, struct send_options *options, int argc, char **argv)
}
//LE910-SVG SMS SEND WORKAROUND
- if (!strcmp(Global.core.model, "LE910-SVG")) {
+ if (is_vzw_lte()) {
tmp = atcmd_plus_cmgs_write_text(fd, pdu.addr.addr, pdu.user_data, pdu.user_data_len);
}
else {