summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gsmd/usock.h2
-rw-r--r--include/libgsmd/misc.h2
-rw-r--r--include/libgsmd/phonebook.h3
-rw-r--r--src/gsmd/usock.c46
-rw-r--r--src/libgsmd/libgsmd_phone.c6
-rw-r--r--src/libgsmd/libgsmd_phonebook.c4
-rw-r--r--src/util/shell.c20
7 files changed, 48 insertions, 35 deletions
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index db9eac7..370553e 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -56,6 +56,7 @@ enum gsmd_msg_pin_type {
enum gsmd_msg_phone {
GSMD_PHONE_POWERUP = 1,
GSMD_PHONE_POWERDOWN = 2,
+ GSMD_PHONE_GET_IMSI = 3,
};
enum gsmd_msg_modem {
@@ -255,7 +256,6 @@ enum gsmd_msg_phonebook {
GSMD_PHONEBOOK_SET_STORAGE = 8,
GSMD_PHONEBOOK_RETRIEVE_READRG = 9,
GSMD_PHONEBOOK_RETRIEVE_FIND = 10,
- GSMD_PHONEBOOK_GET_IMSI = 11,
};
/* Type-of-Address, Numbering-Plan-Identification field, GSM 03.40, 9.1.2.5 */
diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h
index 165994e..554d958 100644
--- a/include/libgsmd/misc.h
+++ b/include/libgsmd/misc.h
@@ -77,5 +77,7 @@ extern int lgsm_get_subscriber_num(struct lgsm_handle *lh);
/* GPRS related functions */
/* TBD */
+/* Retrieve IMSI information */
+extern int lgsm_get_imsi(struct lgsm_handle *lh);
#endif
diff --git a/include/libgsmd/phonebook.h b/include/libgsmd/phonebook.h
index 4bcae6c..6365baf 100644
--- a/include/libgsmd/phonebook.h
+++ b/include/libgsmd/phonebook.h
@@ -99,7 +99,4 @@ extern int lgsm_pb_retrieve_readrg(struct lgsm_handle *lh, int num);
/* Retrieve the records of FIND request */
extern int lgsm_pb_retrieve_find(struct lgsm_handle *lh, int num);
-/* Retrieve IMSI information */
-extern int lgsm_get_imsi(struct lgsm_handle *lh); // TODO this needs to go into a SIM specific file
-
#endif
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 0b81306..80165bf 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -263,6 +263,25 @@ static int phone_powerup_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
return 0;
}
+static int get_imsi_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+ struct gsmd_ucmd *ucmd;
+
+ DEBUGP("resp: %s\n", resp);
+
+ ucmd = gsmd_ucmd_fill(strlen(resp)+1, GSMD_MSG_PHONE,
+ GSMD_PHONE_GET_IMSI, 0);
+ if (!ucmd)
+ return -ENOMEM;
+
+ strcpy(ucmd->buf, resp);
+
+ usock_cmd_enqueue(ucmd, gu);
+
+ return 0;
+}
+
static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
int len)
{
@@ -279,9 +298,14 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
&null_cmd_cb, gu, 0, NULL);
gu->gsmd->dev_state.on = 0;
break;
+ case GSMD_PHONE_GET_IMSI:
+ cmd = atcmd_fill("AT+CIMI", 7 + 1, &get_imsi_cb, gu, 0, NULL);
+ break;
+
default:
return -EINVAL;
}
+
if (!cmd)
return -ENOMEM;
@@ -961,25 +985,6 @@ static int phonebook_list_storage_cb(struct gsmd_atcmd *cmd,
return 0;
}
-static int get_imsi_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
-{
- struct gsmd_user *gu = ctx;
- struct gsmd_ucmd *ucmd;
-
- DEBUGP("resp: %s\n", resp);
-
- ucmd = gsmd_ucmd_fill(strlen(resp)+1, GSMD_MSG_PHONEBOOK,
- GSMD_PHONEBOOK_GET_IMSI, 0);
- if (!ucmd)
- return -ENOMEM;
-
- strcpy(ucmd->buf, resp);
-
- usock_cmd_enqueue(ucmd, gu);
-
- return 0;
-}
-
static int usock_rcv_phonebook(struct gsmd_user *gu,
struct gsmd_msg_hdr *gph,int len)
@@ -1156,9 +1161,6 @@ static int usock_rcv_phonebook(struct gsmd_user *gu,
usock_cmd_enqueue(ucmd, gu);
break;
- case GSMD_PHONEBOOK_GET_IMSI:
- cmd = atcmd_fill("AT+CIMI", 7 + 1, &get_imsi_cb, gu, 0, NULL);
- break;
default:
return -EINVAL;
diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c
index 07d1d13..83e31e8 100644
--- a/src/libgsmd/libgsmd_phone.c
+++ b/src/libgsmd/libgsmd_phone.c
@@ -44,3 +44,9 @@ int lgsm_phone_power(struct lgsm_handle *lh, int power)
return lgsm_send_simple(lh, GSMD_MSG_PHONE, type);
}
+
+int lgsm_get_imsi(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_IMSI);
+}
+
diff --git a/src/libgsmd/libgsmd_phonebook.c b/src/libgsmd/libgsmd_phonebook.c
index 4091077..f139c2a 100644
--- a/src/libgsmd/libgsmd_phonebook.c
+++ b/src/libgsmd/libgsmd_phonebook.c
@@ -246,8 +246,4 @@ int lgsm_pb_retrieve_find(struct lgsm_handle *lh, int num)
return 0;
}
-int lgsm_get_imsi(struct lgsm_handle *lh)
-{
- return lgsm_send_simple(lh, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_GET_IMSI);
-}
diff --git a/src/util/shell.c b/src/util/shell.c
index 40dddaf..62e7b0f 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -131,11 +131,6 @@ static int pb_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
nFIND = 0;
break;
- case GSMD_PHONEBOOK_GET_IMSI:
- payload = (char *)gmh + sizeof(*gmh);
- printf("imsi <%s>\n", payload);
- pending_responses --;
- break;
default:
return -EINVAL;
}
@@ -349,6 +344,20 @@ static int net_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
}
}
+static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) {
+ char *payload;
+ switch (gmh->msg_subtype) {
+ case GSMD_PHONE_GET_IMSI:
+ payload = (char *)gmh + sizeof(*gmh);
+ printf("imsi <%s>\n", payload);
+ pending_responses --;
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
static int shell_help(void)
{
printf( "\tA\tAnswer incoming call\n"
@@ -405,6 +414,7 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
lgsm_register_handler(lgsmh, GSMD_MSG_PHONEBOOK, &pb_msghandler);
lgsm_register_handler(lgsmh, GSMD_MSG_SMS, &sms_msghandler);
lgsm_register_handler(lgsmh, GSMD_MSG_NETWORK, &net_msghandler);
+ lgsm_register_handler(lgsmh, GSMD_MSG_PHONE, &phone_msghandler);
fcntl(0, F_SETFD, O_NONBLOCK);
fcntl(gsm_fd, F_SETFD, O_NONBLOCK);
personal git repositories of Harald Welte. Your mileage may vary