summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gsmd/usock.c72
-rw-r--r--src/libgsmd/libgsmd_phone.c20
-rw-r--r--src/util/shell.c36
3 files changed, 126 insertions, 2 deletions
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 426fa68..c371c17 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -613,6 +613,58 @@ static int phone_powerdown_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, sizeof(ret), &ret);
}
+static int gsmd_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+
+ DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp);
+ if (strncmp(resp, "+CGMI: ", 7))
+ return -EINVAL;
+ resp += 7;
+ return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_MANUF,
+ cmd->id, strlen(resp) + 1, resp);
+ return 0;
+}
+
+static int gsmd_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+
+ DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp);
+ if (strncmp(resp, "+CGMM: ", 7))
+ return -EINVAL;
+ resp += 7;
+ return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_MODEL,
+ cmd->id, strlen(resp) + 1, resp);
+ return 0;
+}
+
+static int gsmd_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+
+ DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp);
+ if (strncmp(resp, "+CGMR: ", 7))
+ return -EINVAL;
+ resp += 7;
+ return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_REVISION,
+ cmd->id, strlen(resp) + 1, resp);
+ return 0;
+}
+
+static int gsmd_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+
+ DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp);
+ if (strncmp(resp, "+CGSN: ", 7))
+ return -EINVAL;
+ resp += 7;
+ return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_SERIAL,
+ cmd->id, strlen(resp) + 1, resp);
+ return 0;
+}
+
static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
int len)
{
@@ -621,18 +673,34 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
switch (gph->msg_subtype) {
case GSMD_PHONE_POWERUP:
cmd = atcmd_fill("AT+CFUN=1", 9+1,
- &phone_powerup_cb, gu, 0, NULL);
+ &phone_powerup_cb, gu, 0, NULL);
break;
case GSMD_PHONE_POWERDOWN:
cmd = atcmd_fill("AT+CFUN=0", 9+1,
- &phone_powerdown_cb, gu, 0, NULL);
+ &phone_powerdown_cb, gu, 0, NULL);
gu->gsmd->dev_state.on = 0;
break;
case GSMD_PHONE_GET_IMSI:
return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_IMSI,
0, strlen(gu->gsmd->imsi) + 1, gu->gsmd->imsi);
break;
+ case GSMD_PHONE_GET_MANUF:
+ cmd = atcmd_fill("AT+CGMI", 7+1,
+ &gsmd_get_manuf_cb, gu, 0, NULL);
+ break;
+ case GSMD_PHONE_GET_MODEL:
+ cmd = atcmd_fill("AT+CGMM", 7+1,
+ &gsmd_get_model_cb, gu, 0, NULL);
+ break;
+ case GSMD_PHONE_GET_REVISION:
+ cmd = atcmd_fill("AT+CGMR", 7+1,
+ &gsmd_get_revision_cb, gu, 0, NULL);
+ break;
+ case GSMD_PHONE_GET_SERIAL:
+ cmd = atcmd_fill("AT+CGSN", 7+1,
+ &gsmd_get_serial_cb, gu, 0, NULL);
+ break;
default:
return -EINVAL;
diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c
index 83e31e8..18cd614 100644
--- a/src/libgsmd/libgsmd_phone.c
+++ b/src/libgsmd/libgsmd_phone.c
@@ -50,3 +50,23 @@ int lgsm_get_imsi(struct lgsm_handle *lh)
return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_IMSI);
}
+int lgsm_get_manufacturer(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_MANUF);
+}
+
+int lgsm_get_model(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_MODEL);
+}
+
+int lgsm_get_revision(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_REVISION);
+}
+
+int lgsm_get_serial(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_SERIAL);
+}
+
diff --git a/src/util/shell.c b/src/util/shell.c
index b7d65f5..0601e6d 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -400,6 +400,22 @@ static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
payload = (char *)gmh + sizeof(*gmh);
printf("imsi <%s>\n", payload);
break;
+ case GSMD_PHONE_GET_MANUF:
+ payload = (char *)gmh + sizeof(*gmh);
+ printf("manufacturer: %s\n", payload);
+ break;
+ case GSMD_PHONE_GET_MODEL:
+ payload = (char *)gmh + sizeof(*gmh);
+ printf("model: %s\n", payload);
+ break;
+ case GSMD_PHONE_GET_REVISION:
+ payload = (char *)gmh + sizeof(*gmh);
+ printf("revision: %s\n", payload);
+ break;
+ case GSMD_PHONE_GET_SERIAL:
+ payload = (char *)gmh + sizeof(*gmh);
+ printf("serial: %s\n", payload);
+ break;
case GSMD_PHONE_POWERUP:
if (*intresult)
printf("Modem power-up failed: %i\n", *intresult);
@@ -551,6 +567,10 @@ static void shell_help(void)
"\tgvm\tGet Voicemail number\n"
"\tsvm\tSet Voicemail number(svm=number)\n"
"\tim\tGet imsi\n"
+ "\tmf\tGet manufacturer\n"
+ "\tml\tGet model\n"
+ "\trv\tGet revision\n"
+ "\tsn\tGet serial number\n"
"\tcs\tGet Call status\n"
"\tgp\tGet PIN status\n"
"\tRh\tRelease all held calls (+CHLD=0)\n"
@@ -864,6 +884,22 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
printf("Get imsi\n");
lgsm_get_imsi(lgsmh);
pending_responses ++;
+ } else if (!strncmp(buf, "mf", 2)) {
+ printf("Get manufacturer\n");
+ lgsm_get_manufacturer(lgsmh);
+ pending_responses ++;
+ } else if (!strncmp(buf, "ml", 2)) {
+ printf("Get model\n");
+ lgsm_get_model(lgsmh);
+ pending_responses ++;
+ } else if (!strncmp(buf, "rv", 2)) {
+ printf("Get revision\n");
+ lgsm_get_revision(lgsmh);
+ pending_responses ++;
+ } else if (!strncmp(buf, "sn", 2)) {
+ printf("Get serial number\n");
+ lgsm_get_serial(lgsmh);
+ pending_responses ++;
} else if ( strlen(buf)==1 && !strncmp(buf, "M", 1)) {
printf("Modem Power On\n");
lgsm_modem_power(lgsmh, 1);
personal git repositories of Harald Welte. Your mileage may vary