Open Source Telephony
 help / color / mirror / Atom feed
From: Yang Gu <yang.gu@intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/2] stk: provide access technology info
Date: Thu, 18 Nov 2010 18:55:55 +0800	[thread overview]
Message-ID: <1290077756-28124-2-git-send-email-yang.gu@intel.com> (raw)
In-Reply-To: <1290077756-28124-1-git-send-email-yang.gu@intel.com>

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

---
 src/network.c |   14 +++++
 src/ofono.h   |    1 +
 src/stk.c     |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 0 deletions(-)

diff --git a/src/network.c b/src/network.c
index f1d7724..481ece8 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1852,3 +1852,17 @@ void *ofono_netreg_get_data(struct ofono_netreg *netreg)
 {
 	return netreg->driver_data;
 }
+
+unsigned int __ofono_netreg_get_tech(struct ofono_netreg *netreg)
+{
+	GSList *o;
+	unsigned int techs = 0;
+	struct network_operator_data *opd;
+
+	for (o = netreg->operator_list; o; o = o->next) {
+		opd = o->data;
+		techs |= opd->techs;
+	}
+
+	return techs;
+}
diff --git a/src/ofono.h b/src/ofono.h
index 4d76d20..c9d25ab 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -363,6 +363,7 @@ gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
 
 void __ofono_netreg_set_base_station_name(struct ofono_netreg *netreg,
 						const char *name);
+unsigned int __ofono_netreg_get_tech(struct ofono_netreg *netreg);
 
 #include <ofono/history.h>
 
diff --git a/src/stk.c b/src/stk.c
index 18beee6..eec1ddf 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -1989,6 +1989,180 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
 	return TRUE;
 }
 
+static gboolean get_tech(struct ofono_stk *stk, struct stk_response *rsp,
+							gboolean singleton)
+{
+	struct ofono_atom *atom;
+	struct ofono_netreg *netreg;
+	unsigned int tech;
+	unsigned int tech_stk = 0;
+	unsigned int i;
+	int length = 0;
+	int length_temp = 0;
+	enum stk_access_technology_type *techs;
+	static struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE };
+
+	atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
+							OFONO_ATOM_TYPE_NETREG);
+	if (!atom || !__ofono_atom_get_registered(atom))
+		goto error;
+
+	netreg = __ofono_atom_get_data(atom);
+	tech = __ofono_netreg_get_tech(netreg);
+
+	if (tech == 0)
+		goto error;
+
+	/* Stk has different definition of access technology, so do some map */
+	if (tech & ((1 << ACCESS_TECHNOLOGY_GSM) ||
+			(1 << ACCESS_TECHNOLOGY_GSM_COMPACT) ||
+			(1 << ACCESS_TECHNOLOGY_GSM_EGPRS))) {
+		tech_stk |= 1 << STK_ACCESS_TECHNOLOGY_GSM;
+		length++;
+
+		if (singleton && (length == 1))
+			goto finish;
+	}
+
+	if (tech & ((1 << ACCESS_TECHNOLOGY_UTRAN) ||
+			(1 << ACCESS_TECHNOLOGY_UTRAN_HSDPA) ||
+			(1 << ACCESS_TECHNOLOGY_UTRAN_HSUPA) ||
+			(1 << ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA))) {
+		tech_stk |= 1 << STK_ACCESS_TECHNOLOGY_UTRAN;
+		length++;
+
+		if (singleton && (length == 1))
+			goto finish;
+	}
+
+	if (tech & (1 << ACCESS_TECHNOLOGY_EUTRAN)) {
+		tech_stk |= 1 << STK_ACCESS_TECHNOLOGY_EUTRAN;
+		length++;
+	}
+
+finish:
+	if (length == 0)
+		goto error;
+
+	techs = g_try_malloc(length);
+	if (!techs)
+		goto error;
+
+	for (i = 0; i < sizeof(tech_stk) * 8; i++)
+		if (tech_stk & (1 << i))
+			techs[length_temp++] = i;
+
+	rsp->provide_local_info.access_technologies.techs = techs;
+	rsp->provide_local_info.access_technologies.length = length;
+	rsp->result.type = STK_RESULT_TYPE_SUCCESS;
+
+	if (stk_respond(stk, rsp, stk_command_cb))
+		stk_command_cb(&error, stk);
+
+	g_free(techs);
+	return FALSE;
+
+error:
+	rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+	return TRUE;
+}
+
+static gboolean handle_command_provide_local_info(const struct stk_command *cmd,
+				struct stk_response *rsp, struct ofono_stk *stk)
+{
+	switch (cmd->qualifier) {
+	case 0:
+		DBG("Location Information");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 1:
+		DBG("IMEI");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 2:
+		DBG("Network Measurement results");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 3:
+		DBG("Date, time and time zone");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 4:
+		DBG("Language setting");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 5:
+		DBG("Timing Advance");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 6:
+		DBG("Access Technology");
+		return get_tech(stk, rsp, TRUE);
+
+	case 7:
+		DBG("ESN");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 8:
+		DBG("IMEISV");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 9:
+		DBG("Search Mode");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 10:
+		DBG("Charge State of the Battery");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 11:
+		DBG("MEID");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 12:
+		DBG("current WSID");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 13:
+		DBG("Broadcast Network information");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 14:
+		DBG("Multiple Access Technologies");
+		return get_tech(stk, rsp, FALSE);
+
+	case 15:
+		DBG("Location Information for multiple access technologies");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	case 16:
+		DBG("Network Measurement results for "
+					"multiple access technologies");
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+
+	default:
+		ofono_info("Undefined Provide Local Information qualifier: %d",
+				cmd->qualifier);
+		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+		return TRUE;
+	}
+}
+
 static void send_dtmf_cancel(struct ofono_stk *stk)
 {
 	struct ofono_voicecall *vc = NULL;
@@ -2421,6 +2595,11 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
 							&rsp, stk);
 		break;
 
+	case STK_COMMAND_TYPE_PROVIDE_LOCAL_INFO:
+		respond = handle_command_provide_local_info(stk->pending_cmd,
+								&rsp, stk);
+		break;
+
 	case STK_COMMAND_TYPE_SEND_DTMF:
 		respond = handle_command_send_dtmf(stk->pending_cmd,
 							&rsp, stk);
-- 
1.7.2.3


  reply	other threads:[~2010-11-18 10:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 10:55 [PATCH 0/2] Provide Local Information Yang Gu
2010-11-18 10:55 ` Yang Gu [this message]
2010-11-18 13:36   ` [PATCH 1/2] stk: provide access technology info Jeevaka.Badrappan
2010-11-19  6:04     ` Gu, Yang
2010-11-19  7:17       ` Rajesh.Nagaiah
2010-11-19  7:27         ` Gu, Yang
2010-11-18 10:55 ` [PATCH 2/2] network: Use bit as size instead of byte Yang Gu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290077756-28124-2-git-send-email-yang.gu@intel.com \
    --to=yang.gu@intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox