summaryrefslogtreecommitdiffstats
path: root/plugins/ifx.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2012-02-02 09:15:36 -0600
committerDenis Kenzior <denkenz@gmail.com>2012-02-02 09:15:36 -0600
commit6b44e65993939b23e54aabae71039f52638c4960 (patch)
treebc9c820f4845d418303f42dda0426c0e62045a51 /plugins/ifx.c
parent1b5b46a23e03f817e5322ab73deef0208d7fb242 (diff)
downloadofono-6b44e65993939b23e54aabae71039f52638c4960.tar.bz2
ifx: Make sure query XSIMSTATE
XSIMSTATE=1 does not seem to reliably activate XSIM notifications anymore. So query the XSIMSTATE at startup instead.
Diffstat (limited to 'plugins/ifx.c')
-rw-r--r--plugins/ifx.c70
1 files changed, 54 insertions, 16 deletions
diff --git a/plugins/ifx.c b/plugins/ifx.c
index c20a4ae7..b37dbb00 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: