From 6297470cf0526be9eb8710d565035d4de56071ee Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 5 Nov 2009 11:00:57 -0600 Subject: [PATCH] Fix: Handle MBM hardware that fails on EMRDY? --- plugins/mbm.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/mbm.c b/plugins/mbm.c index fd4569c5..2a284287 100644 --- a/plugins/mbm.c +++ b/plugins/mbm.c @@ -108,7 +108,10 @@ static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data) GAtResultIter iter; int status; - DBG(""); + DBG("%d", ok); + + if (!ok) + return; g_at_result_iter_init(&iter, result); @@ -149,6 +152,25 @@ static void emrdy_notifier(GAtResult *result, gpointer user_data) cfun_query, modem, NULL); } +static void emrdy_query(gboolean ok, GAtResult *result, gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct mbm_data *data = ofono_modem_get_data(modem); + + DBG("%d", ok); + + if (ok) + return; + + /* On some MBM hardware the EMRDY cannot be queried, so if this fails + * we try to run CFUN? to check the state. CFUN? will fail unless + * EMRDY: 1 has been sent, in which case the emrdy_notifier should be + * triggered eventually and we send CFUN? again. + */ + g_at_chat_send(data->chat, "AT+CFUN?", cfun_prefix, + cfun_query, modem, NULL); +}; + static int mbm_enable(struct ofono_modem *modem) { struct mbm_data *data = ofono_modem_get_data(modem); @@ -185,7 +207,8 @@ static int mbm_enable(struct ofono_modem *modem) g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1", NULL, NULL, NULL, NULL); - g_at_chat_send(data->chat, "AT*EMRDY?", none_prefix, NULL, NULL, NULL); + g_at_chat_send(data->chat, "AT*EMRDY?", none_prefix, + emrdy_query, modem, NULL); return -EINPROGRESS; }