All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] add ifx support for querying remaining pin entries
@ 2011-01-19 14:03 Jeevaka Badrappan
  2011-01-19 14:03 ` [PATCH v3 1/2] atutil: add pin retry count parser function Jeevaka Badrappan
  2011-01-19 14:03 ` [PATCH v3 2/2] atmodem: add ifx support for pin retries query Jeevaka Badrappan
  0 siblings, 2 replies; 3+ messages in thread
From: Jeevaka Badrappan @ 2011-01-19 14:03 UTC (permalink / raw)
  To: ofono

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

Hi,

 Following patch adds ifx support for querying remaining pin entries.
This patch also introduces a utility function for parsing the pin retry
count at command result.

Regards,
Jeevaka

Jeevaka Badrappan (2):
  atutil: add pin retry count parser function
  atmodem: add ifx support for pin retries query

 drivers/atmodem/atutil.c |   66 ++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/atutil.h |    3 ++
 drivers/atmodem/sim.c    |   79 ++++++++++++++-------------------------------
 3 files changed, 94 insertions(+), 54 deletions(-)


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

* [PATCH v3 1/2] atutil: add pin retry count parser function
  2011-01-19 14:03 [PATCH v3 0/2] add ifx support for querying remaining pin entries Jeevaka Badrappan
@ 2011-01-19 14:03 ` Jeevaka Badrappan
  2011-01-19 14:03 ` [PATCH v3 2/2] atmodem: add ifx support for pin retries query Jeevaka Badrappan
  1 sibling, 0 replies; 3+ messages in thread
From: Jeevaka Badrappan @ 2011-01-19 14:03 UTC (permalink / raw)
  To: ofono

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

---
 drivers/atmodem/atutil.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/atmodem/atutil.h |    3 ++
 2 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index da17253..8edcd02 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -31,6 +31,8 @@
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include <ofono/log.h>
 #include <ofono/types.h>
+#include <ofono/modem.h>
+#include <ofono/sim.h>
 
 #include "atutil.h"
 #include "vendor.h"
@@ -480,3 +482,67 @@ gboolean at_util_parse_attr(GAtResult *result, const char *prefix,
 
 	return TRUE;
 }
