diff options
-rw-r--r-- | plugins/mbm.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/plugins/mbm.c b/plugins/mbm.c index 91935398..864b0df3 100644 --- a/plugins/mbm.c +++ b/plugins/mbm.c @@ -48,7 +48,7 @@ #include <drivers/atmodem/vendor.h> static const char *cfun_prefix[] = { "+CFUN:", NULL }; -static const char *crsm_prefix[] = { "+CRSM:", NULL }; +static const char *cpin_prefix[] = { "+CPIN:", NULL }; static const char *none_prefix[] = { NULL }; struct mbm_data { @@ -92,32 +92,16 @@ static void mbm_debug(const char *str, void *user_data) ofono_info("%s %s", prefix, str); } -static void status_check(gboolean ok, GAtResult *result, gpointer user_data) +static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; struct mbm_data *data = ofono_modem_get_data(modem); - GAtResultIter iter; - gint sw[2]; DBG(""); - if (!ok) - goto poweron; - - /* Modem fakes a 94 04 response from card (File Id not found / - * Pattern not found) when there's no card in the slot. - */ - g_at_result_iter_init(&iter, result); - - if (!g_at_result_iter_next(&iter, "+CRSM:")) - goto poweron; - - g_at_result_iter_next_number(&iter, &sw[0]); - g_at_result_iter_next_number(&iter, &sw[1]); - - data->have_sim = sw[0] != 0x94 || sw[1] != 0x04; + /* Modem returns error if there is no SIM in slot */ + data->have_sim = ok; -poweron: ofono_modem_set_powered(modem, TRUE); } @@ -133,8 +117,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) return; } - g_at_chat_send(data->modem_port, "AT+CRSM=242", crsm_prefix, - status_check, modem, NULL); + g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix, + simpin_check, modem, NULL); } static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data) |