summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gsmd/usock.h1
-rw-r--r--include/libgsmd/misc.h3
-rw-r--r--src/gsmd/usock.c13
-rw-r--r--src/libgsmd/libgsmd_phone.c4
-rw-r--r--src/util/shell.c9
5 files changed, 28 insertions, 2 deletions
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index 162599a..5116da9 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -95,6 +95,7 @@ enum gsmd_msg_phone {
GSMD_PHONE_POWERUP = 1,
GSMD_PHONE_POWERDOWN = 2,
GSMD_PHONE_GET_IMSI = 3,
+ GSMD_PIN_GET_STATUS = 4,
};
enum gsmd_msg_modem {
diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h
index 554d958..8111360 100644
--- a/include/libgsmd/misc.h
+++ b/include/libgsmd/misc.h
@@ -79,5 +79,6 @@ extern int lgsm_get_subscriber_num(struct lgsm_handle *lh);
/* Retrieve IMSI information */
extern int lgsm_get_imsi(struct lgsm_handle *lh);
-
+/* Get PIN status information */
+extern int lgsm_pin_status(struct lgsm_handle *lh);
#endif
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index fd602b5..76adc9b 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -383,6 +383,14 @@ static int get_imsi_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
cmd->id, strlen(resp) + 1, resp);
}
+static int get_cpin_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ DEBUGP("resp: %s\n", resp);
+
+ return gsmd_ucmd_submit(ctx, GSMD_MSG_PHONE, GSMD_PIN_GET_STATUS,
+ cmd->id, strlen(resp) + 1, resp);
+}
+
static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
int len)
{
@@ -402,7 +410,10 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
case GSMD_PHONE_GET_IMSI:
cmd = atcmd_fill("AT+CIMI", 7 + 1, &get_imsi_cb, gu, 0, NULL);
break;
-
+
+ case GSMD_PIN_GET_STATUS:
+ cmd = atcmd_fill("AT+CPIN?", 8 + 1, &get_cpin_cb, gu, 0, NULL);
+ break;
default:
return -EINVAL;
}
diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c
index 83e31e8..44082be 100644
--- a/src/libgsmd/libgsmd_phone.c
+++ b/src/libgsmd/libgsmd_phone.c
@@ -50,3 +50,7 @@ int lgsm_get_imsi(struct lgsm_handle *lh)
return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_IMSI);
}
+int lgsm_pin_status(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PIN_GET_STATUS);
+}
diff --git a/src/util/shell.c b/src/util/shell.c
index 12914d8..34f7e12 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -356,6 +356,10 @@ 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_PIN_GET_STATUS:
+ payload = (char *)gmh + sizeof(*gmh);
+ printf("%s\n", payload);
+ break;
case GSMD_PHONE_POWERUP:
if (*intresult)
printf("Modem power-up failed: %i\n", *intresult);
@@ -470,6 +474,7 @@ static int shell_help(void)
"\tsC\tSMS Set Service Centre (sC=number)\n"
"\tim\tGet imsi\n"
"\tcs\tGet Call status\n"
+ "\tgp\tGet PIN status\n"
"\tq\tQuit\n"
);
}
@@ -761,6 +766,10 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
printf("List current call status\n");
lgsm_voice_get_status(lgsmh);
pending_responses ++;
+ } else if ( !strncmp(buf, "gp", 2)) {
+ printf("Get PIN status\n");
+ lgsm_pin_status(lgsmh);
+ pending_responses ++;
} else {
printf("Unknown command `%s'\n", buf);
}
personal git repositories of Harald Welte. Your mileage may vary