mirror of git://git.sysmocom.de/ofono
atmodem: Enable support for PIN retry counters of ZTE modems
This commit is contained in:
parent
eea276a0a8
commit
5b7d2329dc
|
@ -57,6 +57,7 @@ static const char *cpin_prefix[] = { "+CPIN:", NULL };
|
|||
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 *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
|
||||
static const char *epin_prefix[] = { "*EPIN:", NULL };
|
||||
static const char *none_prefix[] = { NULL };
|
||||
|
@ -148,6 +149,7 @@ static void at_sim_read_info(struct ofono_sim *sim, int fileid,
|
|||
snprintf(buf, sizeof(buf), "AT+CRSM=192,%i", fileid);
|
||||
|
||||
switch (sd->vendor) {
|
||||
case OFONO_VENDOR_ZTE:
|
||||
case OFONO_VENDOR_HUAWEI:
|
||||
case OFONO_VENDOR_SIERRA:
|
||||
case OFONO_VENDOR_QUALCOMM_MSM:
|
||||
|
@ -539,6 +541,44 @@ 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;
|
||||
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, "+ZPINPUK:"))
|
||||
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 xpincnt_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
|
@ -675,19 +715,21 @@ static void at_pin_retries_query(struct ofono_sim *sim,
|
|||
if (g_at_chat_send(sd->chat, "AT+XPINCNT", xpincnt_prefix,
|
||||
xpincnt_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)
|
||||
return;
|
||||
|
||||
break;
|
||||
case OFONO_VENDOR_ZTE:
|
||||
if (g_at_chat_send(sd->chat, "AT+ZPINPUK=?", zpinpuk_prefix,
|
||||
zpinpuk_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
break;
|
||||
case OFONO_VENDOR_MBM:
|
||||
if (g_at_chat_send(sd->chat, "AT*EPIN?", epin_prefix,
|
||||
at_epin_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
break;
|
||||
default:
|
||||
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
|
||||
|
|
Loading…
Reference in New Issue