diff options
author | tick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-11-20 06:05:28 +0000 |
---|---|---|
committer | tick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-11-20 06:05:28 +0000 |
commit | 66ce291b391e092b9af9b764ca5465ce448fb6c8 (patch) | |
tree | af3c1f3d02cbb5fabfdaa103069def34c388dcad /src/gsmd | |
parent | ce08f5ee38bca622527551b28678f4e3a283fca1 (diff) |
[gsmd] New feature for power on/off GSM modem (Sean Chiang)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3449 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/gsmd')
-rw-r--r-- | src/gsmd/machine_generic.c | 1 | ||||
-rw-r--r-- | src/gsmd/machine_gta01.c | 47 | ||||
-rw-r--r-- | src/gsmd/machine_tihtc.c | 1 | ||||
-rw-r--r-- | src/gsmd/usock.c | 13 |
4 files changed, 62 insertions, 0 deletions
diff --git a/src/gsmd/machine_generic.c b/src/gsmd/machine_generic.c index 3d80bbf..536192d 100644 --- a/src/gsmd/machine_generic.c +++ b/src/gsmd/machine_generic.c @@ -56,6 +56,7 @@ static int generic_init(struct gsmd *g, int fd) struct gsmd_machine_plugin gsmd_machine_plugin = { .name = "generic", + .power = NULL, .ex_submit = NULL, .detect = &generic_detect, .init = &generic_init, diff --git a/src/gsmd/machine_gta01.c b/src/gsmd/machine_gta01.c index f035ab1..88e007a 100644 --- a/src/gsmd/machine_gta01.c +++ b/src/gsmd/machine_gta01.c @@ -15,6 +15,52 @@ #include <gsmd/atcmd.h> #define GSMD_MODEM_WAKEUP_TIMEOUT 3 +#define GSMD_MODEM_POWEROFF_TIMEOUT 3 + +static void poweroff_timeout(struct gsmd_timer *tmr, void *data) +{ + exit(0); +} + +static struct gsmd_timer * poweroff_timer(struct gsmd *g) +{ + struct timeval tv; + tv.tv_sec = GSMD_MODEM_POWEROFF_TIMEOUT; + tv.tv_usec = 0; + DEBUGP("Create power off timer\n"); + + return gsmd_timer_create(&tv,&poweroff_timeout,g); +} + +static int gta01_power(struct gsmd *g, int power) +{ + struct gsmd_atcmd * cmd = NULL; + + switch (power) + { + case GSMD_MODEM_POWERUP: + break; + + case GSMD_MODEM_POWERDOWN: + + //After send AT@POFF to GSM modem, modem will not work anymore and gsmd get no response + cmd = atcmd_fill("AT@POFF", 7+1, NULL, g, 0, poweroff_timer); + + if (!cmd) + return -ENOMEM; + + llist_add_tail(&cmd->list, &g->pending_atcmds); + if (llist_empty(&g->busy_atcmds) && !llist_empty(&g->pending_atcmds)) { + atcmd_wake_pending_queue(g); + } + break; + + default: + return -EINVAL; + } + + return 0; +} static int null_wakeup_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { @@ -103,6 +149,7 @@ static int gta01_init(struct gsmd *g, int fd) struct gsmd_machine_plugin gsmd_machine_plugin = { .name = "TI Calypso / FIC firmware", + .power = >a01_power, .ex_submit = &atcmd_wakeup_modem, .detect = >a01_detect, .init = >a01_init, diff --git a/src/gsmd/machine_tihtc.c b/src/gsmd/machine_tihtc.c index 6fe52f0..b07d32e 100644 --- a/src/gsmd/machine_tihtc.c +++ b/src/gsmd/machine_tihtc.c @@ -66,6 +66,7 @@ static int tihtc_init(struct gsmd *g, int fd) struct gsmd_machine_plugin gsmd_machine_plugin = { .name = "TI Calypso / HTC firmware", + .power = NULL, .ex_submit = NULL, .detect = &tihtc_detect, .init = &tihtc_init, diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index 3dc74d3..0b81306 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -288,6 +288,18 @@ static int usock_rcv_phone(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, return atcmd_submit(gu->gsmd, cmd); } +static int usock_rcv_modem(struct gsmd_user *gu, struct gsmd_msg_hdr *gph, + int len) +{ + struct gsmd *g = gu->gsmd; + + if (g->machinepl->power) { + g->machinepl->power(g, gph->msg_subtype); + } + + return 0; +} + static int network_vmail_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) { struct gsmd_user *gu = ctx; @@ -1168,6 +1180,7 @@ static usock_msg_handler *pcmd_type_handlers[__NUM_GSMD_MSGS] = { [GSMD_MSG_SMS] = &usock_rcv_sms, [GSMD_MSG_CB] = &usock_rcv_cb, [GSMD_MSG_PHONEBOOK] = &usock_rcv_phonebook, + [GSMD_MSG_MODEM] = &usock_rcv_modem, }; static int usock_rcv_pcmd(struct gsmd_user *gu, char *buf, int len) |