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
Show replies by date
---
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
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
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
---
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
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