From 636e8ecfdf47c6441975e41ed3f39dace55485c6 Mon Sep 17 00:00:00 2001 From: erin_yueh Date: Thu, 6 Mar 2008 09:35:12 +0000 Subject: gsmd: Query Antenna Status (Erin Yueh) git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@4174 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/gsmd/usock.c | 14 ++++++++++++++ src/libgsmd/libgsmd_phone.c | 5 +++++ src/util/shell.c | 7 +++++++ 3 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index c7f8827..aa2c7b5 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -613,6 +613,15 @@ static int phone_powerdown_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) cmd->id, sizeof(ret), &ret); } +static int phone_power_status_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + DEBUGP("resp: %s\n", resp); + if (!strncmp(resp, "+CFUN: ", 7)) + resp += 7; + return gsmd_ucmd_submit(ctx, GSMD_MSG_PHONE, GSMD_PHONE_POWER_STATUS, + cmd->id, strlen(resp) + 1, resp); +} + static int phone_get_manuf_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { struct gsmd_user *gu = ctx; @@ -721,6 +730,11 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, &phone_powerdown_cb, gu, 0, NULL); gu->gsmd->dev_state.on = 0; break; + case GSMD_PHONE_POWER_STATUS: + cmd = atcmd_fill("AT+CFUN?", 8+1, + &phone_power_status_cb, gu, 0, NULL); + 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); diff --git a/src/libgsmd/libgsmd_phone.c b/src/libgsmd/libgsmd_phone.c index 5ad5e44..a67642a 100644 --- a/src/libgsmd/libgsmd_phone.c +++ b/src/libgsmd/libgsmd_phone.c @@ -45,6 +45,11 @@ int lgsm_phone_power(struct lgsm_handle *lh, int power) return lgsm_send_simple(lh, GSMD_MSG_PHONE, type); } +int lgsm_get_power_status(struct lgsm_handle *lh) +{ + return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_POWER_STATUS); +} + int lgsm_get_imsi(struct lgsm_handle *lh) { return lgsm_send_simple(lh, GSMD_MSG_PHONE, GSMD_PHONE_GET_IMSI); diff --git a/src/util/shell.c b/src/util/shell.c index 85aa902..b0d5b41 100644 --- a/src/util/shell.c +++ b/src/util/shell.c @@ -425,6 +425,9 @@ static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) else printf("Modem down\n"); break; + case GSMD_PHONE_POWER_STATUS: + printf("Antenna Status: %s\n", payload); + break; case GSMD_PHONE_GET_BATTERY: printf(": %d : %d \n", bc->bcs, bc->bcl); break; @@ -546,6 +549,7 @@ static void shell_help(void) "\tH\tHangup call\n" "\tO\tAntenna Power On\n" "\to\tAntenna Power Off\n" + "\tgos\tGet Antenna Status\n" "\tV\tVibrator Enable (CVIB=1)\n" "\tv\tVibrator Disable (CVIB=0)\n" "\tM\tModem Power On\n" @@ -680,6 +684,9 @@ int shell_main(struct lgsm_handle *lgsmh, int sync) } else if (!strcmp(buf, "o")) { printf("Power-Off\n"); lgsm_phone_power(lgsmh, 0); + } else if (!strcmp(buf, "gos")) { + printf("Get Antenna status\n"); + lgsm_get_power_status(lgsmh, 0); } else if (!strcmp(buf, "V")) { printf("Vibrator-Enable\n"); lgsm_phone_vibrator(lgsmh, 1); -- cgit v1.2.3