All of lore.kernel.org
 help / color / mirror / Atom feed
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/4] emulator: add AT+BIA support for HFP
Date: Wed, 31 Aug 2011 17:21:30 +0200	[thread overview]
Message-ID: <1314804093-12504-1-git-send-email-frederic.danis@linux.intel.com> (raw)

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

---
 src/emulator.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 73 insertions(+), 10 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 06ec06c..a907b12 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -60,6 +60,8 @@ struct indicator {
 	int min;
 	int max;
 	gboolean deferred;
+	gboolean active;
+	gboolean mandatory;
 };
 
 static void emulator_debug(const char *str, void *data)
@@ -360,7 +362,8 @@ static void notify_deferred_indicators(GAtServer *server, void *user_data)
 		if (!ind->deferred)
 			continue;
 
-		if (em->events_mode == 3 && em->events_ind && em->slc) {
+		if (em->events_mode == 3 && em->events_ind && em->slc &&
+				ind->active) {
 			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
 			g_at_server_send_unsolicited(em->server, buf);
 		}
@@ -783,8 +786,60 @@ fail:
 	}
 }
 
+static void bia_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+	{
+		GAtResultIter iter;
+		GSList *l;
+		struct indicator *ind;
+		int val;
+
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		/* check validity of the request */
+		while (g_at_result_iter_next_number_default(&iter, 0, &val)) {
+			if (val != 0 &&  val != 1)
+				goto fail;
+		}
+
+		if (g_at_result_iter_skip_next(&iter))
+			goto fail;
+
+		/* request is valid, update the indicator activation status */
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		for (l = em->indicators; l; l = l->next) {
+			ind = l->data;
+
+			if (!g_at_result_iter_next_number_default(&iter,
+							ind->active, &val))
+				break;
+
+			if (!ind->mandatory)
+				ind->active = val;
+		}
+
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+	}
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
-					int min, int max, int dflt)
+					int min, int max, int dflt,
+					gboolean mandatory)
 {
 	struct indicator *ind;
 
@@ -798,6 +853,8 @@ static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 	ind->min = min;
 	ind->max = max;
 	ind->value = dflt;
+	ind->active = TRUE;
+	ind->mandatory = mandatory;
 
 	em->indicators = g_slist_append(em->indicators, ind);
 }
@@ -860,15 +917,20 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 						em);
 
 	if (em->type == OFONO_EMULATOR_TYPE_HFP) {
-		emulator_add_indicator(em, OFONO_EMULATOR_IND_SERVICE, 0, 1, 0);
-		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALL, 0, 1, 0);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_SERVICE, 0, 1, 0,
+									FALSE);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALL, 0, 1, 0,
+									TRUE);
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, 0, 3,
-									0);
+								0, TRUE);
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_CALLHELD, 0, 2,
-									0);
-		emulator_add_indicator(em, OFONO_EMULATOR_IND_SIGNAL, 0, 5, 0);
-		emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0);
-		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
+								0, TRUE);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_SIGNAL, 0, 5, 0,
+									FALSE);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0,
+									FALSE);
+		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5,
+									FALSE);
 
 		g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
 		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
@@ -876,6 +938,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		g_at_server_register(em->server, "+CLIP", clip_cb, em, NULL);
 		g_at_server_register(em->server, "+CCWA", ccwa_cb, em, NULL);
 		g_at_server_register(em->server, "+CMEE", cmee_cb, em, NULL);
+		g_at_server_register(em->server, "+BIA", bia_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);
@@ -1149,7 +1212,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 	if (waiting)
 		notify_ccwa(em);
 
-	if (em->events_mode == 3 && em->events_ind && em->slc) {
+	if (em->events_mode == 3 && em->events_ind && em->slc && ind->active) {
 		if (!g_at_server_command_pending(em->server)) {
 			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
 			g_at_server_send_unsolicited(em->server, buf);
-- 
1.7.1


             reply	other threads:[~2011-08-31 15:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 15:21 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-08-31 15:21 ` [PATCH 2/4] include: update HFP features types to version 1.6 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-09-08  8:45   ` Denis Kenzior
2011-08-31 15:21 ` [PATCH 3/4] hfp_ag: update SDP record " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-09-08  8:46   ` Denis Kenzior
2011-08-31 15:21 ` [PATCH 4/4] TODO: mark HFP AG 1.6 indicator activation as done =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-09-08  8:45   ` Denis Kenzior
2011-09-08  8:45 ` [PATCH 1/4] emulator: add AT+BIA support for HFP Denis Kenzior

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=1314804093-12504-1-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.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 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.