summaryrefslogtreecommitdiffstats
path: root/plugins/gobi.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-07-27 16:29:52 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-07-27 16:29:52 +0200
commit357499597ef8b65633c8aa6d903dde3abf121650 (patch)
treed5d14275f43f9942b2393f556a2c84723c8fa4d4 /plugins/gobi.c
parent13b41706d1dd60d4b0e6bfd9545d42f8444dd97b (diff)
downloadofono-357499597ef8b65633c8aa6d903dde3abf121650.tar.bz2
gobi: Add timeout for modem enabling handling
Some GOBI cards stop responding to AT commands when RFKILL has been enabled. In that case just timeout after 5 seconds.
Diffstat (limited to 'plugins/gobi.c')
-rw-r--r--plugins/gobi.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/plugins/gobi.c b/plugins/gobi.c
index f31e0cd9..a234f4e0 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -52,6 +52,7 @@ struct gobi_data {
GAtChat *chat;
struct ofono_sim *sim;
gboolean have_sim;
+ guint cfun_timeout;
};
static void gobi_debug(const char *str, void *user_data)
@@ -165,11 +166,16 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
DBG("");
+ if (data->cfun_timeout > 0) {
+ g_source_remove(data->cfun_timeout);
+ data->cfun_timeout = 0;
+ }
+
if (!ok) {
g_at_chat_unref(data->chat);
data->chat = NULL;
- ofono_modem_set_powered(modem, ok);
+ ofono_modem_set_powered(modem, FALSE);
return;
}
@@ -184,7 +190,24 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_send(data->chat, "AT$QCSIMSTAT?", none_prefix,
NULL, NULL, NULL);
- ofono_modem_set_powered(modem, ok);
+ ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean cfun_timeout(gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct gobi_data *data = ofono_modem_get_data(modem);
+
+ ofono_error("Modem enabling timeout, RFKILL enabled?");
+
+ data->cfun_timeout = 0;
+
+ g_at_chat_unref(data->chat);
+ data->chat = NULL;
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ return FALSE;
}
static int gobi_enable(struct ofono_modem *modem)
@@ -203,6 +226,8 @@ static int gobi_enable(struct ofono_modem *modem)
g_at_chat_send(data->chat, "AT+CFUN=4", none_prefix,
cfun_enable, modem, NULL);
+ data->cfun_timeout = g_timeout_add_seconds(5, cfun_timeout, modem);
+
return -EINPROGRESS;
}