summaryrefslogtreecommitdiff
path: root/src/gsmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsmd')
-rw-r--r--src/gsmd/machine_generic.c1
-rw-r--r--src/gsmd/machine_gta01.c47
-rw-r--r--src/gsmd/machine_tihtc.c1
-rw-r--r--src/gsmd/usock.c13
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 = &gta01_power,
.ex_submit = &atcmd_wakeup_modem,
.detect = &gta01_detect,
.init = &gta01_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)
personal git repositories of Harald Welte. Your mileage may vary