summaryrefslogtreecommitdiff
path: root/src/gsmd
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-08-17 08:36:48 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-08-17 08:36:48 +0000
commitad708e46d7a8adc45aa8b9ec2ff7b110303f708f (patch)
tree5a5cc9f7679a8dec50677048d2aa6d52c0f5d9cd /src/gsmd
parent1dc0db218c93c606e0eb3ab5d7cc2dff1677fe75 (diff)
Add retrieving phone's own subscriber number. (Andrzej Zaborowski)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2733 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/gsmd')
-rw-r--r--src/gsmd/usock.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 8525c0a..56ef3f4 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -548,6 +548,51 @@ static int network_pref_num_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
return 0;
}
+static int network_ownnumbers_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = (struct gsmd_user *) ctx;
+ struct gsmd_ucmd *ucmd;
+ struct gsmd_own_number *num;
+ int len, ret, type;
+ char dummy;
+
+ if (cmd->ret && cmd->ret != -255)
+ return 0;
+
+ if (sscanf(resp, "+CNUM: \"%*[^\"]\"%c%n", &dummy, &len) > 0)
+ len -= strlen("+CNUM: \"\",");
+ else
+ len = 0;
+
+ ucmd = gsmd_ucmd_fill(sizeof(*num) + len + 1,
+ GSMD_MSG_NETWORK, GSMD_NETWORK_GET_NUMBER, cmd->id);
+ if (!ucmd)
+ return -ENOMEM;
+
+ num = (struct gsmd_own_number *) ucmd->buf;
+ if (len)
+ ret = sscanf(resp, "+CNUM: \"%[^\"]\",\"%32[^\"]\",%i,%*i,%i,",
+ num->name, num->addr.number,
+ &type, &num->service) - 1;
+ else
+ ret = sscanf(resp, "+CNUM: ,\"%32[^\"]\",%i,%*i,%i,",
+ num->addr.number,
+ &type, &num->service);
+ if (ret < 2) {
+ talloc_free(ucmd);
+ return -EINVAL;
+ }
+ if (ret < 3)
+ num->service = GSMD_SERVICE_UNKNOWN;
+ num->name[len] = 0;
+ num->addr.type = type;
+ num->is_last = (cmd->ret == 0);
+
+ usock_cmd_enqueue(ucmd, gu);
+
+ return 0;
+}
+
static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
int len)
{
@@ -607,6 +652,10 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
cmd = atcmd_fill("AT+CPOL=?", 9 + 1,
&network_pref_num_cb, gu, 0);
break;
+ case GSMD_NETWORK_GET_NUMBER:
+ cmd = atcmd_fill("AT+CNUM", 7 + 1,
+ &network_ownnumbers_cb, gu, 0);
+ break;
default:
return -EINVAL;
}
personal git repositories of Harald Welte. Your mileage may vary