From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0303644765007237262==" MIME-Version: 1.0 From: Marcel Holtmann Subject: Re: [PATCH] atmodem: implement standard PIN retries Date: Mon, 31 Jan 2011 13:59:50 +0100 Message-ID: <1296478790.1520.212.camel@aeonflux> In-Reply-To: <1296478100-24306-1-git-send-email-remi.denis-courmont@nokia.com> List-Id: To: ofono@ofono.org --===============0303644765007237262== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Remi, > drivers/atmodem/sim.c | 48 +++++++++++++++++++++++++++++++++++++++++++= +++++ > 1 files changed, 48 insertions(+), 0 deletions(-) > = > diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c > index 0938998..dfd40f8 100644 > --- a/drivers/atmodem/sim.c > +++ b/drivers/atmodem/sim.c > @@ -57,6 +57,7 @@ static const char *cpin_prefix[] =3D { "+CPIN:", NULL }; > static const char *clck_prefix[] =3D { "+CLCK:", NULL }; > static const char *huawei_cpin_prefix[] =3D { "^CPIN:", NULL }; > static const char *xpincnt_prefix[] =3D { "+XPINCNT:", NULL }; > +static const char *cpinr_prefixes[] =3D { "+CPINR:", "+CPINRE:", NULL }; if you are not processing +CPINRE, why bother consuming it in the first place? > static const char *none_prefix[] =3D { NULL }; > = > static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer use= r_data) > @@ -554,6 +555,50 @@ error: > CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); > } > = > +static void at_cpinr_cb(gboolean ok, GAtResult *result, gpointer user_da= ta) > +{ > + struct cb_data *cbd =3D user_data; > + ofono_sim_pin_retries_cb_t cb =3D cbd->cb; > + GAtResultIter iter; > + struct ofono_error error; > + int retries[OFONO_SIM_PASSWORD_INVALID]; > + size_t len =3D sizeof(at_sim_name) / sizeof(*at_sim_name); > + size_t i; > + > + decode_at_error(&error, g_at_result_final_response(result)); > + > + if (!ok) { > + cb(&error, NULL, cbd->data); > + return; > + } > + > + for (i =3D 0; i < OFONO_SIM_PASSWORD_INVALID; i++) > + retries[i] =3D -1; > + > + g_at_result_iter_init(&iter, result); > + > + /* Ignore +CPINRE results... */ > + while (g_at_result_iter_next(&iter, "+CPINR:")) { > + const char *name; > + int val; > + > + if (!g_at_result_iter_next_unquoted_string(&iter, &name)) > + continue; > + > + if (!g_at_result_iter_next_number(&iter, &val)) > + continue; > + > + for (i =3D 1; i < len; i++) { > + if (!strcmp(name, at_sim_name[i].name)) { > + retries[i] =3D val; > + break; > + } > + } > + } > + > + cb(&error, retries, cbd->data); > +} > + > static void at_pin_retries_query(struct ofono_sim *sim, > ofono_sim_pin_retries_cb_t cb, > void *data) > @@ -577,6 +622,9 @@ static void at_pin_retries_query(struct ofono_sim *si= m, > = > break; > default: > + if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes, > + at_cpinr_cb, cbd, g_free) > 0) > + return; since this command is pretty new, don't we need to check if it is supported? Is there any impact not checking it? Regards Marcel --===============0303644765007237262==--