From 9425af516e374f787bcb20244d931e7a355fd0f8 Mon Sep 17 00:00:00 2001 From: erin_yueh Date: Fri, 15 Feb 2008 11:10:16 +0000 Subject: gsmd: add retrieving phone info (Erin Yueh) git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@4067 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/gsmd/usock.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'src/gsmd') diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 426fa68..c371c17 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -613,6 +613,58 @@ static int phone_powerdown_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) cmd->id, sizeof(ret), &ret); } +static int gsmd_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + struct gsmd_user *gu = ctx; + + DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); + if (strncmp(resp, "+CGMI: ", 7)) + return -EINVAL; + resp += 7; + return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_MANUF, + cmd->id, strlen(resp) + 1, resp); + return 0; +} + +static int gsmd_get_model_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + struct gsmd_user *gu = ctx; + + DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); + if (strncmp(resp, "+CGMM: ", 7)) + return -EINVAL; + resp += 7; + return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_MODEL, + cmd->id, strlen(resp) + 1, resp); + return 0; +} + +static int gsmd_get_revision_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + struct gsmd_user *gu = ctx; + + DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); + if (strncmp(resp, "+CGMR: ", 7)) + return -EINVAL; + resp += 7; + return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_REVISION, + cmd->id, strlen(resp) + 1, resp); + return 0; +} + +static int gsmd_get_serial_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + struct gsmd_user *gu = ctx; + + DEBUGP("cmd = '%s', resp: '%s'\n", cmd->buf, resp); + if (strncmp(resp, "+CGSN: ", 7)) + return -EINVAL; + resp += 7; + return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_SERIAL, + cmd->id, strlen(resp) + 1, resp); + return 0; +} + static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, int len) { @@ -621,18 +673,34 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, switch (gph->msg_subtype) { case GSMD_PHONE_POWERUP: cmd = atcmd_fill("AT+CFUN=1", 9+1, - &phone_powerup_cb, gu, 0, NULL); + &phone_powerup_cb, gu, 0, NULL); break; case GSMD_PHONE_POWERDOWN: cmd = atcmd_fill("AT+CFUN=0", 9+1, - &phone_powerdown_cb, gu, 0, NULL); + &phone_powerdown_cb, gu, 0, NULL); gu->gsmd->dev_state.on = 0; break; case GSMD_PHONE_GET_IMSI: return gsmd_ucmd_submit(gu, GSMD_MSG_PHONE, GSMD_PHONE_GET_IMSI, 0, strlen(gu->gsmd->imsi) + 1, gu->gsmd->imsi); break; + case GSMD_PHONE_GET_MANUF: + cmd = atcmd_fill("AT+CGMI", 7+1, + &gsmd_get_manuf_cb, gu, 0, NULL); + break; + case GSMD_PHONE_GET_MODEL: + cmd = atcmd_fill("AT+CGMM", 7+1, + &gsmd_get_model_cb, gu, 0, NULL); + break; + case GSMD_PHONE_GET_REVISION: + cmd = atcmd_fill("AT+CGMR", 7+1, + &gsmd_get_revision_cb, gu, 0, NULL); + break; + case GSMD_PHONE_GET_SERIAL: + cmd = atcmd_fill("AT+CGSN", 7+1, + &gsmd_get_serial_cb, gu, 0, NULL); + break; default: return -EINVAL; -- cgit v1.2.3