summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-12-01 01:54:59 +0000
committertick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-12-01 01:54:59 +0000
commitf07e7027fe91ac71a8ab760f863c3a05a1d1499d (patch)
treee8657fd1bbf18a0b9a6e71385e5dfd071321270f
parented45d021e84b497e75ff4342ad369c615cc174a3 (diff)
gsmd: Modem power-up and -down result events.(Andrzej Zaborowski)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3544 99fdad57-331a-0410-800a-d7fa5415bdb3
-rw-r--r--src/gsmd/usock.c27
-rw-r--r--src/util/shell.c33
2 files changed, 50 insertions, 10 deletions
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 80165bf..cf3aea9 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -248,6 +248,7 @@ static int usock_rcv_pin(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
static int phone_powerup_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
{
struct gsmd_user *gu = ctx;
+ struct gsmd_ucmd *ucmd;
/* We need to verify if there is some error */
switch (cmd->ret) {
@@ -260,7 +261,29 @@ static int phone_powerup_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
gsmd_log(GSMD_DEBUG, "Radio power-up failed\n");
break;
}
- return 0;
+
+ ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_PHONE,
+ GSMD_PHONE_POWERUP, 0);
+ if (ucmd) {
+ ((int *) ucmd->buf)[0] = cmd->ret;
+ usock_cmd_enqueue(ucmd, gu);
+ return 0;
+ }
+ return -ENOMEM;
+}
+
+static int phone_powerdown_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+ struct gsmd_ucmd *ucmd = gsmd_ucmd_fill(sizeof(int), GSMD_MSG_PHONE,
+ GSMD_PHONE_POWERDOWN, 0);
+
+ if (ucmd) {
+ ((int *) ucmd->buf)[0] = cmd->ret;
+ usock_cmd_enqueue(ucmd, gu);
+ return 0;
+ }
+ return -ENOMEM;
}
static int get_imsi_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
@@ -295,7 +318,7 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
case GSMD_PHONE_POWERDOWN:
cmd = atcmd_fill("AT+CFUN=0", 9+1,
- &null_cmd_cb, gu, 0, NULL);
+ &phone_powerdown_cb, gu, 0, NULL);
gu->gsmd->dev_state.on = 0;
break;
case GSMD_PHONE_GET_IMSI:
diff --git a/src/util/shell.c b/src/util/shell.c
index 62e7b0f..031ed34 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -344,18 +344,33 @@ 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) {
+static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
+{
+ char *payload;
+ int *intresult = (void *)gmh + sizeof(*gmh);
+
+ 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;
+ case GSMD_PHONE_POWERUP:
+ if (*intresult)
+ printf("Modem power-up failed: %i\n", *intresult);
+ else
+ printf("Modem powered-up okay\n");
+ break;
+ case GSMD_PHONE_POWERDOWN:
+ if (*intresult)
+ printf("Modem power-down failed: %i\n", *intresult);
+ else
+ printf("Modem down\n");
+ break;
+ default:
+ return -EINVAL;
+ }
+ pending_responses --;
+ return 0;
}
static int shell_help(void)
@@ -688,9 +703,11 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
} else if (!strncmp(buf, "M", 1)) {
printf("Modem Power On\n");
lgsm_modem_power(lgsmh, 1);
+ pending_responses ++;
} else if (!strncmp(buf, "m", 1)) {
printf("Modem Power Off\n");
lgsm_modem_power(lgsmh, 0);
+ pending_responses ++;
} else {
printf("Unknown command `%s'\n", buf);
}
personal git repositories of Harald Welte. Your mileage may vary