* [PATCH_v3 1/3] atutil: Add destroyer in at_util_sim_state_query_new prototype
2012-04-18 12:16 [PATCH_v3 0/3] Poll SIM state for ZTE modem when PIN is entered Guillaume Zajac
@ 2012-04-18 12:16 ` Guillaume Zajac
2012-04-18 9:10 ` Denis Kenzior
2012-04-18 12:16 ` [PATCH_v3 2/3] plugins: Update new at_util_sim_state_query_new() prototype use Guillaume Zajac
2012-04-18 12:16 ` [PATCH_v3 3/3] atmodem: Poll SIM state after having entered PIN Guillaume Zajac
2 siblings, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2012-04-18 12:16 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1966 bytes --]
---
drivers/atmodem/atutil.c | 8 +++++++-
drivers/atmodem/atutil.h | 3 ++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index 0c6aab4..7c46dc5 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -45,6 +45,7 @@ struct at_util_sim_state_query {
guint num_times;
at_util_sim_inserted_cb_t cb;
void *userdata;
+ GDestroyNotify data_destroy;
};
static gboolean cpin_check(gpointer userdata);
@@ -574,7 +575,8 @@ static gboolean cpin_check(gpointer userdata)
struct at_util_sim_state_query *at_util_sim_state_query_new(GAtChat *chat,
guint interval, guint num_times,
at_util_sim_inserted_cb_t cb,
- void *userdata)
+ void *userdata,
+ GDestroyNotify data_destroy)
{
struct at_util_sim_state_query *req;
@@ -585,6 +587,7 @@ struct at_util_sim_state_query *at_util_sim_state_query_new(GAtChat *chat,
req->num_times = num_times;
req->cb = cb;
req->userdata = userdata;
+ req->data_destroy = data_destroy;
cpin_check(req);
@@ -599,5 +602,8 @@ void at_util_sim_state_query_free(struct at_util_sim_state_query *req)
if (req->cpin_poll_source > 0)
g_source_remove(req->cpin_poll_source);
+ if (req->data_destroy)
+ req->data_destroy(req->userdata);
+
g_free(req);
}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 5046547..5ab9901 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -79,7 +79,8 @@ gboolean at_util_parse_attr(GAtResult *result, const char *prefix,
struct at_util_sim_state_query *at_util_sim_state_query_new(GAtChat *chat,
guint interval, guint num_times,
at_util_sim_inserted_cb_t cb,
- void *userdata);
+ void *userdata,
+ GDestroyNotify data_destroy);
void at_util_sim_state_query_free(struct at_util_sim_state_query *req);
struct cb_data {
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH_v3 2/3] plugins: Update new at_util_sim_state_query_new() prototype use
2012-04-18 12:16 [PATCH_v3 0/3] Poll SIM state for ZTE modem when PIN is entered Guillaume Zajac
2012-04-18 12:16 ` [PATCH_v3 1/3] atutil: Add destroyer in at_util_sim_state_query_new prototype Guillaume Zajac
@ 2012-04-18 12:16 ` Guillaume Zajac
2012-04-18 9:11 ` Denis Kenzior
2012-04-18 12:16 ` [PATCH_v3 3/3] atmodem: Poll SIM state after having entered PIN Guillaume Zajac
2 siblings, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2012-04-18 12:16 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2407 bytes --]
---
plugins/alcatel.c | 3 ++-
plugins/mbm.c | 2 +-
plugins/samsung.c | 3 ++-
plugins/speedup.c | 3 ++-
plugins/zte.c | 3 ++-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/plugins/alcatel.c b/plugins/alcatel.c
index fd0e4ec..8005170 100644
--- a/plugins/alcatel.c
+++ b/plugins/alcatel.c
@@ -157,7 +157,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
}
data->sim_state_query = at_util_sim_state_query_new(data->aux,
- 2, 20, sim_state_cb, modem);
+ 2, 20, sim_state_cb, modem,
+ NULL);
}
static int alcatel_enable(struct ofono_modem *modem)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index 32c7665..035f87e 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -164,7 +164,7 @@ done:
data->sim_state_query = at_util_sim_state_query_new(data->modem_port,
1, 5,
sim_state_cb,
- modem);
+ modem, NULL);
}
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
diff --git a/plugins/samsung.c b/plugins/samsung.c
index 8e0d360..68a9b0a 100644
--- a/plugins/samsung.c
+++ b/plugins/samsung.c
@@ -142,7 +142,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
}
data->sim_state_query = at_util_sim_state_query_new(data->chat,
- 1, 5, sim_state_cb, modem);
+ 1, 5, sim_state_cb, modem,
+ NULL);
}
static int samsung_enable(struct ofono_modem *modem)
diff --git a/plugins/speedup.c b/plugins/speedup.c
index ca6ed13..ca33f48 100644
--- a/plugins/speedup.c
+++ b/plugins/speedup.c
@@ -174,7 +174,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
}
data->sim_state_query = at_util_sim_state_query_new(data->aux,
- 2, 20, sim_state_cb, modem);
+ 2, 20, sim_state_cb, modem,
+ NULL);
}
static int speedup_enable(struct ofono_modem *modem)
diff --git a/plugins/zte.c b/plugins/zte.c
index 3a83c8b..53beefe 100644
--- a/plugins/zte.c
+++ b/plugins/zte.c
@@ -218,7 +218,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
}
data->sim_state_query = at_util_sim_state_query_new(data->aux,
- 2, 20, sim_state_cb, modem);
+ 2, 20, sim_state_cb, modem,
+ NULL);
}
static int zte_enable(struct ofono_modem *modem)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH_v3 3/3] atmodem: Poll SIM state after having entered PIN
2012-04-18 12:16 [PATCH_v3 0/3] Poll SIM state for ZTE modem when PIN is entered Guillaume Zajac
2012-04-18 12:16 ` [PATCH_v3 1/3] atutil: Add destroyer in at_util_sim_state_query_new prototype Guillaume Zajac
2012-04-18 12:16 ` [PATCH_v3 2/3] plugins: Update new at_util_sim_state_query_new() prototype use Guillaume Zajac
@ 2012-04-18 12:16 ` Guillaume Zajac
2012-04-18 12:39 ` [PATCH_v4] " Guillaume Zajac
2 siblings, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2012-04-18 12:16 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2111 bytes --]
We encountered the problem of CME ERROR 14: SIM busy on ZTE modems.
ZTE modems don't use SIM notification to check SIM state.
We poll SIM ready state before confirming PIN is entered.
---
drivers/atmodem/sim.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index c51b1d4..865d758 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -51,6 +51,7 @@ struct sim_data {
GAtChat *chat;
unsigned int vendor;
guint ready_id;
+ struct at_util_sim_state_query *sim_state_query;
};
static const char *crsm_prefix[] = { "+CRSM:", NULL };
@@ -972,6 +973,21 @@ static void at_epev_notify(GAtResult *result, gpointer user_data)
sd->ready_id = 0;
}
+static void sim_state_cb(gboolean present, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct sim_data *sd = cbd->user;
+ ofono_sim_lock_unlock_cb_t cb = cbd->cb;
+
+ at_util_sim_state_query_free(sd->sim_state_query);
+ sd->sim_state_query = NULL;
+
+ if (present == 1)
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ else
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
static void at_pin_send_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
@@ -1005,6 +1021,16 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
sd->ready_id = g_at_chat_register(sd->chat, "*EPEV",
at_epev_notify,
FALSE, cbd, g_free);
+ case OFONO_VENDOR_ZTE:
+ /*
+ * On ZTE modems, after pin is entered, SIM state is check
+ * by doing some polling as their modem doesn't use
+ * notification.
+ */
+ default:
+ sd->sim_state_query = at_util_sim_state_query_new(sd->chat,
+ 2, 20, sim_state_cb, cbd,
+ g_free);
return;
}
@@ -1246,6 +1272,9 @@ static void at_sim_remove(struct ofono_sim *sim)
{
struct sim_data *sd = ofono_sim_get_data(sim);
+ /* Cleanup potential SIM state polling */
+ at_util_sim_state_query_free(sd->sim_state_query);
+
ofono_sim_set_data(sim, NULL);
g_at_chat_unref(sd->chat);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH_v4] atmodem: Poll SIM state after having entered PIN
2012-04-18 12:16 ` [PATCH_v3 3/3] atmodem: Poll SIM state after having entered PIN Guillaume Zajac
@ 2012-04-18 12:39 ` Guillaume Zajac
2012-04-18 9:22 ` Denis Kenzior
0 siblings, 1 reply; 8+ messages in thread
From: Guillaume Zajac @ 2012-04-18 12:39 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2062 bytes --]
We encountered the problem of CME ERROR 14: SIM busy on ZTE modems.
ZTE modems don't use SIM notification to check SIM state.
We poll SIM ready state before confirming PIN is entered.
---
drivers/atmodem/sim.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index c51b1d4..1c9a7f3 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -51,6 +51,7 @@ struct sim_data {
GAtChat *chat;
unsigned int vendor;
guint ready_id;
+ struct at_util_sim_state_query *sim_state_query;
};
static const char *crsm_prefix[] = { "+CRSM:", NULL };
@@ -972,6 +973,21 @@ static void at_epev_notify(GAtResult *result, gpointer user_data)
sd->ready_id = 0;
}
+static void sim_state_cb(gboolean present, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct sim_data *sd = cbd->user;
+ ofono_sim_lock_unlock_cb_t cb = cbd->cb;
+
+ at_util_sim_state_query_free(sd->sim_state_query);
+ sd->sim_state_query = NULL;
+
+ if (present == 1)
+ CALLBACK_WITH_SUCCESS(cb, cbd->data);
+ else
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
static void at_pin_send_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
@@ -1006,6 +1022,16 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
at_epev_notify,
FALSE, cbd, g_free);
return;
+ case OFONO_VENDOR_ZTE:
+ /*
+ * On ZTE modems, after pin is entered, SIM state is check
+ * by doing some polling as their modem doesn't use
+ * notification.
+ */
+ sd->sim_state_query = at_util_sim_state_query_new(sd->chat,
+ 2, 20, sim_state_cb, cbd,
+ g_free);
+ return;
}
done:
@@ -1246,6 +1272,9 @@ static void at_sim_remove(struct ofono_sim *sim)
{
struct sim_data *sd = ofono_sim_get_data(sim);
+ /* Cleanup potential SIM state polling */
+ at_util_sim_state_query_free(sd->sim_state_query);
+
ofono_sim_set_data(sim, NULL);
g_at_chat_unref(sd->chat);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread