All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alok <develnewbie@gmail.com>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] [PATCH] HFP - Audio Gateway Features
Date: Fri, 14 Dec 2007 05:40:33 +0530	[thread overview]
Message-ID: <1197591033.28907.18.camel@greatbear> (raw)
In-Reply-To: <47613E47.10305@access-company.com>

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

Hello, 

Sending a patch for the following : 

1. Added AG's Feature definitions + BRSF response. 

2. Modified headset_send() for variable args. 


Let me know if anything needs to be fixed. 



-Alok Barsode.


[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 5192 bytes --]

diff --git a/audio/headset.c b/audio/headset.c
index e7425d5..ee9a57f 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <signal.h>
 #include <string.h>
 #include <getopt.h>
@@ -64,6 +65,17 @@
 #define HEADSET_GAIN_SPEAKER 'S'
 #define HEADSET_GAIN_MICROPHONE 'M'
 
+#define AG_FEATURE_THREE_WAY_CALLING             0x0001
+#define AG_FEATURE_EC_ANDOR_NR                   0x0002
+#define AG_FEATURE_VOICE_RECOGNITION             0x0004
+#define AG_FEATURE_INBAND_RINGTONE               0x0008
+#define AG_FEATURE_ATTACH_NUMBER_TO_VOICETAG     0x0010
+#define AG_FEATURE_REJECT_A_CALL                 0x0020
+#define AG_FEATURE_ENHANCES_CALL_STATUS          0x0040
+#define AG_FEATURE_ENHANCES_CALL_CONTROL         0x0080
+/*Audio Gateway features.Default is In-band Ringtone*/
+static unsigned int ag_features = AG_FEATURE_INBAND_RINGTONE;
+
 static char *str_state[] = {
 	"HEADSET_STATE_DISCONNECTED",
 	"HEADSET_STATE_CONNECT_IN_PROGRESS",
@@ -120,21 +132,31 @@ struct event {
 static int rfcomm_connect(struct device *device, struct pending_connect *c);
 static int get_handles(struct device *device, struct pending_connect *c);
 
-static int headset_send(struct headset *hs, const char *str)
+static int headset_send(struct headset *hs, char *format, ...)
 {
+	char rsp[BUF_SIZE];
+	va_list ap;
 	GIOError err;
 	gsize total_written, written, count;
+	int er;
+
+	va_start(ap, hs);
+	er = vsnprintf(rsp, sizeof(rsp), format, ap);
+	va_end(ap);
+
+	if (er < 0)
+		return -EINVAL;
 
 	if (hs->state < HEADSET_STATE_CONNECTED || !hs->rfcomm) {
 		error("headset_send: the headset is not connected");
 		return -EIO;
 	}
 
-	count = strlen(str);
+	count = strlen(rsp);
 	written = total_written = 0;
 
 	while (total_written < count) {
-		err = g_io_channel_write(hs->rfcomm, str + total_written,
+		err = g_io_channel_write(hs->rfcomm, rsp + total_written,
 					count - total_written, &written);
 		if (err != G_IO_ERROR_NONE)
 			return -errno;
@@ -150,8 +172,7 @@ static int supported_features(struct device *device, const char *buf)
 	int err;
 
 	hs->hfp_features = strtoul(&buf[8], NULL, 10);
-
-	err = headset_send(hs, "\r\n+BRSF:0\r\n");
+	err = headset_send(hs, "\r\n+BRSF=%u\r\n", ag_features);
 	if (err < 0)
 		return err;
 
@@ -355,7 +376,7 @@ static gboolean rfcomm_io_cb(GIOChannel *chan, GIOCondition cond,
 	err = handle_event(device, &hs->buf[hs->data_start]);
 	if (err < 0)
 		error("Error handling command %s: %s (%d)", &hs->buf[hs->data_start],
-				strerror(-err), -err);
+		      strerror(-err), -err);
 
 	hs->data_start += cmd_len;
 	hs->data_length -= cmd_len;
@@ -1103,8 +1124,11 @@ error:
 static gboolean ring_timer_cb(gpointer data)
 {
 	struct device *device = data;
+	int err;
+
+	err = headset_send(device->headset, "\r\nRING\r\n");
 
-	if (headset_send(device->headset, "\r\nRING\r\n") != G_IO_ERROR_NONE)
+	if (err)
 		error("Sending RING failed");
 
 	return TRUE;
@@ -1116,6 +1140,7 @@ static DBusHandlerResult hs_ring(DBusConnection *conn, DBusMessage *msg,
 	struct device *device = data;
 	struct headset *hs = device->headset;
 	DBusMessage *reply = NULL;
+	int err;
 
 	if (hs->state < HEADSET_STATE_CONNECTED)
 		return error_not_connected(conn, msg);
@@ -1129,7 +1154,8 @@ static DBusHandlerResult hs_ring(DBusConnection *conn, DBusMessage *msg,
 		goto done;
 	}
 
-	if (headset_send(device->headset, "\r\nRING\r\n") != G_IO_ERROR_NONE) {
+	err = headset_send(device->headset, "\r\nRING\r\n");
+	if (err) {
 		dbus_message_unref(reply);
 		return error_failed(conn, msg, "Failed");
 	}
@@ -1261,7 +1287,7 @@ static DBusHandlerResult hs_set_gain(DBusConnection *conn,
 	DBusMessage *reply;
 	DBusError derr;
 	dbus_uint16_t gain;
-	char str[13];
+	int err;
 
 	if (hs->state < HEADSET_STATE_CONNECTED)
 		return error_not_connected(conn, msg);
@@ -1286,10 +1312,8 @@ static DBusHandlerResult hs_set_gain(DBusConnection *conn,
 
 	if (hs->state != HEADSET_STATE_PLAYING)
 		goto done;
-
-	snprintf(str, sizeof(str) - 1, "\r\n+VG%c=%u\r\n", type, gain);
-
-	if (headset_send(device->headset, str) != G_IO_ERROR_NONE) {
+	err = headset_send(device->headset, "\r\n+VG%c=%u\r\n", type, gain);
+	if (err) {
 		dbus_message_unref(reply);
 		return error_failed(conn, msg, "Unable to send to headset");
 	}
@@ -1584,7 +1608,6 @@ int headset_close_rfcomm(struct device *dev)
 void headset_set_state(struct device *dev, headset_state_t state)
 {
 	struct headset *hs = dev->headset;
-	char str[13];
 
 	if (hs->state == state)
 		return;
@@ -1629,17 +1652,11 @@ void headset_set_state(struct device *dev, headset_state_t state)
 						AUDIO_HEADSET_INTERFACE,
 						"Playing", DBUS_TYPE_INVALID);
 
-		if (hs->sp_gain >= 0) {
-			snprintf(str, sizeof(str) - 1, "\r\n+VGS=%u\r\n",
-				hs->sp_gain);
-			headset_send(hs, str);
-		}
+		if (hs->sp_gain >= 0)
+			headset_send(hs, "\r\n+VGS=%u\r\n", hs->sp_gain);
 
-		if (hs->mic_gain >= 0) {
-			snprintf(str, sizeof(str) - 1, "\r\n+VGM=%u\r\n",
-				hs->sp_gain);
-			headset_send(hs, str);
-		}
+		if (hs->mic_gain >= 0)
+			headset_send(hs, "\r\n+VGM=%u\r\n", hs->mic_gain);
 		break;
 	}
 

[-- Attachment #3: Type: text/plain, Size: 308 bytes --]

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

      parent reply	other threads:[~2007-12-14  0:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-13 14:14 [Bluez-devel] plugin tries Frédéric Dalleau
2007-12-13 14:16 ` Frédéric Dalleau
2007-12-14  0:10 ` Alok [this message]

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=1197591033.28907.18.camel@greatbear \
    --to=develnewbie@gmail.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /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.