gemalto: add PIN retries support
PATCH 1/1 gemalto: add PIN retries support
From 4157f3e7aa0eb16eec0b1ccf87946ecf53539090 Mon Sep 17 00:00:00 2001
From: Gabriel Lucas <[email protected]>
Date: Tue, 24 Oct 2017 11:15:58 +0200
Subject: [PATCH] gemalto: add PIN retries support
In SimManager, the Retries property isn't used for gemalto modems. The at command AT^SPIC is used to get the remaining retries left for the current required password type.
This commit adds the implementation in the SIM driver of the retries queries.
--- drivers/atmodem/sim.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ plugins/gemalto.c | 3 ++- 2 files changed, 47 insertions(+), 1 deletion(-)
drivers/atmodem/sim.c +1 -0
@@ -70,6 +70,7 @@ static const char *pct_prefix[] = { "#PCT:", NULL };static const char *pnnm_prefix[] = {"+PNNM:" ,NULL };static const char *qpinc_prefix[] = {"+QPINC:" ,NULL };static const char *upincnt_prefix[] = {"+UPINCNT:" ,NULL }; +static const char *spic_prefix[] = {"^SPIC:" ,NULL };static const char *none_prefix[] = {NULL }; static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer
user_data)
@@ -1054,6 +1055,45 @@ error:
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
+static void spic_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data; + struct ofono_sim *sim = cbd->user; + 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; + int pin_type = ofono_sim_get_password_type(sim);
+
+ decode_at_error(&error, final);
+
+ if (!ok) {
+ cb(&error, NULL, cbd->data);
+ return;
+ }
+
+ for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
+ retries[i] = -1;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "^SPIC:"))
+ goto error;
+
+ if (!g_at_result_iter_next_number(&iter, &retries[pin_type]))
+ goto error;
+
+ DBG("Retry : %d, type : %d", retries[pin_type], pin_type);
+ cb(&error, retries, cbd->data);
+
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
+}
+
static void at_pin_retries_query(struct ofono_sim *sim,
ofono_sim_pin_retries_cb_t cb, void *data)
@@ -1126,6 +1166,11 @@ static void at_pin_retries_query(struct ofono_sim *sim,
upincnt_cb, cbd, g_free) > 0)
return;
break;+ case OFONO_VENDOR_CINTERION:
+ if (g_at_chat_send(sd->chat, "AT^SPIC", spic_prefix,
+ spic_cb, cbd, g_free) > 0)
+ return;
+ break;
default:
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
at_cpinr_cb, cbd, g_free) > 0)plugins/gemalto.c +0 -0
@@ -420,7 +420,8 @@ static void gemalto_pre_sim(struct ofono_modem
*modem)
ofono_devinfo_create(modem, 0, "atmodem", data->app); ofono_location_reporting_create(modem, 0, "gemaltomodem",data->app);
- sim = ofono_sim_create(modem, 0, "atmodem", data->app);
+ sim = ofono_sim_create(modem, OFONO_VENDOR_CINTERION, "atmodem",
+ data->app);
if (sim && data->have_sim == TRUE)
ofono_sim_inserted_notify(sim, TRUE);Signature · 1 line
1.9.1
Hi Gabriel,
Quoted 10 lines · Gabriel LUCAS
From
4157f3e7aa0eb16eec0b1ccf87946ecf53539090Mon Sep 17 00:00:00 2001
From: Gabriel Lucas <[email protected]>
Date: Tue, 24 Oct 2017 11:15:58 +0200
Subject: [PATCH] gemalto: add PIN retries supportSigned-off-by Gabriel Lucas <[email protected]>In SimManager, the Retries property isn't used for gemalto modems. The at command AT^SPIC is used to get the remaining retries left for the current required password type.
Quoted 6 lines
This commit adds the implementation in the SIM driver of the retries queries.
--- drivers/atmodem/sim.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ plugins/gemalto.c | 3 ++- 2 files changed, 47 insertions(+), 1 deletion(-)
This patch doesn't apply. It looks like whitespace is corrupted, tabs switched to spaces, etc. Are you using Microsoft products by any chance?
Quoted 78 lines
drivers/atmodem/sim.c +1
-0@@ -70,6 +70,7 @@ static const char *pct_prefix[] = { "#PCT:", NULL }; static const char *pnnm_prefix[] = { "+PNNM:", NULL }; static const char *qpinc_prefix[] = { "+QPINC:", NULL }; static const char *upincnt_prefix[] = { "+UPINCNT:", NULL }; +static const char *spic_prefix[] = {"^SPIC:" ,NULL }; static const char *none_prefix[] = { NULL }; static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer
user_data)drivers/atmodem/sim.c +44
-0@@ -1054,6 +1055,45 @@ error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); } +static void spic_cb (gboolean ok,GAtResult *result,gpointer user_data) +{ + struct cb_data *cbd = user_data; + struct ofono_sim *sim = cbd->user; + 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; + int pin_type = ofono_sim_get_password_type(sim); + + decode_at_error(&error, final); + + if (!ok) { + cb(&error, NULL, cbd->data); + return; + } + + for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++) + retries[i] = -1; + + g_at_result_iter_init(&iter, result); + + if (!g_at_result_iter_next(&iter, "^SPIC:")) + goto error; + + if (!g_at_result_iter_next_number(&iter, &retries[pin_type])) + goto error; + + DBG("Retry : %d, type : %d", retries[pin_type], pin_type); + cb(&error, retries, cbd->data); + + return; + +error: + CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); +} + static void at_pin_retries_query(struct ofono_sim *sim, ofono_sim_pin_retries_cb_t cb, void *data)@@ -1126,6 +1166,11 @@ static void at_pin_retries_query(struct ofono_sim *sim, upincnt_cb, cbd, g_free) > 0) return; break; + case OFONO_VENDOR_CINTERION: + if (g_at_chat_send(sd->chat, "AT^SPIC", spic_prefix, + spic_cb, cbd, g_free) > 0) + return; + break; default: if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
at_cpinr_cb, cbd,g_free) > 0)plugins/gemalto.c +0
-0
plugins/gemalto.c static void gemalto_pre_sim(struct ofono_modem *modem) · line 427
Quoted 9 lines
plugins/gemalto.c +2
-1@@ -420,7 +420,8 @@ static void gemalto_pre_sim(struct ofono_modem *modem) ofono_devinfo_create(modem, 0, "atmodem", data->app); ofono_location_reporting_create(modem, 0, "gemaltomodem", data->app); - sim = ofono_sim_create(modem, 0, "atmodem", data->app); + sim = ofono_sim_create(modem, OFONO_VENDOR_CINTERION, "atmodem", + data->app); if (sim && data->have_sim == TRUE) ofono_sim_inserted_notify(sim, TRUE);
This part should be in a separate commit. See 'HACKING', 'Submitting patches' in ofono git.
Regards,
-Denis
Hi Denis,
Quoted 3 lines
This patch doesn't apply. It looks like whitespace is corrupted, tabs switched to spaces, etc. Are you using Microsoft products by any chance?
My bad, I wasn't able to configure git send-email correctly so I've tried
with another email client. Bad idea apparently.
Quoted 2 lines
This part should be in a separate commit. See 'HACKING', 'Submitting patches' in ofono git.
I've sent to the mailist (with git send-email) a new version of patch split in two parts
Regards,
Gabriel