From 24ba6f89233f0eb84a7415d00857585b827043d3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Jan 2016 19:34:29 +0100 Subject: [PATCH] wavecom: Always disable the modem when enabling it we don't want to deal with any stale state, e.g. if the modem was already powered up and in CFUN=1 state at the time ofonod was started. --- plugins/wavecom.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/plugins/wavecom.c b/plugins/wavecom.c index 56cade69..2abdc9c2 100644 --- a/plugins/wavecom.c +++ b/plugins/wavecom.c @@ -145,31 +145,18 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) ofono_modem_set_powered(modem, TRUE); } -static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data) +static void cfun_disable2enable(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; GAtChat *chat = ofono_modem_get_data(modem); - GAtResultIter iter; - int status; DBG("ok %d", ok); if (!ok) return; - g_at_result_iter_init(&iter, result); - - if (g_at_result_iter_next(&iter, "+CFUN:") == FALSE) - return; - - g_at_result_iter_next_number(&iter, &status); - - if (status != 1) { - g_at_chat_send(chat, "AT+CFUN=1", none_prefix, - cfun_enable, modem, NULL); - return; - } else - ofono_modem_set_powered(modem, TRUE); + g_at_chat_send(chat, "AT+CFUN=1", none_prefix, + cfun_enable, modem, NULL); } static void wind_set(gboolean ok, GAtResult *result, gpointer user_data) @@ -237,8 +224,8 @@ static int wavecom_enable(struct ofono_modem *modem) g_at_chat_send(chat, "AT+WIND=32767", wind_prefix, wind_set, modem, NULL); - g_at_chat_send(chat, "AT+CFUN?", cfun_prefix, - cfun_query, modem, NULL); + g_at_chat_send(chat, "AT+CFUN=0", cfun_prefix, + cfun_disable2enable, modem, NULL); return -EINPROGRESS; }