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.
This commit is contained in:
root 2016-01-12 19:34:29 +01:00
parent 0b182dc173
commit 24ba6f8923
1 changed files with 5 additions and 18 deletions

View File

@ -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;
}