Thursday, 15 July
2010
Thu, 15 Jul
'10
1:43 a.m.
From: Pekka Pessi <Pekka.Pessi(a)nokia.com>
---
plugins/mbm.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index 864b0df..5058b7c 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include <glib.h>
#include <gatchat.h>
@@ -92,6 +93,8 @@ static void mbm_debug(const char *str, void *user_data)
ofono_info("%s %s", prefix, str);
}
+static gboolean init_simpin_check(gpointer user_data);
+
static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -99,17 +102,35 @@ static void simpin_check(gboolean ok, GAtResult *result, gpointer
user_data)
DBG("");
- /* Modem returns error if there is no SIM in slot */
+ /* Modem returns +CME ERROR: 10 if SIM is not ready. */
+ if (!ok && result->final_or_pdu &&
+ !strcmp(result->final_or_pdu, "+CME ERROR: 10")) {
+ g_timeout_add_seconds(1, init_simpin_check, modem);
+ return;
+ }
+
+ /* Modem returns ERROR if there is no SIM in slot. */
data->have_sim = ok;
ofono_modem_set_powered(modem, TRUE);
}
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+
+static gboolean init_simpin_check(gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct mbm_data *data = ofono_modem_get_data(modem);
+ g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix,
+ simpin_check, modem, NULL);
+
+ return FALSE;
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+
DBG("");
if (!ok) {
@@ -117,8 +138,7 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer
user_data)
return;
}
- g_at_chat_send(data->modem_port, "AT+CPIN?", cpin_prefix,
- simpin_check, modem, NULL);
+ init_simpin_check(modem);
}
static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
--
1.7.0.4
Show replies by date
Hi Pekka,
@@ -99,17 +102,35 @@ static void simpin_check(gboolean ok, GAtResult
*result, gpointer user_data)
DBG("");
- /* Modem returns error if there is no SIM in slot */
+ /* Modem returns +CME ERROR: 10 if SIM is not ready. */
+ if (!ok && result->final_or_pdu &&
+ !strcmp(result->final_or_pdu, "+CME ERROR: 10")) {
+ g_timeout_add_seconds(1, init_simpin_check, modem);
+ return;
+ }
+
+ /* Modem returns ERROR if there is no SIM in slot. */
What if the modem has no SIM present at all? You might want to set a
retry threshold so that we don't poll the modem into oblivion.
Regards,
-Denis
Hi Denis,
2010/7/14 Denis Kenzior <denkenz(a)gmail.com>:
> @@ -99,17 +102,35 @@ static void simpin_check(gboolean ok,
GAtResult *result, gpointer user_data)
>
> DBG("");
>
> - /* Modem returns error if there is no SIM in slot */
> + /* Modem returns +CME ERROR: 10 if SIM is not ready. */
> + if (!ok && result->final_or_pdu &&
> + !strcmp(result->final_or_pdu, "+CME ERROR: 10")) {
> + g_timeout_add_seconds(1, init_simpin_check, modem);
> + return;
> + }
> +
> + /* Modem returns ERROR if there is no SIM in slot. */
What if the modem has no SIM present at all? You might want to set a
retry threshold so that we don't poll the modem into oblivion.
If there is no SIM, +CPIN? returns plain ERROR (as I try to explain in
the comment above).
+CME ERROR: 10 is returned while modem is busy trying to connect with
the SIM card.
I'll add a check to stop polling after 5 seconds.
--
Pekka.Pessi mail at
nokia.com