summaryrefslogtreecommitdiffstats
path: root/plugins/gobi.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-01-24 12:55:25 +0100
committerMarcel Holtmann <marcel@holtmann.org>2011-01-24 12:55:25 +0100
commit1f356f227bc4257c05dc34e961e4017fd927a522 (patch)
tree0cf7366106b484fbd107cf32f73d0764dcc11a63 /plugins/gobi.c
parent2999252d15ebd4c8a3fcdd8c37fca780c60fab22 (diff)
downloadofono-1f356f227bc4257c05dc34e961e4017fd927a522.tar.bz2
gobi: Handle broken SIM status notification gracefully
Diffstat (limited to 'plugins/gobi.c')
-rw-r--r--plugins/gobi.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/gobi.c b/plugins/gobi.c
index 9d02513d..5024d749 100644
--- a/plugins/gobi.c
+++ b/plugins/gobi.c
@@ -126,7 +126,7 @@ static void simstat_notify(GAtResult *result, gpointer user_data)
struct gobi_data *data = ofono_modem_get_data(modem);
GAtResultIter iter;
- const char *state;
+ const char *state, *tmp;
if (data->sim == NULL)
return;
@@ -136,10 +136,17 @@ static void simstat_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next(&iter, "$QCSIMSTAT:"))
return;
- if (!g_at_result_iter_skip_next(&iter))
+ if (!g_at_result_iter_next_unquoted_string(&iter, &tmp))
return;
- if (!g_at_result_iter_next_unquoted_string(&iter, &state))
+ /*
+ * When receiving an unsolicited notification, the comma
+ * is missing ($QCSIMSTAT: 1 SIM INIT COMPLETED). Handle
+ * this gracefully.
+ */
+ if (g_str_has_prefix(tmp, "1 ") == TRUE)
+ state = tmp + 2;
+ else if (!g_at_result_iter_next_unquoted_string(&iter, &state))
return;
DBG("state %s", state);