diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2011-12-29 12:08:38 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2011-12-29 12:08:38 -0800 |
commit | 2e0f1f79c18bb5963396537874c6f31f18800029 (patch) | |
tree | 1f139024bb385ffd50c2e4d2b3c6808f0ee3f845 /drivers | |
parent | 5d1a60b4c466853deb767655cb28ab7c7a77260e (diff) | |
download | ofono-2e0f1f79c18bb5963396537874c6f31f18800029.tar.bz2 |
atmodem: Add support for Option HSO specific PIN retry counters
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/atmodem/sim.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c index ddae177a..297914d9 100644 --- a/drivers/atmodem/sim.c +++ b/drivers/atmodem/sim.c @@ -59,6 +59,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 *oercn_prefix[] = { "_OERCN:", NULL }; static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL }; static const char *epin_prefix[] = { "*EPIN:", NULL }; static const char *none_prefix[] = { NULL }; @@ -620,6 +621,43 @@ error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); } +static void oercn_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, + }; + + 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, "_OERCN:")) + 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 cpnnum_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; @@ -782,6 +820,11 @@ static void at_pin_retries_query(struct ofono_sim *sim, cpnnum_cb, cbd, g_free) > 0) return; break; + case OFONO_VENDOR_OPTION_HSO: + if (g_at_chat_send(sd->chat, "AT_OERCN?", oercn_prefix, + oercn_cb, cbd, g_free) > 0) + return; + break; case OFONO_VENDOR_HUAWEI: if (g_at_chat_send(sd->chat, "AT^CPIN?", huawei_cpin_prefix, huawei_cpin_cb, cbd, g_free) > 0) |