This patch adds the Audio Card driver connect callback implementation
to handle SCO connection requested by the driver. This approach
addresses devices compliant with HFP 1.5
---
 plugins/hfp_hf_bluez5.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 00159fa..bc91cfc 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -322,7 +322,36 @@ static void card_remove(struct ofono_handsfree_card *card)
 
 static int card_audio_connect(const char *remote, const char *local)
 {
-       return 0;
+       struct sockaddr_sco addr;
+       int sk, ret;
+
+       sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET | O_NONBLOCK | SOCK_CLOEXEC,
+                                                               BTPROTO_SCO);
+       if (sk < 0)
+               return -1;
+
+       /* Bind to local address */
+       memset(&addr, 0, sizeof(addr));
+       addr.sco_family = AF_BLUETOOTH;
+       bt_str2ba(local, &addr.sco_bdaddr);
+
+       if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+               close(sk);
+               return -1;
+       }
+
+       /* Connect to remote device */
+       memset(&addr, 0, sizeof(addr));
+       addr.sco_family = AF_BLUETOOTH;
+       bt_str2ba(remote, &addr.sco_bdaddr);
+
+       ret = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
+       if (ret < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) {
+               close(sk);
+               return -1;
+       }
+
+       return sk;
 }
 
 static struct ofono_handsfree_card_driver card_driver15 = {
-- 
1.7.11.7

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to