All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card
@ 2013-02-28 16:01 Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 2/6] hfp_hf_bluez5: Add local address to " Claudio Takahasi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Claudio Takahasi @ 2013-02-28 16:01 UTC (permalink / raw)
  To: ofono

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

This patch registers the Handsfree Audio Card when the service level
connection is established.
---
 plugins/hfp_hf_bluez5.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7057d71..87d7e91 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -46,6 +46,7 @@
 #include <ofono/netreg.h>
 #include <ofono/voicecall.h>
 #include <ofono/call-volume.h>
+#include <ofono/handsfree-audio.h>
 #include <ofono/handsfree.h>
 
 #include <drivers/hfpmodem/slc.h>
@@ -61,6 +62,7 @@
 struct hfp {
 	struct hfp_slc_info info;
 	DBusMessage *msg;
+	struct ofono_handsfree_card *card;
 };
 
 static GDBusClient *bluez = NULL;
@@ -88,6 +90,8 @@ static void slc_established(gpointer userdata)
 	hfp->msg = NULL;
 
 	ofono_info("Service level connection established");
+
+	ofono_handsfree_card_register(hfp->card);
 }
 
 static void slc_failed(gpointer userdata)
@@ -315,8 +319,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 {
 	struct hfp *hfp;
 	struct ofono_modem *modem;
+	struct sockaddr_rc saddr;
+	socklen_t optlen;
 	DBusMessageIter entry;
 	const char *device;
+	char remote[18];
 	int fd, err;
 
 	DBG("Profile handler NewConnection");
@@ -353,8 +360,22 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 					"Not enough resources");
 	}
 
+	memset(&saddr, 0, sizeof(saddr));
+	optlen = sizeof(saddr);
+
+	if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+		err = errno;
+		ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
+									err);
+		close(fd);
+		goto invalid;
+	}
+
+	bt_ba2str(&saddr.rc_bdaddr, remote);
+
 	hfp = ofono_modem_get_data(modem);
 	hfp->msg = dbus_message_ref(msg);
+	hfp->card = ofono_handsfree_card_create(remote, NULL);
 
 	return NULL;
 
-- 
1.7.11.7


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

* [PATCH v3 2/6] hfp_hf_bluez5: Add local address to Audio Card
  2013-02-28 16:01 [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card Claudio Takahasi
@ 2013-02-28 16:01 ` Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 3/6] hfp_hf_bluez5: Remove Card when SLC fails Claudio Takahasi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2013-02-28 16:01 UTC (permalink / raw)
  To: ofono

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

---
 plugins/hfp_hf_bluez5.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 87d7e91..3960d7a 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -323,7 +323,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 	socklen_t optlen;
 	DBusMessageIter entry;
 	const char *device;
-	char remote[18];
+	char local[18], remote[18];
 	int fd, err;
 
 	DBG("Profile handler NewConnection");
@@ -363,6 +363,19 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 	memset(&saddr, 0, sizeof(saddr));
 	optlen = sizeof(saddr);
 
+	if (getsockname(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+		err = errno;
+		ofono_error("RFCOMM getsockname(): %s (%d)", strerror(err),
+									err);
+		close(fd);
+		goto invalid;
+	}
+
+	bt_ba2str(&saddr.rc_bdaddr, local);
+
+	memset(&saddr, 0, sizeof(saddr));
+	optlen = sizeof(saddr);
+
 	if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
 		err = errno;
 		ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
@@ -375,7 +388,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 
 	hfp = ofono_modem_get_data(modem);
 	hfp->msg = dbus_message_ref(msg);
-	hfp->card = ofono_handsfree_card_create(remote, NULL);
+	hfp->card = ofono_handsfree_card_create(remote, local);
 
 	return NULL;
 
-- 
1.7.11.7


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

* [PATCH v3 3/6] hfp_hf_bluez5: Remove Card when SLC fails
  2013-02-28 16:01 [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 2/6] hfp_hf_bluez5: Add local address to " Claudio Takahasi
@ 2013-02-28 16:01 ` Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 4/6] hfp_hf_bluez5: Remove Card if SLC is disconnected Claudio Takahasi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2013-02-28 16:01 UTC (permalink / raw)
  To: ofono

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

This patch removes the previously created Audio Card if the service
level negotiation fails.
---
 plugins/hfp_hf_bluez5.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 3960d7a..98cef7c 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -112,6 +112,9 @@ static void slc_failed(gpointer userdata)
 	ofono_error("Service level connection failed");
 	ofono_modem_set_powered(modem, FALSE);
 