+
+gboolean at_util_parse_pin_retries(GAtResult *result, int *retries,
+					int retries_cnt, unsigned int vendor)
+{
+	GAtResultIter iter;
+	enum ofono_sim_password_type passwd_types[OFONO_SIM_PASSWORD_INVALID];
+	int i;
+	int passwd_types_cnt;
+
+	g_at_result_iter_init(&iter, result);
+
+	switch (vendor) {
+	case OFONO_VENDOR_HUAWEI:
+		if (!g_at_result_iter_next(&iter, "^CPIN:"))
+			return FALSE;
+
+		/* Skip status since we are not interested in this */
+		if (!g_at_result_iter_skip_next(&iter))
+			return FALSE;
+
+		/*
+		 * Skip "overall counter" since we'll grab each one
+		 * individually.
+		 */
+		if (!g_at_result_iter_skip_next(&iter))
+			return FALSE;
+
+		passwd_types[0] = OFONO_SIM_PASSWORD_SIM_PUK;
+		passwd_types[1] = OFONO_SIM_PASSWORD_SIM_PIN;
+		passwd_types[2] = OFONO_SIM_PASSWORD_SIM_PUK2;
+		passwd_types[3] = OFONO_SIM_PASSWORD_SIM_PIN2;
+		passwd_types_cnt = 4;
+		break;
+	case OFONO_VENDOR_IFX:
+		if (!g_at_result_iter_next(&iter, "+XPINCNT:"))
+			return FALSE;
+
+		passwd_types[0] = OFONO_SIM_PASSWORD_SIM_PIN;
+		passwd_types[1] = OFONO_SIM_PASSWORD_SIM_PIN2;
+		passwd_types[2] = OFONO_SIM_PASSWORD_SIM_PUK;
+		passwd_types[3] = OFONO_SIM_PASSWORD_SIM_PUK2;
+		passwd_types_cnt = 4;
+		break;
+	default:
+		return FALSE;
+	}
+
+	for (i = 0; i < retries_cnt; i++)
+		retries[i] = -1;
+
+	for (i = 0; i < passwd_types_cnt; i++) {
+		int val;
+
+		if (!g_at_result_iter_next_number(&iter, &val))
+			return FALSE;
+
+		retries[passwd_types[i]] = val;
+
+		DBG("retry counter id=%d, val=%d", passwd_types[i],
+						retries[passwd_types[i]]);
+	}
+
+	return TRUE;
+}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 3d13b84..a22f4a4 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -74,6 +74,9 @@ gboolean at_util_parse_cscs_query(GAtResult *result,
 gboolean at_util_parse_attr(GAtResult *result, const char *prefix,
 				const char **out_attr);
 
+gboolean at_util_parse_pin_retries(GAtResult *result, int *retries,
+					int retries_cnt, unsigned int vendor);
+
 struct cb_data {
 	void *cb;
 	void *data;
-- 
1.7.0.4


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

* [PATCH v3 2/2] atmodem: add ifx support for pin retries query
  2011-01-19 14:03 [PATCH v3 0/2] add ifx support for querying remaining pin entries Jeevaka Badrappan
  2011-01-19 14:03 ` [PATCH v3 1/2] atutil: add pin retry count parser function Jeevaka Badrappan
@ 2011-01-19 14:03 ` Jeevaka Badrappan
  1 sibling, 0 replies; 3+ messages in thread
From: Jeevaka Badrappan @ 2011-01-19 14:03 UTC (permalink / raw)
  To: ofono

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

This patch also makes use of the helper function
introduce in atutil for parsing the huawei and ifx
pin retry count at command result.
---
 drivers/atmodem/sim.c |   79 +++++++++++++++---------------------------------
 1 files changed, 25 insertions(+), 54 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 8d89d53..73b0178 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -56,6 +56,7 @@ static const char *crsm_prefix[] = { "+CRSM:", NULL };
 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 *none_prefix[] = { NULL };
 
 static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -463,21 +464,14 @@ static struct {
 	{ OFONO_SIM_PASSWORD_PHCORP_PUK,	"PH-CORP PUK"	},
 };
 
-static void huawei_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
+static void pin_retry_cnt_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;
+	struct sim_data *sd = cbd->user;
 	int retries[OFONO_SIM_PASSWORD_INVALID];
-	size_t i;
-	static enum ofono_sim_password_type password_types[] = {
-		OFONO_SIM_PASSWORD_SIM_PUK,
-		OFONO_SIM_PASSWORD_SIM_PIN,
-		OFONO_SIM_PASSWORD_SIM_PUK2,
-		OFONO_SIM_PASSWORD_SIM_PIN2,
-	};
 
 	decode_at_error(&error, final);
 
@@ -486,34 +480,10 @@ static void huawei_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
-	g_at_result_iter_init(&iter, result);
-
-	if (!g_at_result_iter_next(&iter, "^CPIN:"))
-		goto error;
-
-	/* Skip status since we are not interested in this */
-	if (!g_at_result_iter_skip_next(&iter))
-		goto error;
-
-	/* Skip "overall counter" since we'll grab each one individually */
-	if (!g_at_result_iter_skip_next(&iter))
+	if(at_util_parse_pin_retries(result, retries, ARRAY_SIZE(retries),
+					sd->vendor) == FALSE)
 		goto error;
 
-	for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
-		retries[i] = -1;
-
-	for (i = 0; i < ARRAY_SIZE(password_types); i++) {
-		int val;
-
-		if (!g_at_result_iter_next_number(&iter, &val))
-			goto error;
-
-		retries[password_types[i]] = val;
-
-		DBG("retry counter id=%d, val=%d", password_types[i],
-						retries[password_types[i]]);
-	}
-
 	cb(&error, retries, cbd->data);
 
 	return;
@@ -523,39 +493,40 @@ error:
 }
 
 static void at_pin_retries_query(struct ofono_sim *sim,
-				ofono_sim_pin_retries_cb_t cb, void *data)
+					ofono_sim_pin_retries_cb_t cb,
+					void *data)
 {
 	struct sim_data *sd = ofono_sim_get_data(sim);
-	struct cb_data *cbd;
-	int retries[OFONO_SIM_PASSWORD_INVALID];
-	int i;
+	struct cb_data *cbd = cb_data_new(cb, data);
 
 	DBG("");
 
-	switch (sd->vendor) {
-	case OFONO_VENDOR_HUAWEI:
-		cbd = cb_data_new(cb, data);
+	if (cbd == NULL)
+		goto error;
+
+	cbd->user = sd;
 
-		if (cbd == NULL) {
-			CALLBACK_WITH_FAILURE(cb, NULL, data);
+	switch (sd->vendor) {
+	case OFONO_VENDOR_IFX:
+		if (g_at_chat_send(sd->chat, "AT+XPINCNT", xpincnt_prefix,
+					pin_retry_cnt_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)
+					pin_retry_cnt_cb, cbd, g_free) > 0)
 			return;
 
-		g_free(cbd);
-
-		CALLBACK_WITH_FAILURE(cb, NULL, data);
 		break;
-
 	default:
-		for(i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
-			retries[i] = -1;
-
-		CALLBACK_WITH_SUCCESS(cb, retries, data);
+		break;
 	}
+
+error:
+	g_free(cbd);
+
+	CALLBACK_WITH_FAILURE(cb, NULL, data);
 }
 
 static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
-- 
1.7.0.4


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

end of thread, other threads:[~2011-01-19 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 14:03 [PATCH v3 0/2] add ifx support for querying remaining pin entries Jeevaka Badrappan
2011-01-19 14:03 ` [PATCH v3 1/2] atutil: add pin retry count parser function Jeevaka Badrappan
2011-01-19 14:03 ` [PATCH v3 2/2] atmodem: add ifx support for pin retries query Jeevaka Badrappan

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.