summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gsmd/gsmd.h1
-rw-r--r--include/gsmd/usock.h4
-rw-r--r--include/libgsmd/misc.h22
-rw-r--r--src/gsmd/usock.c72
-rw-r--r--src/libgsmd/libgsmd_phone.c20
-rw-r--r--src/util/shell.c36
6 files changed, 139 insertions, 16 deletions
diff --git a/include/gsmd/gsmd.h b/include/gsmd/gsmd.h
index 0521dd5..fc26875 100644
--- a/include/gsmd/gsmd.h
+++ b/include/gsmd/gsmd.h
@@ -73,6 +73,7 @@ struct gsmd;
#define GSMD_FLAG_SMS_FMT_TEXT 0x0002 /* TODO Use TEXT rather than PDU mode */
#define GSMD_ATCMD_TIMEOUT 60 /* If doesn get respond within 60 secs, discard */
+#define GSMD_MAX_INFO_LEN 64 /* by the standard it should be 2048, way too much :) */
struct gsmd {
unsigned int flags;
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index 21ab54e..4263cad 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -135,6 +135,10 @@ enum gsmd_msg_phone {
GSMD_PHONE_POWERUP = 1,
GSMD_PHONE_POWERDOWN = 2,
GSMD_PHONE_GET_IMSI = 3,
+ GSMD_PHONE_GET_MANUF = 4,
+ GSMD_PHONE_GET_MODEL = 5,
+ GSMD_PHONE_GET_REVISION = 6,
+ GSMD_PHONE_GET_SERIAL = 7,
};
enum gsmd_msg_modem {
diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h
index 4ced5b1..02483d3 100644
--- a/include/libgsmd/misc.h
+++ b/include/libgsmd/misc.h
@@ -11,20 +11,6 @@
extern int lgsm_phone_power(struct lgsm_handle *lh, int power);
extern int lgsm_modem_power(struct lgsm_handle *lh, int power);
-enum lgsm_info_type {
- LGSM_INFO_TYPE_NONE = 0,
- LGSM_INFO_TYPE_MANUF = 1,
- LGSM_INFO_TYPE_MODEL = 2,
- LGSM_INFO_TYPE_REVISION = 3,
- LGSM_INFO_TYPE_SERIAL = 4,
- LGSM_INFO_TYPE_IMSI = 5,
-};
-
-/* Get some information about the handset */
-extern int lgsm_get_info(struct lgsm_handle *lh,
- enum lgsm_info_type type,
- char *ret_string, u_int16_t len);
-
/* Authenticate to SIM Card using specified null-terminated pin */
extern int lgsm_pin_auth(struct lgsm_handle *lh, const char *pin);
@@ -73,6 +59,14 @@ extern int lgsm_get_subscriber_num(struct lgsm_handle *lh);
/* Retrieve IMSI information */
extern int lgsm_get_imsi(struct lgsm_handle *lh);
+/* Retrieve manufacturer information */
+extern int lgsm_get_manufacturer(struct lgsm_handle *lh);
+/* Retrieve model information */
+extern int lgsm_get_model(struct lgsm_handle *lh);
+/* Retrieve revision information */
+extern int lgsm_get_revision(struct lgsm_handle *lh);
+/* Retrieve serial information */
+extern int lgsm_get_serial(struct lgsm_handle *lh);
/* Set voice mail number */
extern int lgsm_voicemail_set(struct lgsm_handle *lh, const char *number);
/* Get currently configured voice mail number */
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