All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] gemalto: add PIN retries support in driver
@ 2017-11-06 13:57 Gabriel Lucas
  2017-11-06 13:57 ` [PATCH v2 2/2] gemalto: add PIN retries support in plugin Gabriel Lucas
  2017-11-06 17:30 ` [PATCH v2 1/2] gemalto: add PIN retries support in driver Denis Kenzior
  0 siblings, 2 replies; 6+ messages in thread
From: Gabriel Lucas @ 2017-11-06 13:57 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2535 bytes --]

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 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 7508281..f593a51 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -74,6 +74,7 @@ static const char *upincnt_prefix[] = { "+UPINCNT:", NULL };
 static const char *cuad_prefix[] = { "+CUAD:", NULL };
 static const char *ccho_prefix[] = { "+CCHO:", NULL };
 static const char *crla_prefix[] = { "+CRLA:", NULL };
+static const char *spic_prefix[] = { "^SPIC:", NULL };
 static const char *none_prefix[] = { NULL };
 
 static void append_file_path(char *buf, const unsigned char *path,
@@ -1065,6 +1066,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)
@@ -1137,6 +1177,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)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] gemalto: add PIN retries support in plugin
  2017-11-06 13:57 [PATCH v2 1/2] gemalto: add PIN retries support in driver Gabriel Lucas
@ 2017-11-06 13:57 ` Gabriel Lucas
  2017-11-07 15:59   ` Denis Kenzior
  2017-11-06 17:30 ` [PATCH v2 1/2] gemalto: add PIN retries support in driver Denis Kenzior
  1 sibling, 1 reply; 6+ messages in thread
From: Gabriel Lucas @ 2017-11-06 13:57 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

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 enable the use of the driver in the gemalto plugin
---
 plugins/gemalto.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 45ec0cf..3739d7b 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] gemalto: add PIN retries support in driver
  2017-11-06 13:57 [PATCH v2 1/2] gemalto: add PIN retries support in driver Gabriel Lucas
  2017-11-06 13:57 ` [PATCH v2 2/2] gemalto: add PIN retries support in plugin Gabriel Lucas
@ 2017-11-06 17:30 ` Denis Kenzior
  2017-11-07  9:53   ` Gabriel Lucas
  1 sibling, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2017-11-06 17:30 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1039 bytes --]

Hi Gabriel,

On 11/06/2017 07:57 AM, Gabriel Lucas wrote:
> 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 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 45 insertions(+)
> 

After applying, I get:

drivers/atmodem/sim.c:77:20: error: redefinition of ‘spic_prefix’
  static const char *spic_prefix[] = { "^SPIC:", NULL };
                     ^~~~~~~~~~~
drivers/atmodem/sim.c:69:20: note: previous definition of ‘spic_prefix’ 
was here
  static const char *spic_prefix[] = { "+SPIC:", NULL };
                     ^~~~~~~~~~~
drivers/atmodem/sim.c:69:20: error: ‘spic_prefix’ defined but not used 
[-Werror=unused-variable]
cc1: error: unrecognized command line option ‘-Wno-format-truncation’ 
[-Werror]

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] gemalto: add PIN retries support in driver
  2017-11-06 17:30 ` [PATCH v2 1/2] gemalto: add PIN retries support in driver Denis Kenzior
@ 2017-11-07  9:53   ` Gabriel Lucas
  2017-11-07 15:59     ` Denis Kenzior
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel Lucas @ 2017-11-07  9:53 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2555 bytes --]

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 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 7508281..f593a51 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -74,6 +74,7 @@ static const char *upincnt_prefix[] = { "+UPINCNT:", NULL };
 static const char *cuad_prefix[] = { "+CUAD:", NULL };
 static const char *ccho_prefix[] = { "+CCHO:", NULL };
 static const char *crla_prefix[] = { "+CRLA:", NULL };
+static const char *cinterion_spic_prefix[] = { "^SPIC:", NULL };
 static const char *none_prefix[] = { NULL };
 
 static void append_file_path(char *buf, const unsigned char *path,
@@ -1065,6 +1066,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)
@@ -1137,6 +1177,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", cinterion_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)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] gemalto: add PIN retries support in driver
  2017-11-07  9:53   ` Gabriel Lucas
@ 2017-11-07 15:59     ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2017-11-07 15:59 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

Hi Gabriel,

On 11/07/2017 03:53 AM, Gabriel Lucas wrote:
> 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 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 45 insertions(+)
> 

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] gemalto: add PIN retries support in plugin
  2017-11-06 13:57 ` [PATCH v2 2/2] gemalto: add PIN retries support in plugin Gabriel Lucas
@ 2017-11-07 15:59   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2017-11-07 15:59 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

Hi Gabriel,

On 11/06/2017 07:57 AM, Gabriel Lucas wrote:
> 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 enable the use of the driver in the gemalto plugin
> ---
>   plugins/gemalto.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-07 15:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 13:57 [PATCH v2 1/2] gemalto: add PIN retries support in driver Gabriel Lucas
2017-11-06 13:57 ` [PATCH v2 2/2] gemalto: add PIN retries support in plugin Gabriel Lucas
2017-11-07 15:59   ` Denis Kenzior
2017-11-06 17:30 ` [PATCH v2 1/2] gemalto: add PIN retries support in driver Denis Kenzior
2017-11-07  9:53   ` Gabriel Lucas
2017-11-07 15:59     ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.