diff options
author | erin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2008-01-24 15:20:40 +0000 |
---|---|---|
committer | erin_yueh <erin_yueh@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2008-01-24 15:20:40 +0000 |
commit | 288049ff764151736483ba5f07987df67748b9cd (patch) | |
tree | 31f2f881943d19db1f4b1677b0de05c3b48963d9 /src/gsmd | |
parent | b97df6c14964a74476e2327f426dd2b7d9f40ee0 (diff) |
gsmd: query network registration status (Erin Yueh)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3943 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/gsmd')
-rw-r--r-- | src/gsmd/usock.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 0164c1c..b6f42dd 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -664,6 +664,33 @@ static int usock_rcv_modem(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, return 0; } +static int network_query_reg_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + struct gsmd_user *gu = ctx; + struct gsm_extrsp *er; + enum gsmd_netreg_state state; + + DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); + + if (strncmp(resp, "+CREG: ", 7)) + return -EINVAL; + resp += 7; + er = extrsp_parse(gsmd_tallocs, resp); + if(!er) + return -ENOMEM; + //extrsp_dump(er); + /* +CREG: <n>,<stat>[,<lac>,<ci>] */ + if((er->num_tokens == 4 || er->num_tokens == 2 ) && + er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC && + er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) { + state = er->tokens[1].u.numeric; + } + + talloc_free(er); + return gsmd_ucmd_submit(gu, GSMD_MSG_NETWORK, GSMD_NETWORK_QUERY_REG, + cmd->id, sizeof(state), &state); +} + static int network_vmail_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { struct gsmd_user *gu = ctx; @@ -735,6 +762,8 @@ static int network_sigq_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) cmd->id, sizeof(gsq), &gsq); } + + static int network_oper_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { struct gsmd_user *gu = ctx; @@ -1004,6 +1033,9 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, case GSMD_NETWORK_DEREGISTER: cmd = atcmd_fill("AT+COPS=2", 9+1, &null_cmd_cb, gu, 0, NULL); break; + case GSMD_NETWORK_QUERY_REG: + cmd = atcmd_fill("AT+CREG?", 8+1, &network_query_reg_cb, gu, 0, NULL); + break; case GSMD_NETWORK_VMAIL_GET: cmd = atcmd_fill("AT+CSVM?", 8+1, &network_vmail_cb, gu, 0, NULL); break; |