From 4a5f37dafdecf567e372b90adb38d41281d6e213 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 24 Oct 2010 20:00:32 +0200 Subject: ifx: Detect modems stuck in multiplexer mode When the initial AT commands on the master device don't respond, then the modem is stuck in multiplexer mode. For now just report an error. --- plugins/ifx.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/ifx.c b/plugins/ifx.c index 9aa8b0bf..430db22a 100644 --- a/plugins/ifx.c +++ b/plugins/ifx.c @@ -86,6 +86,7 @@ struct ifx_data { guint dlc_poll_count; guint dlc_poll_source; guint dlc_init_source; + guint mux_init_timeout; guint frame_size; int mux_ldisc; int saved_ldisc; @@ -462,6 +463,11 @@ static void mux_setup_cb(gboolean ok, GAtResult *result, gpointer user_data) DBG(""); + if (data->mux_init_timeout > 0) { + g_source_remove(data->mux_init_timeout); + data->mux_init_timeout = 0; + } + g_at_chat_unref(data->dlcs[AUX_DLC]); data->dlcs[AUX_DLC] = NULL; @@ -501,6 +507,26 @@ error: ofono_modem_set_powered(modem, FALSE); } +static gboolean mux_timeout_cb(gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct ifx_data *data = ofono_modem_get_data(modem); + + ofono_error("Timeout with multiplexer setup"); + + data->mux_init_timeout = 0; + + g_at_chat_unref(data->dlcs[AUX_DLC]); + data->dlcs[AUX_DLC] = NULL; + + g_io_channel_unref(data->device); + data->device = NULL; + + ofono_modem_set_powered(modem, FALSE); + + return FALSE; +} + static int ifx_enable(struct ofono_modem *modem) { struct ifx_data *data = ofono_modem_get_data(modem); @@ -559,6 +585,9 @@ static int ifx_enable(struct ofono_modem *modem) g_at_chat_send(chat, "AT+CMUX=0,0,,1509,10,3,30,,", NULL, mux_setup_cb, modem, NULL); + data->mux_init_timeout = g_timeout_add_seconds(5, mux_timeout_cb, + modem); + data->dlcs[AUX_DLC] = chat; return -EINPROGRESS; -- cgit v1.2.3