mirror of git://git.sysmocom.de/ofono
sim: Add SIMCOM specific PIN retry handling
Use AT+SPIC for obtaining retries remaining for SIM PIN / PUK AT+SPIC Retries Remaining to Input SIM PIN/PUK +SPIC: <pin1>,<pin2>,<puk1>,<puk2> Parameters <pin1> Times remained to input chv1 <pin2> Times remained to input chv2 <puk1> Times remained to input puk1 <puk2> Times remained to input puk2
This commit is contained in:
parent
1a5895f428
commit
409b0f01b6
|
@ -62,6 +62,7 @@ static const char *zpinpuk_prefix[] = { "+ZPINPUK:", NULL };
|
||||||
static const char *oercn_prefix[] = { "_OERCN:", NULL };
|
static const char *oercn_prefix[] = { "_OERCN:", NULL };
|
||||||
static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
|
static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
|
||||||
static const char *epin_prefix[] = { "*EPIN:", NULL };
|
static const char *epin_prefix[] = { "*EPIN:", NULL };
|
||||||
|
static const char *spic_prefix[] = { "+SPIC:", NULL };
|
||||||
static const char *none_prefix[] = { NULL };
|
static const char *none_prefix[] = { NULL };
|
||||||
|
|
||||||
static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
|
@ -800,6 +801,45 @@ static void at_cpinr_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
cb(&error, retries, cbd->data);
|
cb(&error, retries, cbd->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void at_spic_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, "+SPIC:"))
|
||||||
|
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 at_pin_retries_query(struct ofono_sim *sim,
|
static void at_pin_retries_query(struct ofono_sim *sim,
|
||||||
ofono_sim_pin_retries_cb_t cb,
|
ofono_sim_pin_retries_cb_t cb,
|
||||||
void *data)
|
void *data)
|
||||||
|
@ -840,6 +880,11 @@ static void at_pin_retries_query(struct ofono_sim *sim,
|
||||||
at_epin_cb, cbd, g_free) > 0)
|
at_epin_cb, cbd, g_free) > 0)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
case OFONO_VENDOR_SIMCOM:
|
||||||
|
if (g_at_chat_send(sd->chat, "AT+SPIC", spic_prefix,
|
||||||
|
at_spic_cb, cbd, g_free) > 0)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
|
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
|
||||||
at_cpinr_cb, cbd, g_free) > 0)
|
at_cpinr_cb, cbd, g_free) > 0)
|
||||||
|
|
Loading…
Reference in New Issue