summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem/sim.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-05-25 14:32:28 +0200
committerMarcel Holtmann <marcel@holtmann.org>2012-05-25 14:32:28 +0200
commit1698d720ce16c7ae5caa0c3d86c3b9226b9949d2 (patch)
tree98cd15591618700f896dff97af77b6c99f4076e1 /drivers/atmodem/sim.c
parent9954425175b12eb9036c8cd1d7d1b5646be472d7 (diff)
downloadofono-1698d720ce16c7ae5caa0c3d86c3b9226b9949d2.tar.bz2
atmodem: Add support for Icera PIN retry counters
Diffstat (limited to 'drivers/atmodem/sim.c')
-rw-r--r--drivers/atmodem/sim.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index dd86980d..971b0ea4 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -60,6 +60,7 @@ static const char *clck_prefix[] = { "+CLCK:", NULL };
static const char *huawei_cpin_prefix[] = { "^CPIN:", NULL };
static const char *xpincnt_prefix[] = { "+XPINCNT:", NULL };
static const char *zpinpuk_prefix[] = { "+ZPINPUK:", NULL };
+static const char *pinnum_prefix[] = { "%PINNUM:", NULL };
static const char *oercn_prefix[] = { "_OERCN:", NULL };
static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
static const char *epin_prefix[] = { "*EPIN:", NULL };
@@ -505,6 +506,46 @@ error:
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
+static void pinnum_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_sim_pin_retries_cb_t cb = cbd->cb;
+ const char *final = g_at_result_final_response(result);
+ GAtResultIter iter;
+ struct ofono_error error;
+ int retries[OFONO_SIM_PASSWORD_INVALID];
+ size_t i;
+ static enum ofono_sim_password_type password_types[] = {
+ OFONO_SIM_PASSWORD_SIM_PIN,
+ OFONO_SIM_PASSWORD_SIM_PUK,
+ OFONO_SIM_PASSWORD_SIM_PIN2,
+ OFONO_SIM_PASSWORD_SIM_PUK2,
+ };
+
+
+ decode_at_error(&error, final);
+
+ if (!ok) {
+ cb(&error, NULL, cbd->data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "%PINNUM:"))
+ goto error;
+
+ BUILD_PIN_RETRIES_ARRAY(password_types, ARRAY_SIZE(password_types),
+ retries);
+
+ cb(&error, retries, cbd->data);
+
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+}
+
static void zpinpuk_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;
@@ -830,6 +871,11 @@ static void at_pin_retries_query(struct ofono_sim *sim,
huawei_cpin_cb, cbd, g_free) > 0)
return;
break;
+ case OFONO_VENDOR_ICERA:
+ if (g_at_chat_send(sd->chat, "AT%PINNUM?", pinnum_prefix,
+ pinnum_cb, cbd, g_free) > 0)
+ return;
+ break;
case OFONO_VENDOR_ZTE:
if (g_at_chat_send(sd->chat, "AT+ZPINPUK=?", zpinpuk_prefix,
zpinpuk_cb, cbd, g_free) > 0)