summaryrefslogtreecommitdiff
path: root/plugins/mbm.c
diff options
context:
space:
mode:
authorPekka Pessi <Pekka.Pessi@nokia.com>2010-06-29 14:06:41 +0300
committerDenis Kenzior <denkenz@gmail.com>2010-06-29 12:24:51 -0500
commite8965f5f8c85578158de69cc57df624f9c62f461 (patch)
treeec2ec82d4c2e35d4c44f2a303bc836fd517ebc0e /plugins/mbm.c
parent7d4ae198d0050757815df0f3f86fb4fe23322988 (diff)
downloadofono-e8965f5f8c85578158de69cc57df624f9c62f461.tar.gz
mbm: use CPIN? to check if SIM is missing
AT+CRSM=242 is not supported by all mbm models.
Diffstat (limited to 'plugins/mbm.c')
-rw-r--r--plugins/mbm.c28
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)