+	ofono_handsfree_card_remove(hfp->card);
+	hfp->card = NULL;
+
 	g_at_chat_unref(info->chat);
 	info->chat = NULL;
 }
-- 
1.7.11.7


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

* [PATCH v3 4/6] hfp_hf_bluez5: Remove Card if SLC is disconnected
  2013-02-28 16:01 [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 2/6] hfp_hf_bluez5: Add local address to " Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 3/6] hfp_hf_bluez5: Remove Card when SLC fails Claudio Takahasi
@ 2013-02-28 16:01 ` Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 5/6] hfp_hf_bluez5: Remove Card when modem is disabled Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 6/6] hfp_hf_bluez5: Remove Card on RequestDisconnection Claudio Takahasi
  4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2013-02-28 16:01 UTC (permalink / raw)
  To: ofono

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

This patch removes previous registered Audio Card when the remote
Bluetooth device triggers the service level disconnection.
---
 plugins/hfp_hf_bluez5.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 98cef7c..5db7bb8 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -129,6 +129,9 @@ static void hfp_disconnected_cb(gpointer user_data)
 
 	ofono_modem_set_powered(modem, FALSE);
 
+	ofono_handsfree_card_remove(hfp->card);
+	hfp->card = NULL;
+
 	g_at_chat_unref(info->chat);
 	info->chat = NULL;
 }
-- 
1.7.11.7


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

* [PATCH v3 5/6] hfp_hf_bluez5: Remove Card when modem is disabled
  2013-02-28 16:01 [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card Claudio Takahasi
                   ` (2 preceding siblings ...)
  2013-02-28 16:01 ` [PATCH v3 4/6] hfp_hf_bluez5: Remove Card if SLC is disconnected Claudio Takahasi
@ 2013-02-28 16:01 ` Claudio Takahasi
  2013-02-28 16:01 ` [PATCH v3 6/6] hfp_hf_bluez5: Remove Card on RequestDisconnection Claudio Takahasi
  4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2013-02-28 16:01 UTC (permalink / raw)
  To: ofono

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

---
 plugins/hfp_hf_bluez5.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 5db7bb8..d35a20f 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -272,6 +272,9 @@ static int hfp_disable(struct ofono_modem *modem)
 	fd = g_io_channel_unix_get_fd(channel);
 	shutdown(fd, SHUT_RDWR);
 
+	ofono_handsfree_card_remove(hfp->card);
+	hfp->card = NULL;
+
 	g_at_chat_unref(info->chat);
 	info->chat = NULL;
 
-- 
1.7.11.7


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

* [PATCH v3 6/6] hfp_hf_bluez5: Remove Card on RequestDisconnection
  2013-02-28 16:01 [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card Claudio Takahasi
                   ` (3 preceding siblings ...)
  2013-02-28 16:01 ` [PATCH v3 5/6] hfp_hf_bluez5: Remove Card when modem is disabled Claudio Takahasi
@ 2013-02-28 16:01 ` Claudio Takahasi
  4 siblings, 0 replies; 6+ messages in thread
From: Claudio Takahasi @ 2013-02-28 16:01 UTC (permalink / raw)
  To: ofono

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

For local initiated disconnection the GAtChat disconnect callback is not
called. For this case, Audio Card remove function needs to be called.
---
 plugins/hfp_hf_bluez5.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index d35a20f..2db2fa5 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -454,6 +454,9 @@ static DBusMessage *profile_disconnection(DBusConnection *conn,
 	hfp = ofono_modem_get_data(modem);
 	info = &hfp->info;
 
+	ofono_handsfree_card_remove(hfp->card);
+	hfp->card = NULL;
+
 	g_at_chat_unref(info->chat);
 	info->chat = NULL;
 
-- 
1.7.11.7


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

end of thread, other threads:[~2013-02-28 16:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28 16:01 [PATCH v3 1/6] hfp_hf_bluez5: Add registering Audio Card Claudio Takahasi
2013-02-28 16:01 ` [PATCH v3 2/6] hfp_hf_bluez5: Add local address to " Claudio Takahasi
2013-02-28 16:01 ` [PATCH v3 3/6] hfp_hf_bluez5: Remove Card when SLC fails Claudio Takahasi
2013-02-28 16:01 ` [PATCH v3 4/6] hfp_hf_bluez5: Remove Card if SLC is disconnected Claudio Takahasi
2013-02-28 16:01 ` [PATCH v3 5/6] hfp_hf_bluez5: Remove Card when modem is disabled Claudio Takahasi
2013-02-28 16:01 ` [PATCH v3 6/6] hfp_hf_bluez5: Remove Card on RequestDisconnection Claudio Takahasi

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.