summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2019-06-18 17:11:03 +0300
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2019-06-18 17:42:15 +0300
commita1727baa9c57466517e76b635e7c27bf177acda2 (patch)
treef722d6e3e8e8e76fe9ffc74ab3b694d4741be9ba /src
parent2267c8ec1d21b8e0367ecdae2cb11b75553088b7 (diff)
downloadsms-utils-a1727baa9c57466517e76b635e7c27bf177acda2.tar.gz
sms-utils-a1727baa9c57466517e76b635e7c27bf177acda2.tar.bz2
sms-utils-a1727baa9c57466517e76b635e7c27bf177acda2.zip
[MTR-MTQ] Quectel support for sms-utils
- Added new "manufacturer" field to the "global_core" structure - Added the "atcmd_plus_gmi_read()" function to fetch manufacturer identification - Added a call to the "atcmd_plus_gmi_read()" in "sms_atcmd_init()" - Added "is_telit_model()" and "is_quectel_model()" functions to pick a proper manufacturer-specific command in "atcmd_plus_iccid_read()" and, possibly, other commands in the future - Tabs VS spaces. This project uses tabs
Diffstat (limited to 'src')
-rw-r--r--src/atcmd.c71
-rw-r--r--src/atcmd.h4
-rw-r--r--src/global.h5
3 files changed, 77 insertions, 3 deletions
diff --git a/src/atcmd.c b/src/atcmd.c
index 595a91a..9e230c5 100644
--- a/src/atcmd.c
+++ b/src/atcmd.c
@@ -1243,6 +1243,50 @@ int atcmd_plus_gmm_read(int fd)
return 0;
}
+/* Manufacturer identification is needed to pick proper manufacturer-specific commands.
+ * For example, in atcmd_plus_iccid_read() function. */
+int atcmd_plus_gmi_read(int fd)
+{
+ char buf[ATCMD_LINE_SIZE];
+ char *save;
+ char *token;
+ int tmp;
+
+ atcmd_writeline(fd, "AT+GMI");
+ //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 manufacturer string
+ tmp = atcmd_readline(fd, buf, sizeof(buf));
+ if (tmp <= 0) {
+ log_debug("expected manufacturer but it was not received");
+ return -1;
+ }
+
+ save = buf;
+ token = atcmd_value_tok(&save);
+ if (!token) {
+ log_debug("atcmd_value_tok manufacturer");
+ return -1;
+ }
+ free(Global.core.manufacturer);
+ Global.core.manufacturer = strdup(token);
+
+ log_debug("manufacturer: %s", Global.core.manufacturer);
+
+ 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;
+}
+
/* ICCID needed for LNA3 to determine carrier */
int atcmd_plus_iccid_read(int fd)
{
@@ -1348,12 +1392,18 @@ static int sms_atcmd_init(int fd)
return -1;
}
- tmp = atcmd_plus_gmm_read(fd);
+ tmp = atcmd_plus_gmm_read(fd);
if (tmp < 0) {
log_error("failed to read radio model");
return -1;
}
+ tmp = atcmd_plus_gmi_read(fd);
+ if (tmp < 0) {
+ log_error("failed to read radio manufacturer");
+ return -1;
+ }
+
tmp = atcmd_plus_iccid_read(fd);
if (tmp < 0) {
log_error("failed to read SIM ICCID");
@@ -1494,3 +1544,22 @@ int isCdmaTypeModel()
!strcmp(Global.core.model, "CE910-DUAL"));
}
+int is_telit_model()
+{
+ if (!strcmp(Global.core.manufacturer, "Telit")) {
+ log_debug("Found Telit model");
+ return 1;
+ }
+
+ return 0;
+}
+
+int is_quectel_model()
+{
+ if (!strcmp(Global.core.manufacturer, "Quectel")) {
+ log_debug("Found Quectel model");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/atcmd.h b/src/atcmd.h
index c13866e..dc3d5d9 100644
--- a/src/atcmd.h
+++ b/src/atcmd.h
@@ -3,6 +3,7 @@
#include <termios.h>
#include <stdarg.h>
+#include <stddef.h>
#ifdef __ATCMD_C
#define ATCMD_EXTERN
@@ -113,11 +114,14 @@ int atcmd_plus_cpbs_write(int fd, const char *name);
int atcmd_plus_cpbr_test(int fd, struct phonebook_store *store);
int atcmd_plus_gmm_read(int fd);
+int atcmd_plus_gmi_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);
+int is_telit_model(void);
+int is_quectel_model(void);
#if __ATCMD_C
const char *abort_dfl[] = {
diff --git a/src/global.h b/src/global.h
index fc8df6f..764cc06 100644
--- a/src/global.h
+++ b/src/global.h
@@ -29,8 +29,9 @@ struct global_core {
char *msg_store_send;
char *msg_store_new;
char *pb_store;
- char *model;
- char *iccid; /* Needed for LNA3/Verizon */
+ char *model;
+ char *iccid; /* Needed for LNA3/Verizon */
+ char *manufacturer; /* Needed to pick proper manufacturer-specific commands */
char *editor;
char *edit_file;