Skip to contentSkip to conversation

emulator: add AT+BIA support for HFP

PATCH In review Frédéric Danis 2 participants 8 messages Aug 31, 2011 – Sep 8, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 emulator: add AT+BIA support for HFP

---
 src/emulator.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 73 insertions(+), 10 deletions(-)
src/emulator.c +73 -10
index 06ec06c..a907b12 100644
@@ -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);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/4 include: update HFP features types to version 1.6

---
 include/types.h |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
include/types.h +6 -4
index 536dac7..0a3b72c 100644
@@ -115,7 +115,7 @@ struct ofono_uuid {
 	unsigned char uuid[OFONO_SHA1_UUID_LEN];
 };
 
-/* HFP AG supported features bitmap. Bluetooth HFP 1.5 spec page 77 */
+/* HFP AG supported features bitmap. Bluetooth HFP 1.6 spec page 88 */
 enum hfp_ag_feature {
 	HFP_AG_FEATURE_3WAY =			0x1,
 	HFP_AG_FEATURE_ECNR =			0x2,
@@ -125,10 +125,11 @@ enum hfp_ag_feature {
 	HFP_AG_FEATURE_REJECT_CALL =		0x20,
 	HFP_AG_FEATURE_ENHANCED_CALL_STATUS =	0x40,
 	HFP_AG_FEATURE_ENHANCED_CALL_CONTROL =	0x80,
-	HFP_AG_FEATURE_EXTENDED_RES_CODE =	0x100
+	HFP_AG_FEATURE_EXTENDED_RES_CODE =	0x100,
+	HFP_AG_FEATURE_CODEC_NEGOTIATION =	0x200
 };
 
-/* HFP HF supported features bitmap. Bluetooth HFP 1.5 spec page 77 */
+/* HFP HF supported features bitmap. Bluetooth HFP 1.6 spec page 88 */
 enum hfp_hf_feature {
 	HFP_HF_FEATURE_ECNR =			0x1,
 	HFP_HF_FEATURE_3WAY =			0x2,
@@ -136,7 +137,8 @@ enum hfp_hf_feature {
 	HFP_HF_FEATURE_VOICE_RECOGNITION =	0x8,
 	HFP_HF_FEATURE_REMOTE_VOLUME_CONTROL =	0x10,
 	HFP_HF_FEATURE_ENHANCED_CALL_STATUS =	0x20,
-	HFP_HF_FEATURE_ENHANCED_CALL_CONTROL =	0x40
+	HFP_HF_FEATURE_ENHANCED_CALL_CONTROL =	0x40,
+	HFP_HF_FEATURE_CODEC_NEGOTIATION =	0x80
 };
 
 const char *ofono_uuid_to_str(const struct ofono_uuid *uuid);
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/4 hfp_ag: update SDP record to version 1.6

In reply to Frédéric Danis
---
 plugins/hfp_ag.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/hfp_ag.c +1 -1
index dc65fde..96230fc 100644
@@ -68,7 +68,7 @@ static const gchar *hfp_ag_record =
 "    <sequence>\n"
 "      <sequence>\n"
 "        <uuid value=\"0x111E\"/>\n"
-"        <uint16 value=\"0x0105\" name=\"version\"/>\n"
+"        <uint16 value=\"0x0106\" name=\"version\"/>\n"
 "      </sequence>\n"
 "    </sequence>\n"
 "  </attribute>\n"
Signature · 1 line
1.7.1
#5 lore raw

PATCH 4/4 TODO: mark HFP AG 1.6 indicator activation as done

In reply to Frédéric Danis
---
 TODO             |    7 -------
 doc/features.txt |    8 ++++----
 2 files changed, 4 insertions(+), 11 deletions(-)
TODO +0 -7
index 516d325..5672259 100644
@@ -148,13 +148,6 @@ Modem Emulator
   Complexity: C4
   Priority: Medium
 
-- Support new HFP 1.6 AG command related to indicators (AT+BIA).
-
-  Complexity: C1
-  Priority: Low
-  Owner: Frédéric Danis <[email protected]>
-  Depends: HFP AG emulator
-
 - Support new HFP 1.6 AG commands allowing to publish, select and connect audio
   codecs (AT+BAC, AT+BCS, +BCS, AT+BCC). This will need to interact with audio
   framework.
doc/features.txt +4 -4
index b8bcdb1..ad4d176 100644
@@ -675,11 +675,11 @@ Modem Emulator
 ==============
 
 - Support for Bluetooth HandsFree Profile Audio Gateway (HFP AG).  oFono
-  supports the underlying AT command protocol specified by BT HFP version 1.5.
+  supports the underlying AT command protocol specified by BT HFP version 1.6.
   Supported features include 3-way calling, ability to reject a call,
-  enhanced call status, enhanced call control and report of extended error
-  results code.  Audio management is assumed to be performed in another system
-  component, e.g. PulseAudio.
+  enhanced call status, enhanced call control, report of extended error results
+  code and indicator activation. Audio management is assumed to be performed in
+  another system component, e.g. PulseAudio.
 
 - Support for Bluetooth DUN profile.  oFono supports the Dial Up Networking
   profile and all mandatory commands specified by BT DUN 1.1.  For a list
Signature · 1 line
1.7.1
#7 lore raw
In reply to Frédéric Danis

Hi Frédéric,

Quoted 4 lines · Frédéric Danis
---
 src/emulator.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 73 insertions(+), 10 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis

#2 lore raw

Re: [PATCH 2/4] include: update HFP features types to version 1.6

In reply to Frédéric Danis

Hi Frédéric,

Quoted 4 lines · Frédéric Danis
---
 include/types.h |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis

#6 lore raw

Re: [PATCH 4/4] TODO: mark HFP AG 1.6 indicator activation as done

In reply to Frédéric Danis

Hi Frédéric,

Quoted 5 lines · Frédéric Danis
---
 TODO             |    7 -------
 doc/features.txt |    8 ++++----
 2 files changed, 4 insertions(+), 11 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis

#4 lore raw

Re: [PATCH 3/4] hfp_ag: update SDP record to version 1.6

In reply to Frédéric Danis

Hi Frédéric,

Quoted 4 lines · Frédéric Danis
---
 plugins/hfp_ag.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

As discussed on IRC, I'm holding off on this one for now.

Regards,
-Denis