diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gsmd/usock.c | 46 | ||||
-rw-r--r-- | src/libgsmd/libgsmd_phone.c | 6 | ||||
-rw-r--r-- | src/libgsmd/libgsmd_phonebook.c | 4 | ||||
-rw-r--r-- | src/util/shell.c | 20 |
4 files changed, 45 insertions, 31 deletions
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); |