From: Denis Kenzior Date: Thu, 2 Feb 2012 15:15:36 +0000 (-0600) Subject: ifx: Make sure query XSIMSTATE X-Git-Tag: 1.4~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b44e65993939b23e54aabae71039f52638c4960;p=platform%2Fupstream%2Fofono.git ifx: Make sure query XSIMSTATE XSIMSTATE=1 does not seem to reliably activate XSIM notifications anymore. So query the XSIMSTATE at startup instead. --- diff --git a/plugins/ifx.c b/plugins/ifx.c index c20a4ae..b37dbb0 100644 --- a/plugins/ifx.c +++ b/plugins/ifx.c @@ -81,6 +81,7 @@ static const char *dlc_nodes[NUM_DLC] = { "/dev/ttyGSM1", "/dev/ttyGSM2", static const char *none_prefix[] = { NULL }; static const char *xdrv_prefix[] = { "+XDRV:", NULL }; static const char *xgendata_prefix[] = { "+XGENDATA:", NULL }; +static const char *xsimstate_prefix[] = { "+XSIMSTATE:", NULL }; struct ifx_data { GIOChannel *device; @@ -138,25 +139,10 @@ static void ifx_remove(struct ofono_modem *modem) g_free(data); } -static void xsim_notify(GAtResult *result, gpointer user_data) +static void ifx_set_sim_state(struct ofono_modem *modem, int state) { - struct ofono_modem *modem = user_data; struct ifx_data *data = ofono_modem_get_data(modem); - GAtResultIter iter; - int state; - - if (data->sim == NULL) - return; - - g_at_result_iter_init(&iter, result); - - if (!g_at_result_iter_next(&iter, "+XSIM:")) - return; - - if (!g_at_result_iter_next_number(&iter, &state)) - return; - DBG("state %d", state); switch (state) { @@ -186,6 +172,55 @@ static void xsim_notify(GAtResult *result, gpointer user_data) } } +static void xsim_notify(GAtResult *result, gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct ifx_data *data = ofono_modem_get_data(modem); + + GAtResultIter iter; + int state; + + if (data->sim == NULL) + return; + + g_at_result_iter_init(&iter, result); + + if (!g_at_result_iter_next(&iter, "+XSIM:")) + return; + + if (!g_at_result_iter_next_number(&iter, &state)) + return; + + ifx_set_sim_state(modem, state); +} + +static void xsimstate_query(gboolean ok, GAtResult *result, gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct ifx_data *data = ofono_modem_get_data(modem); + GAtResultIter iter; + int mode; + int state; + + DBG(""); + + if (!ok) + return; + + g_at_result_iter_init(&iter, result); + + if (!g_at_result_iter_next(&iter, "+XSIMSTATE:")) + return; + + if (!g_at_result_iter_next_number(&iter, &mode)) + return; + + if (!g_at_result_iter_next_number(&iter, &state)) + return; + + ifx_set_sim_state(modem, state); +} + static void shutdown_device(struct ifx_data *data) { int i, fd; @@ -338,6 +373,9 @@ static void xgendata_query(gboolean ok, GAtResult *result, gpointer user_data) g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE=1", none_prefix, NULL, NULL, NULL); + g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE?", xsimstate_prefix, + xsimstate_query, modem, NULL); + return; error: