Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCHv3 1/4] android/daemon: Implement get adapter name
From: Andrei Emeltchenko @ 2013-11-04 13:22 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <CABBYNZLUUPkLM_b2DDb=mxc5-QqLrwN9in7XmZGpV+xQ-DpzzQ@mail.gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Use adapter_name_changed for get_property call.
---
 android/adapter.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index af461b8..3e43d44 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -1019,11 +1019,12 @@ static void send_adapter_address(void)
 
 static bool get_name(void)
 {
-	DBG("Not implemented");
+	if (!adapter->name)
+		return false;
 
-	/* TODO: Add implementation */
+	adapter_name_changed((uint8_t *) adapter->name);
 
-	return false;
+	return true;
 }
 
 static bool get_uuids(void)
-- 
1.7.10.4


^ permalink raw reply related

* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Stevie Trujillo @ 2013-11-04 13:15 UTC (permalink / raw)
  To: Hui Wang, marcel, tedd.an; +Cc: linux-bluetooth
In-Reply-To: <527737C7.40208@canonical.com>

Hello, I've been trying to use my computer as "handsfree" with
"Hands-Free Profile" using "Intel Corporation Centrino Wireless-N
1030". I accept() the BTPROTO_SCO socket, but never recv() any
data. Your post looked similar!

When googling I found this:

http://www.netbsd.org/docs/guide/en/chap-bluetooth.html#chap-bluetooth-audio
   SCO Audio will not work with ehci(4) USB controllers, since support
   for Isochronous data over EHCI is missing in NetBSD. 

Does Linux support this? (I have no idea what it means)

I'm sorry if this mail is somewhat broken. I could only find your email
on "gmane" and it had encrypted all your email addresses!

On Mon, 04 Nov 2013 13:59:35 +0800
Hui Wang <hui.wang-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> wrote:

> On 11/03/2013 03:05 AM, Marcel Holtmann wrote:
> > Hi Hui,
> >
> <snip>
> >>
> >> The attachment lenovo-k4450-btmon-v1.log is the log of intel 7260
> >> init procedure + scan headset + connect headset + play sound.
> > I looked through the logs and the controller init is just fine. So
> > in theory this should route the SCO audio frames over HCI. For some
> > reason it does not and I have no idea why not.
> >
> > That it makes a different between EHCI and XHCI is strange. I can
> > not explain this. Maybe Tedd can help you since I have no further
> > insights in our chips at this moment.
> 
> Thanks Marcel for your kind help and analysis.
> 
> Tedd, did you reproduce this issue on the machines with intel 7260 BT 
> module connected to the EHCI bus? Did you have any idea on this issue?

^ permalink raw reply

* Re: [PATCHv2 1/2] android/daemon: Implement get adapter name
From: Andrei Emeltchenko @ 2013-11-04 12:51 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZLUUPkLM_b2DDb=mxc5-QqLrwN9in7XmZGpV+xQ-DpzzQ@mail.gmail.com>

Hi Luiz,

On Mon, Nov 04, 2013 at 01:17:35PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
> 
> On Mon, Nov 4, 2013 at 12:49 PM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > ---
> >  android/adapter.c |   11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/android/adapter.c b/android/adapter.c
> > index af461b8..fdac82e 100644
> > --- a/android/adapter.c
> > +++ b/android/adapter.c
> > @@ -1017,13 +1017,14 @@ static void send_adapter_address(void)
> >         g_free(ev);
> >  }
> >
> > -static bool get_name(void)
> > +static bool send_adapter_name(void)
> >  {
> > -       DBG("Not implemented");
> > +       if (!adapter->name)
> > +               return false;
> >
> > -       /* TODO: Add implementation */
> > +       adapter_name_changed((uint8_t *) adapter->name);
> >
> > -       return false;
> > +       return true;
> >  }
> >
> >  static bool get_uuids(void)
> > @@ -1098,7 +1099,7 @@ static bool get_property(void *buf, uint16_t len)
> >                 send_adapter_address();
> >                 return true;
> >         case HAL_PROP_ADAPTER_NAME:
> > -               return get_name();
> > +               return send_adapter_name();
> 
> Not sure why you are changing the name here, all the other properties
> is using the same format as get_<name of property>.

I am following style, look at previous function: send_adapter_address. So
shall I change that one also in a separate patch?

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* [PATCH] android/client: Fix annoying delay in command line
From: Jerzy Kasenberg @ 2013-11-04 11:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jerzy Kasenberg

Move fflush(stdout) to after prints and user input.
This removes delay of showing prompt.
---
Same effect could be achieved by calling setbuf(stdout, NULL)
in terminal_setup() then all fflush calls could be removed.

If you think this should be better approach, I will change it.

 android/client/pollhandler.c |    5 -----
 android/client/terminal.c    |    6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/android/client/pollhandler.c b/android/client/pollhandler.c
index dd0d09f..6160921 100644
--- a/android/client/pollhandler.c
+++ b/android/client/pollhandler.c
@@ -68,11 +68,6 @@ void poll_dispatch_loop(void)
 			if (cur_fds_count != fds_count)
 				break;
 		}
-		/*
-		 * This seems to be needed for correct output handling
-		 * when all waiting is performed in poll
-		 */
-		fflush(stdout);
 	}
 }
 
diff --git a/android/client/terminal.c b/android/client/terminal.c
index e721160..22a1d8a 100644
--- a/android/client/terminal.c
+++ b/android/client/terminal.c
@@ -197,6 +197,8 @@ int terminal_vprint(const char *format, va_list args)
 
 	terminal_draw_command_line();
 
+	fflush(stdout);
+
 	return ret;
 }
 
@@ -570,6 +572,9 @@ void terminal_process_char(int c, void (*process_line)(char *line))
 		printf("%s \b", line_buf + refresh_from);
 		terminal_move_cursor(line_buf_ix - line_len);
 	}
+
+	/* Flush output after all user input */
+	fflush(stdout);
 }
 
 static struct termios origianl_tios;
@@ -596,4 +601,5 @@ void terminal_setup(void)
 	atexit(terminal_cleanup);
 
 	printf("%s", prompt);
+	fflush(stdout);
 }
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH] android/client: Change interface name to bluetooth
From: Jerzy Kasenberg @ 2013-11-04 11:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jerzy Kasenberg

This changes 'adapter' to 'bluetooth' as name of HAL interface.
This name matches name fond in bluetooth.h where all interfaces
are defined.
---
 android/client/if-bt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index fb1b3f3..4c501a5 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -777,6 +777,6 @@ static struct method methods[] = {
 };
 
 const struct interface bluetooth_if = {
-	.name = "adapter",
+	.name = "bluetooth",
 	.methods = methods
 };
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCHv2 1/2] android/daemon: Implement get adapter name
From: Luiz Augusto von Dentz @ 2013-11-04 11:17 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1383562180-21646-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Mon, Nov 4, 2013 at 12:49 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> ---
>  android/adapter.c |   11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/android/adapter.c b/android/adapter.c
> index af461b8..fdac82e 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -1017,13 +1017,14 @@ static void send_adapter_address(void)
>         g_free(ev);
>  }
>
> -static bool get_name(void)
> +static bool send_adapter_name(void)
>  {
> -       DBG("Not implemented");
> +       if (!adapter->name)
> +               return false;
>
> -       /* TODO: Add implementation */
> +       adapter_name_changed((uint8_t *) adapter->name);
>
> -       return false;
> +       return true;
>  }
>
>  static bool get_uuids(void)
> @@ -1098,7 +1099,7 @@ static bool get_property(void *buf, uint16_t len)
>                 send_adapter_address();
>                 return true;
>         case HAL_PROP_ADAPTER_NAME:
> -               return get_name();
> +               return send_adapter_name();

Not sure why you are changing the name here, all the other properties
is using the same format as get_<name of property>.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH BlueZ 4/4] android/pan: Add initial code for handling commands
From: Luiz Augusto von Dentz @ 2013-11-04 10:56 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383562617-9029-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/main.c |  4 ++++
 android/pan.c  | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/pan.h  |  2 ++
 3 files changed, 62 insertions(+)

diff --git a/android/main.c b/android/main.c
index 29b3882..7d36976 100644
--- a/android/main.c
+++ b/android/main.c
@@ -272,6 +272,10 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 		bt_a2dp_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
 								msg->len);
 		break;
+	case HAL_SERVICE_ID_PAN:
+		bt_pan_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
+								msg->len);
+		break;
 	default:
 		ipc_send_rsp(hal_cmd_io, msg->service_id, HAL_STATUS_FAILED);
 		break;
diff --git a/android/pan.c b/android/pan.c
index 4b988ac..0cc3590 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -32,9 +32,65 @@
 #include "lib/bluetooth.h"
 #include "log.h"
 #include "pan.h"
+#include "hal-msg.h"
+#include "ipc.h"
 
 static GIOChannel *notification_io = NULL;
 
+static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+static uint8_t bt_pan_get_role(void *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+static uint8_t bt_pan_connect(struct hal_cmd_pan_connect *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+static uint8_t bt_pan_disconnect(struct hal_cmd_pan_connect *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+void bt_pan_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+								uint16_t len)
+{
+	uint8_t status = HAL_STATUS_FAILED;
+
+	switch (opcode) {
+	case HAL_OP_PAN_ENABLE:
+		status = bt_pan_enable(buf, len);
+		break;
+	case HAL_OP_PAN_GET_ROLE:
+		status = bt_pan_get_role(buf, len);
+		break;
+	case HAL_OP_PAN_CONNECT:
+		status = bt_pan_connect(buf, len);
+		break;
+	case HAL_OP_PAN_DISCONNECT:
+		status = bt_pan_disconnect(buf, len);
+		break;
+	default:
+		DBG("Unhandled command, opcode 0x%x", opcode);
+		break;
+	}
+
+	ipc_send_rsp(io, HAL_SERVICE_ID_A2DP, status);
+}
+
 bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr)
 {
 	DBG("");
diff --git a/android/pan.h b/android/pan.h
index 318f318..1ffba9d 100644
--- a/android/pan.h
+++ b/android/pan.h
@@ -21,5 +21,7 @@
  *
  */
 
+void bt_pan_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len);
+
 bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr);
 void bt_pan_unregister(void);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ 3/4] android: Add initial skeleton for pan in the daemon
From: Luiz Augusto von Dentz @ 2013-11-04 10:56 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383562617-9029-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/Android.mk  |  1 +
 android/Makefile.am |  1 +
 android/main.c      |  9 +++++++++
 android/pan.c       | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/pan.h       | 25 +++++++++++++++++++++++++
 5 files changed, 89 insertions(+)
 create mode 100644 android/pan.c
 create mode 100644 android/pan.h

diff --git a/android/Android.mk b/android/Android.mk
index 6f537ea..77fd5a0 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -26,6 +26,7 @@ LOCAL_SRC_FILES := \
 	socket.c \
 	ipc.c ipc.h \
 	a2dp.c \
+	pan.c \
 	../src/log.c \
 	../src/shared/mgmt.c \
 	../src/shared/util.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index df7f8ec..3c51390 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -21,6 +21,7 @@ android_bluetoothd_SOURCES = android/main.c \
 				android/ipc.h android/ipc.c \
 				android/a2dp.h android/a2dp.c \
 				android/socket.h android/socket.c \
+				android/pan.h android/pan.c \
 				btio/btio.h btio/btio.c \
 				src/sdp-client.h src/sdp-client.c
 
diff --git a/android/main.c b/android/main.c
index 75ed4bb..29b3882 100644
--- a/android/main.c
+++ b/android/main.c
@@ -54,6 +54,7 @@
 #include "hal-msg.h"
 #include "ipc.h"
 #include "a2dp.h"
+#include "pan.h"
 
 /* TODO: Consider to remove PLATFORM_SDKVERSION check if requirement
 *  for minimal Android platform version increases. */
@@ -107,6 +108,11 @@ static void service_register(void *buf, uint16_t len)
 			goto error;
 
 		break;
+	case HAL_SERVICE_ID_PAN:
+		if (!bt_a2dp_register(hal_notif_io, adapter_bdaddr))
+			goto error;
+
+		break;
 	default:
 		DBG("service %u not supported", m->service_id);
 		goto error;
@@ -143,6 +149,9 @@ static void service_unregister(void *buf, uint16_t len)
 	case HAL_SERVICE_ID_A2DP:
 		bt_a2dp_unregister();
 		break;
+	case HAL_SERVICE_ID_PAN:
+		bt_pan_unregister();
+		break;
 	default:
 		/* This would indicate bug in HAL, as unregister should not be
 		 * called in init failed */
diff --git a/android/pan.c b/android/pan.c
new file mode 100644
index 0000000..4b988ac
--- /dev/null
+++ b/android/pan.c
@@ -0,0 +1,53 @@
+/*
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "log.h"
+#include "pan.h"
+
+static GIOChannel *notification_io = NULL;
+
+bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr)
+{
+	DBG("");
+
+	notification_io = g_io_channel_ref(io);
+
+	return true;
+}
+
+void bt_pan_unregister(void)
+{
+	DBG("");
+
+	g_io_channel_unref(notification_io);
+	notification_io = NULL;
+}
diff --git a/android/pan.h b/android/pan.h
new file mode 100644
index 0000000..318f318
--- /dev/null
+++ b/android/pan.h
@@ -0,0 +1,25 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr);
+void bt_pan_unregister(void);
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ 2/4] android/a2dp: Add initial code for handling commands
From: Luiz Augusto von Dentz @ 2013-11-04 10:56 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383562617-9029-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/a2dp.c | 36 ++++++++++++++++++++++++++++++++++++
 android/a2dp.h |  3 +++
 android/main.c |  4 ++++
 3 files changed, 43 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 64e5278..28ab4b1 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -35,9 +35,45 @@
 #include "lib/bluetooth.h"
 #include "log.h"
 #include "a2dp.h"
+#include "hal-msg.h"
+#include "ipc.h"
 
 static GIOChannel *notification_io = NULL;
 
+static uint8_t bt_a2dp_connect(struct hal_cmd_av_connect *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+static uint8_t bt_a2dp_disconnect(struct hal_cmd_av_connect *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+								uint16_t len)
+{
+	uint8_t status = HAL_STATUS_FAILED;
+
+	switch (opcode) {
+	case HAL_OP_AV_CONNECT:
+		status = bt_a2dp_connect(buf, len);
+		break;
+	case HAL_OP_AV_DISCONNECT:
+		status = bt_a2dp_disconnect(buf, len);
+		break;
+	default:
+		DBG("Unhandled command, opcode 0x%x", opcode);
+		break;
+	}
+
+	ipc_send_rsp(io, HAL_SERVICE_ID_A2DP, status);
+}
+
 bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr)
 {
 	DBG("");
diff --git a/android/a2dp.h b/android/a2dp.h
index b8b14bb..a5ac53e 100644
--- a/android/a2dp.h
+++ b/android/a2dp.h
@@ -21,5 +21,8 @@
  *
  */
 
+void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
+								uint16_t len);
+
 bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr);
 void bt_a2dp_unregister(void);
diff --git a/android/main.c b/android/main.c
index efa8c37..75ed4bb 100644
--- a/android/main.c
+++ b/android/main.c
@@ -259,6 +259,10 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 		bt_sock_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
 								msg->len);
 		break;
+	case HAL_SERVICE_ID_A2DP:
+		bt_a2dp_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
+								msg->len);
+		break;
 	default:
 		ipc_send_rsp(hal_cmd_io, msg->service_id, HAL_STATUS_FAILED);
 		break;
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ 1/4] android: Add initial skeleton for a2dp in the daemon
From: Luiz Augusto von Dentz @ 2013-11-04 10:56 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/Android.mk  |  1 +
 android/Makefile.am |  1 +
 android/a2dp.c      | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/a2dp.h      | 25 ++++++++++++++++++++++++
 android/main.c      |  9 +++++++++
 5 files changed, 92 insertions(+)
 create mode 100644 android/a2dp.c
 create mode 100644 android/a2dp.h

diff --git a/android/Android.mk b/android/Android.mk
index 443ac7a..6f537ea 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \
 	hid.c \
 	socket.c \
 	ipc.c ipc.h \
+	a2dp.c \
 	../src/log.c \
 	../src/shared/mgmt.c \
 	../src/shared/util.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index acbc0f5..df7f8ec 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -19,6 +19,7 @@ android_bluetoothd_SOURCES = android/main.c \
 				android/adapter.h android/adapter.c \
 				android/hid.h android/hid.c \
 				android/ipc.h android/ipc.c \
+				android/a2dp.h android/a2dp.c \
 				android/socket.h android/socket.c \
 				btio/btio.h btio/btio.c \
 				src/sdp-client.h src/sdp-client.c
diff --git a/android/a2dp.c b/android/a2dp.c
new file mode 100644
index 0000000..64e5278
--- /dev/null
+++ b/android/a2dp.c
@@ -0,0 +1,56 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "log.h"
+#include "a2dp.h"
+
+static GIOChannel *notification_io = NULL;
+
+bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr)
+{
+	DBG("");
+
+	notification_io = g_io_channel_ref(io);
+
+	return true;
+}
+
+void bt_a2dp_unregister(void)
+{
+	DBG("");
+
+	g_io_channel_unref(notification_io);
+	notification_io = NULL;
+}
diff --git a/android/a2dp.h b/android/a2dp.h
new file mode 100644
index 0000000..b8b14bb
--- /dev/null
+++ b/android/a2dp.h
@@ -0,0 +1,25 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2013  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr);
+void bt_a2dp_unregister(void);
diff --git a/android/main.c b/android/main.c
index 1d3f10f..efa8c37 100644
--- a/android/main.c
+++ b/android/main.c
@@ -53,6 +53,7 @@
 #include "hid.h"
 #include "hal-msg.h"
 #include "ipc.h"
+#include "a2dp.h"
 
 /* TODO: Consider to remove PLATFORM_SDKVERSION check if requirement
 *  for minimal Android platform version increases. */
@@ -101,6 +102,11 @@ static void service_register(void *buf, uint16_t len)
 			goto error;
 
 		break;
+	case HAL_SERVICE_ID_A2DP:
+		if (!bt_a2dp_register(hal_notif_io, adapter_bdaddr))
+			goto error;
+
+		break;
 	default:
 		DBG("service %u not supported", m->service_id);
 		goto error;
@@ -134,6 +140,9 @@ static void service_unregister(void *buf, uint16_t len)
 	case HAL_SERVICE_ID_HIDHOST:
 		bt_hid_unregister();
 		break;
+	case HAL_SERVICE_ID_A2DP:
+		bt_a2dp_unregister();
+		break;
 	default:
 		/* This would indicate bug in HAL, as unregister should not be
 		 * called in init failed */
-- 
1.8.3.1


^ permalink raw reply related

* [PATCHv2 2/2] android/daemon: Fix setting adapter name
From: Andrei Emeltchenko @ 2013-11-04 10:49 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383562180-21646-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Android use the full string returned even if we terminate it with '\0'.
---
 android/adapter.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index fdac82e..1b84956 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -145,8 +145,8 @@ static void scan_mode_changed(void)
 static void adapter_name_changed(const uint8_t *name)
 {
 	struct hal_ev_adapter_props_changed *ev;
-	uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) +
-							HAL_MAX_NAME_LENGTH];
+	size_t len = strlen((const char *) name);
+	uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
 
 	memset(buf, 0, sizeof(buf));
 	ev = (void *) buf;
@@ -154,10 +154,11 @@ static void adapter_name_changed(const uint8_t *name)
 	ev->num_props = 1;
 	ev->status = HAL_STATUS_SUCCESS;
 	ev->props[0].type = HAL_PROP_ADAPTER_NAME;
-	ev->props[0].len = HAL_MAX_NAME_LENGTH;
-	memcpy(ev->props->val, name, HAL_MAX_NAME_LENGTH);
+	/* Android expects value without NULL terminator */
+	ev->props[0].len = len;
+	memcpy(ev->props->val, name, len);
 
-	DBG("Adapter name changed to: %s", ev->props->val);
+	DBG("Adapter name changed to: %s", name);
 
 	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
 			HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
-- 
1.7.10.4


^ permalink raw reply related

* [PATCHv2 1/2] android/daemon: Implement get adapter name
From: Andrei Emeltchenko @ 2013-11-04 10:49 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/adapter.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index af461b8..fdac82e 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -1017,13 +1017,14 @@ static void send_adapter_address(void)
 	g_free(ev);
 }
 
-static bool get_name(void)
+static bool send_adapter_name(void)
 {
-	DBG("Not implemented");
+	if (!adapter->name)
+		return false;
 
-	/* TODO: Add implementation */
+	adapter_name_changed((uint8_t *) adapter->name);
 
-	return false;
+	return true;
 }
 
 static bool get_uuids(void)
@@ -1098,7 +1099,7 @@ static bool get_property(void *buf, uint16_t len)
 		send_adapter_address();
 		return true;
 	case HAL_PROP_ADAPTER_NAME:
-		return get_name();
+		return send_adapter_name();
 	case HAL_PROP_ADAPTER_UUIDS:
 		return get_uuids();
 	case HAL_PROP_ADAPTER_CLASS:
-- 
1.7.10.4


^ permalink raw reply related

* Re: [PATCH] android: Bump PLATFORM_SDK_VERSION to KitKat
From: Johan Hedberg @ 2013-11-04 10:16 UTC (permalink / raw)
  To: Jerzy Kasenberg; +Cc: linux-bluetooth
In-Reply-To: <1383559573-19508-1-git-send-email-jerzy.kasenberg@tieto.com>

Hi Jerzy,

On Mon, Nov 04, 2013, Jerzy Kasenberg wrote:
> This updates PLATFORM_SDK_VERSION to 19 since
> bluetooth headers were updated already.
> ---
>  android/Makefile.am |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] android: Fix not sending scan mode change notification
From: Johan Hedberg @ 2013-11-04 10:15 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1383559199-22843-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Mon, Nov 04, 2013, Szymon Janc wrote:
> Check for current settings instead of changed setting mask when
> sending notification. Otherwise scan mode change would be communicated
> only if power state changed at the same time.
> ---
>  android/adapter.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] android/client: Fix uninitialized variable
From: Johan Hedberg @ 2013-11-04 10:14 UTC (permalink / raw)
  To: Jerzy Kasenberg; +Cc: linux-bluetooth
In-Reply-To: <1383558940-18520-1-git-send-email-jerzy.kasenberg@tieto.com>

Hi Jerzy,

On Mon, Nov 04, 2013, Jerzy Kasenberg wrote:
> Pin accept variable was intended to be set to 1
> only when pin was typed by user. If no pin was given
> accept should be set to 0. This patch fixes this.
> ---
>  android/client/if-bt.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] android/daemon: Implement get adapter name
From: Johan Hedberg @ 2013-11-04 10:14 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383557952-9302-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Mon, Nov 04, 2013, Andrei Emeltchenko wrote:
> ---
>  android/adapter.c |   13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)

The patch doesn't compile:

android/adapter.c: In function ‘send_adapter_name’:
android/adapter.c:1024:2: error: pointer targets in passing argument 1 of ‘adapter_name_changed’ differ in signedness [-Werror=pointer-sign]
  adapter_name_changed(adapter->name);
  ^
android/adapter.c:145:13: note: expected ‘const uint8_t *’ but argument is of type ‘char *’
 static void adapter_name_changed(const uint8_t *name)
             ^
cc1: all warnings being treated as errors
make[1]: *** [android/adapter.o] Error 1

> @@ -71,6 +71,8 @@ static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
>  {
>  	const struct mgmt_cp_set_local_name *rp = param;
>  
> +	DBG("");
> +
>  	if (length < sizeof(*rp)) {
>  		error("Wrong size of local name changed parameters");
>  		return;

This change seems unrelated. Just drop it or move it to another patch.

Johan

^ permalink raw reply

* Re: [PATCH BlueZ 1/2] android/hid: Use BT_IO_OPT_SOURCE_BDADDR whenever possible
From: Johan Hedberg @ 2013-11-04 10:11 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1383557698-4475-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Mon, Nov 04, 2013, Luiz Augusto von Dentz wrote:
> ---
>  android/hid.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] Fix incorrect result type in set_adapter_name
From: Johan Hedberg @ 2013-11-04 10:08 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1383557498-7971-1-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Mon, Nov 04, 2013, Marcin Kraglak wrote:
> diff --git a/android/adapter.c b/android/adapter.c
> index af62b11..38dec9d 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -880,7 +880,7 @@ static void set_adapter_name_complete(uint8_t status, uint16_t length,
>  	adapter_name_changed(rp->name);
>  }
>  
> -static bool set_adapter_name(uint8_t *name, uint16_t len)
> +static uint8_t set_adapter_name(uint8_t *name, uint16_t len)
>  {
>  	struct mgmt_cp_set_local_name cp;
>  
> @@ -890,11 +890,11 @@ static bool set_adapter_name(uint8_t *name, uint16_t len)
>  	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_LOCAL_NAME, adapter->index,
>  			sizeof(cp), &cp, set_adapter_name_complete, NULL,
>  								NULL) > 0)
> -		return true;
> +		return HAL_STATUS_SUCCESS;
>  
>  	error("Failed to set name");
>  
> -	return false;
> +	return HAL_STATUS_FAILED;
>  }
>  
>  static void read_info_complete(uint8_t status, uint16_t length, const void *param,

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH] android: Bump PLATFORM_SDK_VERSION to KitKat
From: Jerzy Kasenberg @ 2013-11-04 10:06 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jerzy Kasenberg

This updates PLATFORM_SDK_VERSION to 19 since
bluetooth headers were updated already.
---
 android/Makefile.am |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/Makefile.am b/android/Makefile.am
index 5eb8f01..acbc0f5 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -71,7 +71,7 @@ android_haltest_SOURCES = android/client/haltest.c \
 android_haltest_LDADD = android/libhal-internal.la
 
 android_haltest_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
-				-DPLATFORM_SDK_VERSION=18
+				-DPLATFORM_SDK_VERSION=19
 
 android_haltest_LDFLAGS = -pthread
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH] android: Fix not sending scan mode change notification
From: Szymon Janc @ 2013-11-04  9:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Check for current settings instead of changed setting mask when
sending notification. Otherwise scan mode change would be communicated
only if power state changed at the same time.
---
 android/adapter.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index af62b11..efe3e8b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -174,19 +174,20 @@ static void settings_changed(uint32_t settings)
 
 	DBG("0x%08x", changed_mask);
 
-	if (changed_mask & MGMT_SETTING_POWERED) {
+	if (changed_mask & MGMT_SETTING_POWERED)
 		powered_changed();
 
-		/*
-		 * Only when powered, the connectable and discoverable
-		 * state changes should be communicated.
-		 */
-		scan_mode_mask = MGMT_SETTING_CONNECTABLE |
-						MGMT_SETTING_DISCOVERABLE;
 
+	scan_mode_mask = MGMT_SETTING_CONNECTABLE |
+					MGMT_SETTING_DISCOVERABLE;
+
+	/*
+	 * Only when powered, the connectable and discoverable
+	 * state changes should be communicated.
+	 */
+	if (adapter->current_settings & MGMT_SETTING_POWERED)
 		if (changed_mask & scan_mode_mask)
 			scan_mode_changed();
-	}
 }
 
 static void new_settings_callback(uint16_t index, uint16_t length,
-- 
1.8.4.1


^ permalink raw reply related

* [PATCH] android/client: Fix uninitialized variable
From: Jerzy Kasenberg @ 2013-11-04  9:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jerzy Kasenberg

Pin accept variable was intended to be set to 1
only when pin was typed by user. If no pin was given
accept should be set to 0. This patch fixes this.
---
 android/client/if-bt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 43e8788..fb1b3f3 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -605,7 +605,7 @@ static void pin_reply_p(int argc, const char **argv)
 	bt_bdaddr_t addr;
 	bt_pin_code_t pin;
 	int pin_len = 0;
-	int accept;
+	int accept = 0;
 
 	RETURN_IF_NULL(if_bluetooth);
 	VERIFY_ADDR_ARG(2, &addr);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH] android/daemon: Implement get adapter name
From: Andrei Emeltchenko @ 2013-11-04  9:39 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383556934-5481-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/adapter.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index cb92f2f..55c495c 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -71,6 +71,8 @@ static void mgmt_local_name_changed_event(uint16_t index, uint16_t length,
 {
 	const struct mgmt_cp_set_local_name *rp = param;
 
+	DBG("");
+
 	if (length < sizeof(*rp)) {
 		error("Wrong size of local name changed parameters");
 		return;
@@ -1016,13 +1018,14 @@ static void send_adapter_address(void)
 	g_free(ev);
 }
 
-static bool get_name(void)
+static bool send_adapter_name(void)
 {
-	DBG("Not implemented");
+	if (!adapter->name)
+		return false;
 
-	/* TODO: Add implementation */
+	adapter_name_changed(adapter->name);
 
-	return false;
+	return true;
 }
 
 static bool get_uuids(void)
@@ -1097,7 +1100,7 @@ static bool get_property(void *buf, uint16_t len)
 		send_adapter_address();
 		return true;
 	case HAL_PROP_ADAPTER_NAME:
-		return get_name();
+		return send_adapter_name();
 	case HAL_PROP_ADAPTER_UUIDS:
 		return get_uuids();
 	case HAL_PROP_ADAPTER_CLASS:
-- 
1.7.10.4


^ permalink raw reply related

* Re: [RFC] android/daemon: Implement get adapter name
From: Andrei Emeltchenko @ 2013-11-04  9:34 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383556934-5481-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

On Mon, Nov 04, 2013 at 11:22:13AM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Sorry, there is similar function exist, I will reuse it.

Best regards 
Andrei Emeltchenko 

> 
> ---
>  android/adapter.c |   29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/android/adapter.c b/android/adapter.c
> index cb92f2f..8210d1a 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -1016,13 +1016,32 @@ static void send_adapter_address(void)
>  	g_free(ev);
>  }
>  
> -static bool get_name(void)
> +static bool send_adapter_name(void)
>  {
> -	DBG("Not implemented");
> +	struct hal_ev_adapter_props_changed *ev;
> +	size_t len;
>  
> -	/* TODO: Add implementation */
> +	if (!adapter->name)
> +		return false;
>  
> -	return false;
> +	len = sizeof(*ev) + sizeof(struct hal_property) +
> +						strlen(adapter->name) + 1;
> +
> +	ev = g_malloc0(len);
> +
> +	ev->num_props = 1;
> +	ev->status = HAL_STATUS_SUCCESS;
> +
> +	ev->props[0].type = HAL_PROP_ADAPTER_NAME;
> +	ev->props[0].len = strlen(adapter->name) + 1;
> +	memcpy(&ev->props[0].val, adapter->name, strlen(adapter->name));
> +
> +	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
> +				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
> +
> +	g_free(ev);
> +
> +	return true;
>  }
>  
>  static bool get_uuids(void)
> @@ -1097,7 +1116,7 @@ static bool get_property(void *buf, uint16_t len)
>  		send_adapter_address();
>  		return true;
>  	case HAL_PROP_ADAPTER_NAME:
> -		return get_name();
> +		return send_adapter_name();
>  	case HAL_PROP_ADAPTER_UUIDS:
>  		return get_uuids();
>  	case HAL_PROP_ADAPTER_CLASS:
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH BlueZ 2/2] android: Add the missing HAVE_CONFIG_H check daemon files
From: Luiz Augusto von Dentz @ 2013-11-04  9:34 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383557698-4475-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hid.c    | 4 ++++
 android/ipc.c    | 4 ++++
 android/socket.c | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/android/hid.c b/android/hid.c
index 59fc90b..1ee8ed4 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -21,6 +21,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdint.h>
 #include <stdbool.h>
 #include <errno.h>
diff --git a/android/ipc.c b/android/ipc.c
index 1f52753..e672bf8 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -21,6 +21,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stddef.h>
 #include <errno.h>
 #include <stdint.h>
diff --git a/android/socket.c b/android/socket.c
index b6eed6e..e32be46 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -21,6 +21,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <glib.h>
 #include <stdbool.h>
 
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ 1/2] android/hid: Use BT_IO_OPT_SOURCE_BDADDR whenever possible
From: Luiz Augusto von Dentz @ 2013-11-04  9:34 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/hid.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/android/hid.c b/android/hid.c
index e660552..59fc90b 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -661,12 +661,11 @@ void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
 static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 {
 	struct hid_device *dev;
-	bdaddr_t dst;
+	bdaddr_t src, dst;
 	char address[18];
 	uint16_t psm;
 	GError *gerr = NULL;
 	GSList *l;
-	const bdaddr_t *src = bt_adapter_get_address();
 	uuid_t uuid;
 
 	if (err) {
@@ -675,6 +674,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	}
 
 	bt_io_get(chan, &err,
+			BT_IO_OPT_SOURCE_BDADDR, &src,
 			BT_IO_OPT_DEST_BDADDR, &dst,
 			BT_IO_OPT_PSM, &psm,
 			BT_IO_OPT_INVALID);
@@ -699,7 +699,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 		dev->uhid_fd = -1;
 
 		bt_string2uuid(&uuid, HID_UUID);
-		if (bt_search_service(src, &dev->dst, &uuid,
+		if (bt_search_service(&src, &dev->dst, &uuid,
 					hid_sdp_search_cb, dev, NULL) < 0) {
 			error("failed to search sdp details");
 			hid_device_free(dev);
@@ -732,12 +732,14 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 bool bt_hid_register(GIOChannel *io, const bdaddr_t *addr)
 {
 	GError *err = NULL;
+	const bdaddr_t *src = bt_adapter_get_address();
 
 	DBG("");
 
 	notification_io = g_io_channel_ref(io);
 
 	ctrl_io = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
+				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_PSM, L2CAP_PSM_HIDP_CTRL,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
 				BT_IO_OPT_INVALID);
@@ -748,6 +750,7 @@ bool bt_hid_register(GIOChannel *io, const bdaddr_t *addr)
 	}
 
 	intr_io = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
+				BT_IO_OPT_SOURCE_BDADDR, &src,
 				BT_IO_OPT_PSM, L2CAP_PSM_HIDP_INTR,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
 				BT_IO_OPT_INVALID);
-- 
1.8.3.1


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox