Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 2/2] android: Add set/get for discovery timeout
From: Lukasz Rymanowski @ 2013-11-06 15:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski
In-Reply-To: <1383750530-18815-1-git-send-email-lukasz.rymanowski@tieto.com>

Android handles discoverable timeout in Settings app, however still
expects BT stack to maintain this value so we should do it as well.
Otherwise we will get some unexpected behaviour.
For now we keep discovery_timeout only during runtime, but we need to move
it to some local storage once we will have it.

Note: That since Android Settings up handles timer there is no reason to
use discovery timer we have in kernel.
---
 android/adapter.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 1d462c8..d97f34b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -47,6 +47,8 @@
 
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
+/* Default discoverable timeout 120sec as in Android */
+#define DEFAULT_DISCOVERABLE_TIMEOUT 120
 
 static GIOChannel *notification_io = NULL;
 /* This list contains addresses which are asked for records */
@@ -67,6 +69,7 @@ struct bt_adapter {
 	uint32_t current_settings;
 
 	bool discovering;
+	uint32_t discoverable_timeout;
 };
 
 struct browse_req {
@@ -1101,6 +1104,17 @@ static uint8_t set_adapter_name(uint8_t *name, uint16_t len)
 	return HAL_STATUS_FAILED;
 }
 
+static uint8_t set_discoverable_timeout(uint8_t *timeout)
+{
+	/* Android handles discoverable timeout in Settings app.
+	 * There is no need to use kernel feature for that.
+	 * Just need to store this value here */
+
+	/* TODO: This should be in some storage */
+	memcpy(&adapter->discoverable_timeout, timeout, sizeof(uint32_t));
+
+	return HAL_STATUS_SUCCESS;
+}
 static void read_info_complete(uint8_t status, uint16_t length, const void *param,
 							void *user_data)
 {
@@ -1169,6 +1183,8 @@ void bt_adapter_init(uint16_t index, struct mgmt *mgmt, bt_adapter_ready cb)
 	adapter->index = index;
 	adapter->discovering = false;
 	adapter->ready = cb;
+	/* TODO: Read it from some storage */
+	adapter->discoverable_timeout = DEFAULT_DISCOVERABLE_TIMEOUT;
 
 	if (mgmt_send(mgmt, MGMT_OP_READ_INFO, index, 0, NULL,
 					read_info_complete, NULL, NULL) > 0)
@@ -1286,11 +1302,26 @@ static bool get_devices(void)
 
 static bool get_discoverable_timeout(void)
 {
-	DBG("Not implemented");
+	struct hal_ev_adapter_props_changed *ev;
+	int len;
 
-	/* TODO: Add implementation */
+	len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(uint32_t);
 
-	return false;
+	ev = g_malloc(len);
+
+	ev->num_props = 1;
+	ev->status = HAL_STATUS_SUCCESS;
+
+	ev->props[0].type = HAL_PROP_ADAPTER_DISC_TIMEOUT;
+	ev->props[0].len = sizeof(uint32_t);
+	memcpy(&ev->props[0].val, &adapter->discoverable_timeout, sizeof(uint32_t));
+
+	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+
+	g_free(ev);
+
+	return true;
 }
 
 static bool get_property(void *buf, uint16_t len)
@@ -1441,6 +1472,7 @@ static uint8_t set_property(void *buf, uint16_t len)
 	case HAL_PROP_ADAPTER_NAME:
 		return set_adapter_name(cmd->val, cmd->len);
 	case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+		return set_discoverable_timeout(cmd->val);
 	default:
 		DBG("Unhandled property type 0x%x", cmd->type);
 		return HAL_STATUS_FAILED;
-- 
1.8.4


^ permalink raw reply related

* [PATCHv3 1/2] android: Create debug hal-utils helpers
From: Andrei Emeltchenko @ 2013-11-06 15:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <903E7C5D-33E0-4EDB-BD6D-02B183278514@holtmann.org>

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

Create hal-utils helpers which helps to decode packets Android
sends through HAL interface.
---
 android/Android.mk        |    2 ++
 android/Makefile.am       |    3 ++-
 android/client/if-gatt.c  |    1 +
 android/client/textconv.c |   42 ++------------------------------
 android/client/textconv.h |    2 --
 android/hal-utils.c       |   58 +++++++++++++++++++++++++++++++++++++++++++++
 android/hal-utils.h       |   26 ++++++++++++++++++++
 7 files changed, 91 insertions(+), 43 deletions(-)
 create mode 100644 android/hal-utils.c
 create mode 100644 android/hal-utils.h

diff --git a/android/Android.mk b/android/Android.mk
index d76dfaf..32bb591 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -88,6 +88,7 @@ LOCAL_SRC_FILES := \
 	hal-pan.c \
 	hal-av.c \
 	client/textconv.c \
+	hal-utils.c \
 
 LOCAL_C_INCLUDES += \
 	$(call include-path-for, system-core) \
@@ -125,6 +126,7 @@ LOCAL_SRC_FILES := \
 	client/if-hh.c \
 	client/if-pan.c \
 	client/if-sock.c \
+	hal-utils.c \
 
 ANDROID_4_3_OR_ABOVE := $(shell echo 0 | awk -v v=$(PLATFORM_SDK_VERSION) 'END {print (v > 17) ? 1 : 0}')
 
diff --git a/android/Makefile.am b/android/Makefile.am
index 8619641..e4adf6c 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -68,7 +68,8 @@ android_haltest_SOURCES = android/client/haltest.c \
 				android/client/if-hh.c \
 				android/client/if-pan.c \
 				android/client/if-sock.c \
-				android/client/hwmodule.c
+				android/client/hwmodule.c \
+				android/hal-utils.h android/hal-utils.c
 
 android_haltest_LDADD = android/libhal-internal.la
 
diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index b2b20cb..bb53952 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -17,6 +17,7 @@
 
 #include <hardware/bluetooth.h>
 
+#include "../hal-utils.h"
 #include "if-main.h"
 
 const btgatt_interface_t *if_gatt = NULL;
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 4def3da..469b2c3 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <hardware/bluetooth.h>
 
+#include "../hal-utils.h"
+
 #include "textconv.h"
 
 /*
@@ -154,39 +156,6 @@ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr)
 				&p[0], &p[1], &p[2], &p[3], &p[4], &p[5]);
 }
 
-static const char BT_BASE_UUID[] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
-	0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
-};
-
-/*
- * converts uuid to string
- * buf should be at least 39 bytes
- *
- * returns string representation of uuid
- */
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
-{
-	int shift = 0;
-	int i;
-	int is_bt;
-
-	is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
-
-	for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
-		if (i == 4 && is_bt)
-			break;
-
-		if (i == 4 || i == 6 || i == 8 || i == 10) {
-			buf[i * 2 + shift] = '-';
-			shift++;
-		}
-		sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
-	}
-
-	return buf;
-}
-
 /* converts string to uuid */
 void str2bt_uuid_t(const char *str, bt_uuid_t *uuid)
 {
@@ -234,13 +203,6 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
 	return bt_bdaddr_t2str(bd_addr, buf);
 }
 
-static char *btuuid2str(const bt_uuid_t *uuid)
-{
-	static char buf[MAX_UUID_STR_LEN];
-
-	return bt_uuid_t2str(uuid, buf);
-}
-
 char *btproperty2str(const bt_property_t *property)
 {
 	static char buf[4096];
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 1c848ef..837eb4e 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -103,8 +103,6 @@ static struct int2str __##type##2str[] = {
 char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf);
 void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
 
-#define MAX_UUID_STR_LEN 37
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
 void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
 
 char *btproperty2str(const bt_property_t *property);
diff --git a/android/hal-utils.c b/android/hal-utils.c
new file mode 100644
index 0000000..84cfad1
--- /dev/null
+++ b/android/hal-utils.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <hardware/bluetooth.h>
+
+#include "hal-utils.h"
+
+/*
+ * converts uuid to string
+ * buf should be at least 39 bytes
+ *
+ * returns string representation of uuid
+ */
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
+{
+	int shift = 0;
+	int i;
+	int is_bt;
+
+	is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
+
+	for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
+		if (i == 4 && is_bt)
+			break;
+
+		if (i == 4 || i == 6 || i == 8 || i == 10) {
+			buf[i * 2 + shift] = '-';
+			shift++;
+		}
+		sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
+	}
+
+	return buf;
+}
+
+char *btuuid2str(const bt_uuid_t *uuid)
+{
+	static char buf[MAX_UUID_STR_LEN];
+
+	return bt_uuid_t2str(uuid, buf);
+}
diff --git a/android/hal-utils.h b/android/hal-utils.h
new file mode 100644
index 0000000..d40b430
--- /dev/null
+++ b/android/hal-utils.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define MAX_UUID_STR_LEN 37
+
+static const char BT_BASE_UUID[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+	0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
+};
+
+char *btuuid2str(const bt_uuid_t *uuid);
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
-- 
1.7.10.4


^ permalink raw reply related

* [PATCHv3 2/2] android/hal: Add UUID debug print in socket HAL
From: Andrei Emeltchenko @ 2013-11-06 15:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1383750643-1139-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

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

---
 android/hal-sock.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/android/hal-sock.c b/android/hal-sock.c
index 32c7939..1d198ac 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -25,6 +25,8 @@
 #include "hal-msg.h"
 #include "hal.h"
 
+#include "hal-utils.h"
+
 static bt_status_t sock_listen_rfcomm(const char *service_name,
 					const uint8_t *uuid, int chan,
 					int *sock, int flags)
@@ -49,13 +51,14 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
 					int *sock, int flags)
 {
 	if ((!uuid && chan <= 0) || !sock) {
-		error("%s: invalid params: uuid %p, chan %d, sock %p",
-						__func__, uuid, chan, sock);
+		error("Invalid params: uuid %s, chan %d, sock %p",
+				btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d service_name %s",
-					uuid, chan, sock, type, service_name);
+	DBG("uuid %s chan %d sock %p type %d service_name %s",
+				btuuid2str((bt_uuid_t *) uuid), chan,
+				sock, type, service_name);
 
 	switch (type) {
 	case BTSOCK_RFCOMM:
@@ -76,12 +79,13 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
 	struct hal_cmd_sock_connect cmd;
 
 	if ((!uuid && chan <= 0) || !bdaddr || !sock) {
-		error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
-					bdaddr, uuid, chan, sock);
+		error("Invalid params: bd_addr %p, uuid %s, chan %d, sock %p",
+			bdaddr, btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
+	DBG("uuid %s chan %d sock %p type %d", btuuid2str((bt_uuid_t *) uuid),
+							chan, sock, type);
 
 	if (type != BTSOCK_RFCOMM) {
 		error("Socket type %u not supported", type);
-- 
1.7.10.4


^ permalink raw reply related

* linux-firmware: pull-request Marvell mwifiex-firmware 2013-11-06
From: Bing Zhao @ 2013-11-06 19:25 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: linux-wireless, linux-bluetooth, Frank Huang, Bing Zhao

The following changes since commit 7d0c7a8cfd78388d90cc784a185b19dcbdbce824:

  Merge branch 'wilink4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/linux-firmware (2013-10-13 21:11:46 +0100)

are available in the git repository at:


  git://git.marvell.com/mwifiex-firmware.git master

for you to fetch changes up to b7c848634538ff87317acd802fb4645cfd2f9fb5:

  linux-firmware: add Marvell SD8897-B0 firmware combo image (2013-11-04 16:03:34 -0800)

----------------------------------------------------------------
Bing Zhao (2):
      linux-firmware: update Marvell PCIe/USB 8897-B0 firmware combo image
      linux-firmware: add Marvell SD8897-B0 firmware combo image

 WHENCE                   |   5 ++++-
 mrvl/pcie8897_uapsta.bin | Bin 350244 -> 656896 bytes
 mrvl/sd8897_uapsta.bin   | Bin 0 -> 639012 bytes
 3 files changed, 4 insertions(+), 1 deletion(-)
 create mode 100644 mrvl/sd8897_uapsta.bin

diff --git a/WHENCE b/WHENCE
index 2d52804..3875e77 100644
--- a/WHENCE
+++ b/WHENCE
@@ -727,11 +727,14 @@ Version: 14.66.9.p96
 File: mrvl/sd8797_uapsta.bin
 Version: 14.66.11.p151
 
+File: mrvl/sd8897_uapsta.bin
+Version: 15.69.2.p11
+
 File: mrvl/usb8797_uapsta.bin
 Version: 14.69.11.p179
 
 File: mrvl/pcie8897_uapsta.bin
-Version: 15.69.201.p52
+Version: 15.69.2.p11
 
 Licence: Redistributable. See LICENCE.Marvell for details.  Originates from
 http://git.marvell.com/?p=mwifiex-firmware.git
diff --git a/mrvl/pcie8897_uapsta.bin b/mrvl/pcie8897_uapsta.bin
index b067689..858c100 100644
Binary files a/mrvl/pcie8897_uapsta.bin and b/mrvl/pcie8897_uapsta.bin differ
diff --git a/mrvl/sd8897_uapsta.bin b/mrvl/sd8897_uapsta.bin
new file mode 100644
index 0000000..70732a6
Binary files /dev/null and b/mrvl/sd8897_uapsta.bin differ

^ permalink raw reply related

* Re: [PATCH] Bluetooth: Remove unnecessary 'send' parameter from smp_failure()
From: Marcel Holtmann @ 2013-11-06 20:17 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1383729897-28492-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> The send parameter has only been used for determining whether to send a
> Pairing Failed PDU or not. However, the function can equally well use
> the already existing reason parameter to make this choice and send the
> PDU whenever a non-zero value was passed.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/smp.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] Bluetooth: ath3k: Add support for another AR3012 card
From: Marcel Holtmann @ 2013-11-06 20:21 UTC (permalink / raw)
  To: Sujith Manoharan
  Cc: linux-bluetooth@vger.kernel.org development, Gustavo F. Padovan
In-Reply-To: <1383715560-25328-1-git-send-email-sujith@msujith.org>

Hi Sujith,

> T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=04ca ProdID=300b Rev= 0.01
> C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> 
> Reported-by:Face <falazemi@gmail.com>
> Signed-off-by: Sujith Manoharan <sujith@msujith.org>
> ---
> drivers/bluetooth/ath3k.c | 2 ++
> drivers/bluetooth/btusb.c | 1 +
> 2 files changed, 3 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: Intel 7260 bluetooth malfunction when it is connected to EHCI bus
From: Hui Wang @ 2013-11-07  3:45 UTC (permalink / raw)
  To: Stevie Trujillo; +Cc: marcel, tedd.an, linux-bluetooth
In-Reply-To: <20131105194431.54fba8fb@localhost>

On 11/06/2013 02:44 AM, Stevie Trujillo wrote:
> On Tue, 05 Nov 2013 10:32:05 +0800
> Hui Wang <hui.wang@canonical.com> wrote:
>
>> Thanks for your input, I don't know the answer of your question, but
>> at least the camera works well on the EHCI bus, and camera transfers
>> the ISO packets over EHCI bus.
> Hello again! Have you tried comparing usbmon output (I used Wireshark)
> when running on EHCI and XHCI? My bluetooth card is inside the
> computer, so I'm only able to do EHCI.
>
> I see 1 ISO come in right after the SCO thing opens. It has some
> error stuff inside (ENOSPC). No idea how it is supposed to behave,
> since I can't compare with a good one.
>
> Sorry if this is a stupid idea :P
>
Do you know any tools can decode the log generated by usbmon?

Regards,
Hui.

^ permalink raw reply

* Re: [PATCHv2 4/6] android: Add supported uuids when adapter is initialized
From: Andrei Emeltchenko @ 2013-11-07  8:04 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1383657700-22313-5-git-send-email-marcin.kraglak@tieto.com>

Hi All,

On Tue, Nov 05, 2013 at 02:21:38PM +0100, Marcin Kraglak wrote:
> It will set class of device with proper service hints.
> We set it statically because we want to keep code simple.
> 
> ---
>  android/adapter.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/android/adapter.c b/android/adapter.c
> index 0f24cac..70b9265 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -52,6 +52,29 @@ static GIOChannel *notification_io = NULL;
>  /* This list contains addresses which are asked for records */
>  static GSList *browse_reqs;
>  
> +/*
> + * This is an array of supported uuids and service hints. We add them via mgmt
> + * interface when adapter is initialized. Uuids are in reverse orded.
> + */
> +static const struct mgmt_cp_add_uuid supported_services[] = {
> +	/* OBEX_OPP_UUID */
> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
> +			0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00 },
> +	.svc_hint = 0x10 },

I think PBAP is missing here. BTW can we define those strings separately
so that it might be used to compare.

Socket HAL identify service by UUID so I need to derive RFCOMM channel
from it. I am thinking simply comparing those strings.

Any opinion on this?

Best regards 
Andrei Emeltchenko 

^ permalink raw reply

* Re: [PATCH 2/2] android: Add set/get for discovery timeout
From: Johan Hedberg @ 2013-11-07  8:07 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth, szymon.janc
In-Reply-To: <1383750530-18815-2-git-send-email-lukasz.rymanowski@tieto.com>

Hi Lukasz,

On Wed, Nov 06, 2013, Lukasz Rymanowski wrote:
>  static bool get_discoverable_timeout(void)
>  {
> -	DBG("Not implemented");
> +	struct hal_ev_adapter_props_changed *ev;
> +	int len;
>  
> -	/* TODO: Add implementation */
> +	len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(uint32_t);
>  

The dynamic memory allocation seems a bit overkill here since the size is
not very big and can be determined even at compile time. I'd consider
doing something like:

	uint8_t buf[sizeof(struct hal_ev_adapter_props_changed) +
			sizeof(struct hal_property) + sizeof(uint32_t)];
	struct hal_ev_adapter_props_changed *ev = (void *) buf;

	...

	ipc_send(..., sizeof(buf), buf, ...);

Johan

^ permalink raw reply

* Re: [PATCH 1/2] android: Change name for get_disc_timeout
From: Johan Hedberg @ 2013-11-07  8:09 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth, szymon.janc
In-Reply-To: <1383750530-18815-1-git-send-email-lukasz.rymanowski@tieto.com>

Hi Lukasz,

On Wed, Nov 06, 2013, Lukasz Rymanowski wrote:
> Change name to get_discoverable_timeout. Previous name could be
> confusing with disconnection timeout.
> ---
>  android/adapter.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

This patch has been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 3/3] android/hal: Rename hal_op_sock_listen to hal_cmd_sock_listen
From: Johan Hedberg @ 2013-11-07  8:10 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1383746614-15077-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Wed, Nov 06, 2013, Andrei Emeltchenko wrote:
> This makes structures consistent with the rest of the code.
> ---
>  android/hal-msg.h  |    4 ++--
>  android/hal-sock.c |    4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

Patches 1 and 3 have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 2/2] android: Add set/get for discovery timeout
From: Marcel Holtmann @ 2013-11-07  8:14 UTC (permalink / raw)
  To: Johan Hedberg
  Cc: Lukasz Rymanowski, linux-bluetooth@vger.kernel.org development,
	Szymon Janc
In-Reply-To: <20131107080758.GA7493@x220.p-661hnu-f1>

Hi Johan,

>> static bool get_discoverable_timeout(void)
>> {
>> -	DBG("Not implemented");
>> +	struct hal_ev_adapter_props_changed *ev;
>> +	int len;
>> 
>> -	/* TODO: Add implementation */
>> +	len = sizeof(*ev) + sizeof(struct hal_property) + sizeof(uint32_t);
>> 
> 
> The dynamic memory allocation seems a bit overkill here since the size is
> not very big and can be determined even at compile time. I'd consider
> doing something like:
> 
> 	uint8_t buf[sizeof(struct hal_ev_adapter_props_changed) +
> 			sizeof(struct hal_property) + sizeof(uint32_t)];
> 	struct hal_ev_adapter_props_changed *ev = (void *) buf;

actually having some #define for the base len would be easier to read.

	uint8_t buf[BASELEN + sizeof(uint32_t));
 
> 
> 	...
> 
> 	ipc_send(..., sizeof(buf), buf, ...);

Of course an alternative is to use alloca to just allocate on the stack. Then no free is actually needed.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] Bluetooth: ath3k: Add support for a new AR3012 device
From: Johan Hedberg @ 2013-11-07  8:35 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: linux-bluetooth, gustavo
In-Reply-To: <1383581303-1081-1-git-send-email-sujith@msujith.org>

Hi Sujith,

On Mon, Nov 04, 2013, Sujith Manoharan wrote:
> T:  Bus=02 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#=  9 Spd=12   MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0489 ProdID=e05f Rev= 0.02
> C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> 
> Reported-by: Joshua Richenhagen <richenhagen@gmail.com>
> Signed-off-by: Sujith Manoharan <sujith@msujith.org>
> ---
>  drivers/bluetooth/ath3k.c | 2 ++
>  drivers/bluetooth/btusb.c | 1 +
>  2 files changed, 3 insertions(+)

Applied to bluetooth-next. Thanks.

Johan

^ permalink raw reply

* Re: [RFC 01/14] android: Add HAL IPC commands sanity check
From: Johan Hedberg @ 2013-11-07  8:44 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1383746970-25906-2-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Wed, Nov 06, 2013, Szymon Janc wrote:
> +#define check_no_p(opcode) \
> +	case opcode: \
> +		return len == 0;
> +
> +#define check_fix_p(opcode, msg) \
> +	case opcode: \
> +		return len == sizeof(struct msg);
> +
> +#define check_var_p(opcode, msg, mp_len_name) \
> +	case opcode: \
> +	{ \
> +		const struct msg *mp = (const struct msg *) payload; \
> +		return len == (sizeof(*mp) + mp->mp_len_name); \
> +	}
> +
> +#define check_props_p(opcode, msg) \
> +	case opcode: \
> +	{ \
> +		const struct msg *mp = (const struct msg *) payload; \
> +		const struct hal_property *hp = mp->props; \
> +		const void *p = mp->props; \
> +		int i; \
> +		for (i = 0; i < mp->num_props; i++) { \
> +			if ((void *) (p + sizeof(*hp) + hp->len) > \
> +					(void *) (payload + len)) \
> +				return false; \
> +			p += sizeof(*hp) + hp->len; \
> +			hp = p; \
> +		} \
> +		return p == payload + len; \
> +	}
> +
> +static bool check_cmd_core(uint8_t opcode, const void *payload,
> +								uint16_t len)
> +{
> +	switch (opcode) {
> +	check_fix_p(HAL_OP_REGISTER_MODULE, hal_cmd_register_module);
> +	check_fix_p(HAL_OP_UNREGISTER_MODULE, hal_cmd_unregister_module);
> +	default:
> +		return false;
> +	}
> +}

I have a feeling that this kind of approach will eventually not be very
readable/maintainable. Have you looked at how this kind of stuff is
generalized using a simple table, e.g. in btmon or the kernel mgmt
command parsing code?

Johan

^ permalink raw reply

* [PATCH 1/4] android: Make IPC helpers accept file descriptor
From: Szymon Janc @ 2013-11-07  9:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

There is no need to pass GIOChannel as writes are done immediately.
---
 android/a2dp.c    |  3 ++-
 android/adapter.c | 71 ++++++++++++++++++++++++++++++++-----------------------
 android/hid.c     | 15 ++++++++----
 android/ipc.c     | 10 ++++----
 android/ipc.h     |  4 ++--
 android/main.c    | 20 +++++++++-------
 android/pan.c     |  3 ++-
 android/socket.c  |  7 +++---
 8 files changed, 77 insertions(+), 56 deletions(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 28ab4b1..ab7719f 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -71,7 +71,8 @@ void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		break;
 	}
 
-	ipc_send_rsp(io, HAL_SERVICE_ID_A2DP, status);
+	ipc_send_rsp(g_io_channel_unix_get_fd(io), HAL_SERVICE_ID_A2DP,
+								status);
 }
 
 bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr)
diff --git a/android/adapter.c b/android/adapter.c
index cf5edcd..8a62582 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -102,8 +102,9 @@ static void adapter_name_changed(const uint8_t *name)
 	ev->props[0].len = len;
 	memcpy(ev->props->val, name, len);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-			HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
+			sizeof(buf), ev, -1);
 }
 
 static void adapter_set_name(const uint8_t *name)
@@ -143,8 +144,9 @@ static void powered_changed(void)
 
 	DBG("%u", ev.state);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-			HAL_EV_ADAPTER_STATE_CHANGED, sizeof(ev), &ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_STATE_CHANGED,
+			sizeof(ev), &ev, -1);
 }
 
 static uint8_t settings2scan_mode(void)
@@ -183,8 +185,9 @@ static void scan_mode_changed(void)
 
 	DBG("mode %u", *mode);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
+			len, ev, -1);
 
 	g_free(ev);
 }
@@ -205,8 +208,9 @@ static void adapter_class_changed(void)
 	ev->props[0].len = sizeof(uint32_t);
 	memcpy(ev->props->val, &adapter->dev_class, sizeof(uint32_t));
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
+			len, ev, -1);
 
 	g_free(ev);
 }
@@ -300,8 +304,9 @@ static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
 	ev.state = state;
 	bdaddr2android(addr, ev.bdaddr);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-			HAL_EV_BOND_STATE_CHANGED, sizeof(ev), &ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_BOND_STATE_CHANGED,
+			sizeof(ev), &ev, -1);
 }
 
 static void browse_req_free(struct browse_req *req)
@@ -334,8 +339,9 @@ static void remote_uuids_callback(struct browse_req *req)
 	ev->props[0].len = sizeof(uint128_t) * g_slist_length(req->uuids);
 	fill_uuids(req->uuids, ev->props[0].val);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-				HAL_EV_REMOTE_DEVICE_PROPS, len, ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_REMOTE_DEVICE_PROPS,
+			len, ev, -1);
 
 	g_free(ev);
 }
@@ -513,8 +519,9 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
 	memset(&hal_ev, 0, sizeof(hal_ev));
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH, HAL_EV_PIN_REQUEST,
-						sizeof(hal_ev), &hal_ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_PIN_REQUEST,
+			sizeof(hal_ev), &hal_ev, -1);
 }
 
 static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
@@ -528,8 +535,9 @@ static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
 	ev.pairing_variant = variant;
 	ev.passkey = passkey;
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH, HAL_EV_SSP_REQUEST,
-						sizeof(ev), &ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_SSP_REQUEST,
+			sizeof(ev), &ev, -1);
 }
 
 static void user_confirm_request_callback(uint16_t index, uint16_t length,
@@ -620,7 +628,8 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
 		cp.state = HAL_DISCOVERY_STATE_STOPPED;
 	}
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+						HAL_SERVICE_ID_BLUETOOTH,
 						HAL_EV_DISCOVERY_STATE_CHANGED,
 						sizeof(cp), &cp, -1);
 }
@@ -757,9 +766,9 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 		ev->num_props += fill_device_props(prop, remote, eir.class,
 								rssi, eir.name);
 
-		ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-							HAL_EV_DEVICE_FOUND,
-							buff_size, ev, -1);
+		ipc_send(g_io_channel_unix_get_fd(notification_io),
+				HAL_SERVICE_ID_BLUETOOTH, HAL_EV_DEVICE_FOUND,
+				buff_size, ev, -1);
 		g_free(buf);
 	} else {
 		struct hal_ev_remote_device_props *ev = NULL;
@@ -774,9 +783,9 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 		ev->status = HAL_STATUS_SUCCESS;
 		bdaddr2android(bdaddr, ev->bdaddr);
 
-		ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-						HAL_EV_REMOTE_DEVICE_PROPS,
-						buff_size, ev, -1);
+		ipc_send(g_io_channel_unix_get_fd(notification_io),
+				HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_REMOTE_DEVICE_PROPS, buff_size, ev, -1);
 		g_free(buf);
 	}
 
@@ -849,7 +858,8 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,
 	hal_ev.state = HAL_ACL_STATE_CONNECTED;
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH,
 			HAL_EV_ACL_STATE_CHANGED, sizeof(hal_ev), &hal_ev, -1);
 }
 
@@ -868,7 +878,8 @@ static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
 	hal_ev.state = HAL_ACL_STATE_DISCONNECTED;
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH,
 			HAL_EV_ACL_STATE_CHANGED, sizeof(hal_ev), &hal_ev, -1);
 }
 
@@ -1214,8 +1225,9 @@ static void get_address(void)
 	ev->props[0].len = sizeof(bdaddr_t);
 	bdaddr2android(&adapter->bdaddr, ev->props[0].val);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
-				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
+			len, ev, -1);
 
 	g_free(ev);
 }
@@ -1691,6 +1703,7 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 								uint16_t len)
 {
 	uint8_t status = HAL_STATUS_FAILED;
+	int sk = g_io_channel_unix_get_fd(io);
 
 	switch (opcode) {
 	case HAL_OP_ENABLE:
@@ -1798,13 +1811,13 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		goto error;
 	}
 
-	ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, -1);
+	ipc_send(sk, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, -1);
 	return;
 
 error:
 	error("Error handling command 0x%02x status %u", opcode, status);
 
-	ipc_send_rsp(io, HAL_SERVICE_ID_BLUETOOTH, status);
+	ipc_send_rsp(sk, HAL_SERVICE_ID_BLUETOOTH, status);
 }
 
 const bdaddr_t *bt_adapter_get_address(void)
diff --git a/android/hid.c b/android/hid.c
index c38c4c1..6122c9b 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -269,7 +269,8 @@ static void bt_hid_notify_state(struct hid_device *dev, uint8_t state)
 	bdaddr2android(&dev->dst, ev.bdaddr);
 	ev.state = state;
 
-	ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+				HAL_SERVICE_ID_HIDHOST,
 				HAL_EV_HID_CONN_STATE, sizeof(ev), &ev, -1);
 }
 
@@ -327,7 +328,8 @@ static void bt_hid_notify_proto_mode(struct hid_device *dev, uint8_t *buf,
 		ev.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
 	}
 
-	ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+				HAL_SERVICE_ID_HIDHOST,
 				HAL_EV_HID_PROTO_MODE, sizeof(ev), &ev, -1);
 }
 
@@ -370,7 +372,8 @@ static void bt_hid_notify_get_report(struct hid_device *dev, uint8_t *buf,
 	}
 
 send:
-	ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_GET_REPORT,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_GET_REPORT,
 						ev_len, ev, -1);
 	g_free(ev);
 }
@@ -450,7 +453,8 @@ static void bt_hid_set_info(struct hid_device *dev)
 	memset(ev.descr, 0, sizeof(ev.descr));
 	memcpy(ev.descr, dev->rd_data, ev.descr_len);
 
-	ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_INFO,
+	ipc_send(g_io_channel_unix_get_fd(notification_io),
+			HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_INFO,
 							sizeof(ev), &ev, -1);
 }
 
@@ -964,7 +968,8 @@ void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
 		break;
 	}
 
-	ipc_send_rsp(io, HAL_SERVICE_ID_HIDHOST, status);
+	ipc_send_rsp(g_io_channel_unix_get_fd(io), HAL_SERVICE_ID_HIDHOST,
+								status);
 }
 
 static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
diff --git a/android/ipc.c b/android/ipc.c
index e672bf8..9a8657d 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -32,13 +32,11 @@
 #include <signal.h>
 #include <sys/socket.h>
 
-#include <glib.h>
-
 #include "hal-msg.h"
 #include "ipc.h"
 #include "log.h"
 
-void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
+void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
 							void *param, int fd)
 {
 	struct msghdr msg;
@@ -76,17 +74,17 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
 		msg.msg_controllen = sizeof(cmsgbuf);
 	}
 
-	if (sendmsg(g_io_channel_unix_get_fd(io), &msg, 0) < 0) {
+	if (sendmsg(sk, &msg, 0) < 0) {
 		error("IPC send failed, terminating :%s", strerror(errno));
 		raise(SIGTERM);
 	}
 }
 
-void ipc_send_rsp(GIOChannel *io, uint8_t service_id, uint8_t status)
+void ipc_send_rsp(int sk, uint8_t service_id, uint8_t status)
 {
 	struct hal_status s;
 
 	s.code = status;
 
-	ipc_send(io, service_id, HAL_OP_STATUS, sizeof(s), &s, -1);
+	ipc_send(sk, service_id, HAL_OP_STATUS, sizeof(s), &s, -1);
 }
diff --git a/android/ipc.h b/android/ipc.h
index 093c84c..cf0f3d6 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -21,6 +21,6 @@
  *
  */
 
-void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len,
+void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
 							void *param, int fd);
-void ipc_send_rsp(GIOChannel *io, uint8_t service_id, uint8_t status);
+void ipc_send_rsp(int sk, uint8_t service_id, uint8_t status);
diff --git a/android/main.c b/android/main.c
index 75004cf..558ca11 100644
--- a/android/main.c
+++ b/android/main.c
@@ -117,13 +117,14 @@ static void service_register(void *buf, uint16_t len)
 
 	services[m->service_id] = true;
 
-	ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, 0,
-								NULL, -1);
+	ipc_send(g_io_channel_unix_get_fd(hal_cmd_io), HAL_SERVICE_ID_CORE,
+					HAL_OP_REGISTER_MODULE, 0, NULL, -1);
 
 	info("Service ID=%u registered", m->service_id);
 	return;
 failed:
-	ipc_send_rsp(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED);
+	ipc_send_rsp(g_io_channel_unix_get_fd(hal_cmd_io),
+				HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED);
 }
 
 static void service_unregister(void *buf, uint16_t len)
@@ -158,13 +159,14 @@ static void service_unregister(void *buf, uint16_t len)
 
 	services[m->service_id] = false;
 
-	ipc_send(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
-								0, NULL, -1);
+	ipc_send(g_io_channel_unix_get_fd(hal_cmd_io), HAL_SERVICE_ID_CORE,
+					HAL_OP_UNREGISTER_MODULE, 0, NULL, -1);
 
 	info("Service ID=%u unregistered", m->service_id);
 	return;
 failed:
-	ipc_send_rsp(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED);
+	ipc_send_rsp(g_io_channel_unix_get_fd(hal_cmd_io),
+				HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED);
 }
 
 static void handle_service_core(uint8_t opcode, void *buf, uint16_t len)
@@ -177,8 +179,8 @@ static void handle_service_core(uint8_t opcode, void *buf, uint16_t len)
 		service_unregister(buf, len);
 		break;
 	default:
-		ipc_send_rsp(hal_cmd_io, HAL_SERVICE_ID_CORE,
-							HAL_STATUS_FAILED);
+		ipc_send_rsp(g_io_channel_unix_get_fd(hal_cmd_io),
+				HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED);
 		break;
 	}
 }
@@ -274,7 +276,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 								msg->len);
 		break;
 	default:
-		ipc_send_rsp(hal_cmd_io, msg->service_id, HAL_STATUS_FAILED);
+		ipc_send_rsp(fd, msg->service_id, HAL_STATUS_FAILED);
 		break;
 	}
 
diff --git a/android/pan.c b/android/pan.c
index 0cc3590..0f6f1c7 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -88,7 +88,8 @@ void bt_pan_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		break;
 	}
 
-	ipc_send_rsp(io, HAL_SERVICE_ID_A2DP, status);
+	ipc_send_rsp(g_io_channel_unix_get_fd(io), HAL_SERVICE_ID_A2DP,
+								status);
 }
 
 bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr)
diff --git a/android/socket.c b/android/socket.c
index e32be46..c1b0c1d 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -53,6 +53,7 @@ static int handle_connect(void *buf)
 void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 							uint16_t len)
 {
+	int sk = g_io_channel_unix_get_fd(io);
 	int fd;
 
 	switch (opcode) {
@@ -61,21 +62,21 @@ void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		if (fd < 0)
 			break;
 
-		ipc_send(io, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
+		ipc_send(sk, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
 		return;
 	case HAL_OP_SOCK_CONNECT:
 		fd = handle_connect(buf);
 		if (fd < 0)
 			break;
 
-		ipc_send(io, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
+		ipc_send(sk, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
 		return;
 	default:
 		DBG("Unhandled command, opcode 0x%x", opcode);
 		break;
 	}
 
-	ipc_send_rsp(io, HAL_SERVICE_ID_SOCK, HAL_STATUS_FAILED);
+	ipc_send_rsp(sk, HAL_SERVICE_ID_SOCK, HAL_STATUS_FAILED);
 }
 
 bool bt_socket_register(GIOChannel *io, const bdaddr_t *addr)
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 2/4] android: Pass notification socket fd to service handlers
From: Szymon Janc @ 2013-11-07  9:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383815437-521-1-git-send-email-szymon.janc@tieto.com>

IPC helpers were converted to accept socket, not GIOChannel so there
is no need of passing former to handlers.
---
 android/a2dp.c    | 15 +++++------
 android/a2dp.h    |  5 ++--
 android/adapter.c | 78 +++++++++++++++++++++----------------------------------
 android/adapter.h |  6 ++---
 android/hid.c     | 30 +++++++++------------
 android/hid.h     |  4 +--
 android/main.c    | 26 ++++++++-----------
 android/pan.c     | 15 +++++------
 android/pan.h     |  4 +--
 android/socket.c  |  6 ++---
 android/socket.h  |  5 ++--
 11 files changed, 77 insertions(+), 117 deletions(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index ab7719f..0d3bfc5 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -38,7 +38,7 @@
 #include "hal-msg.h"
 #include "ipc.h"
 
-static GIOChannel *notification_io = NULL;
+static int notification_sk = -1;
 
 static uint8_t bt_a2dp_connect(struct hal_cmd_av_connect *cmd, uint16_t len)
 {
@@ -54,8 +54,7 @@ static uint8_t bt_a2dp_disconnect(struct hal_cmd_av_connect *cmd, uint16_t len)
 	return HAL_STATUS_FAILED;
 }
 
-void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-								uint16_t len)
+void bt_a2dp_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 {
 	uint8_t status = HAL_STATUS_FAILED;
 
@@ -71,15 +70,14 @@ void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		break;
 	}
 
-	ipc_send_rsp(g_io_channel_unix_get_fd(io), HAL_SERVICE_ID_A2DP,
-								status);
+	ipc_send_rsp(sk, HAL_SERVICE_ID_A2DP, status);
 }
 
-bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr)
+bool bt_a2dp_register(int sk, const bdaddr_t *addr)
 {
 	DBG("");
 
-	notification_io = g_io_channel_ref(io);
+	notification_sk = sk;
 
 	return true;
 }
@@ -88,6 +86,5 @@ void bt_a2dp_unregister(void)
 {
 	DBG("");
 
-	g_io_channel_unref(notification_io);
-	notification_io = NULL;
+	notification_sk = -1;
 }
diff --git a/android/a2dp.h b/android/a2dp.h
index a5ac53e..3531618 100644
--- a/android/a2dp.h
+++ b/android/a2dp.h
@@ -21,8 +21,7 @@
  *
  */
 
-void bt_a2dp_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-								uint16_t len);
+void bt_a2dp_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
 
-bool bt_a2dp_register(GIOChannel *io, const bdaddr_t *addr);
+bool bt_a2dp_register(int sk, const bdaddr_t *addr);
 void bt_a2dp_unregister(void);
diff --git a/android/adapter.c b/android/adapter.c
index 8a62582..69b3695 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -48,7 +48,7 @@
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
 
-static GIOChannel *notification_io = NULL;
+static int notification_sk = -1;
 /* This list contains addresses which are asked for records */
 static GSList *browse_reqs;
 
@@ -102,9 +102,8 @@ static void adapter_name_changed(const uint8_t *name)
 	ev->props[0].len = len;
 	memcpy(ev->props->val, name, len);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
-			sizeof(buf), ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+			HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
 }
 
 static void adapter_set_name(const uint8_t *name)
@@ -144,9 +143,8 @@ static void powered_changed(void)
 
 	DBG("%u", ev.state);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_STATE_CHANGED,
-			sizeof(ev), &ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+			HAL_EV_ADAPTER_STATE_CHANGED, sizeof(ev), &ev, -1);
 }
 
 static uint8_t settings2scan_mode(void)
@@ -185,9 +183,8 @@ static void scan_mode_changed(void)
 
 	DBG("mode %u", *mode);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
-			len, ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
 
 	g_free(ev);
 }
@@ -208,9 +205,8 @@ static void adapter_class_changed(void)
 	ev->props[0].len = sizeof(uint32_t);
 	memcpy(ev->props->val, &adapter->dev_class, sizeof(uint32_t));
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
-			len, ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
 
 	g_free(ev);
 }
@@ -304,9 +300,8 @@ static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
 	ev.state = state;
 	bdaddr2android(addr, ev.bdaddr);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_BOND_STATE_CHANGED,
-			sizeof(ev), &ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+			HAL_EV_BOND_STATE_CHANGED, sizeof(ev), &ev, -1);
 }
 
 static void browse_req_free(struct browse_req *req)
@@ -339,9 +334,8 @@ static void remote_uuids_callback(struct browse_req *req)
 	ev->props[0].len = sizeof(uint128_t) * g_slist_length(req->uuids);
 	fill_uuids(req->uuids, ev->props[0].val);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_REMOTE_DEVICE_PROPS,
-			len, ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_REMOTE_DEVICE_PROPS, len, ev, -1);
 
 	g_free(ev);
 }
@@ -519,9 +513,8 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
 	memset(&hal_ev, 0, sizeof(hal_ev));
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_PIN_REQUEST,
-			sizeof(hal_ev), &hal_ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH, HAL_EV_PIN_REQUEST,
+						sizeof(hal_ev), &hal_ev, -1);
 }
 
 static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
@@ -535,9 +528,8 @@ static void send_ssp_request(const bdaddr_t *addr, uint8_t variant,
 	ev.pairing_variant = variant;
 	ev.passkey = passkey;
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_SSP_REQUEST,
-			sizeof(ev), &ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH, HAL_EV_SSP_REQUEST,
+							sizeof(ev), &ev, -1);
 }
 
 static void user_confirm_request_callback(uint16_t index, uint16_t length,
@@ -628,10 +620,8 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
 		cp.state = HAL_DISCOVERY_STATE_STOPPED;
 	}
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-						HAL_SERVICE_ID_BLUETOOTH,
-						HAL_EV_DISCOVERY_STATE_CHANGED,
-						sizeof(cp), &cp, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+			HAL_EV_DISCOVERY_STATE_CHANGED, sizeof(cp), &cp, -1);
 }
 
 static void confirm_name_complete(uint8_t status, uint16_t length,
@@ -766,9 +756,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 		ev->num_props += fill_device_props(prop, remote, eir.class,
 								rssi, eir.name);
 
-		ipc_send(g_io_channel_unix_get_fd(notification_io),
-				HAL_SERVICE_ID_BLUETOOTH, HAL_EV_DEVICE_FOUND,
-				buff_size, ev, -1);
+		ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_DEVICE_FOUND, buff_size, ev, -1);
 		g_free(buf);
 	} else {
 		struct hal_ev_remote_device_props *ev = NULL;
@@ -783,8 +772,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 		ev->status = HAL_STATUS_SUCCESS;
 		bdaddr2android(bdaddr, ev->bdaddr);
 
-		ipc_send(g_io_channel_unix_get_fd(notification_io),
-				HAL_SERVICE_ID_BLUETOOTH,
+		ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
 				HAL_EV_REMOTE_DEVICE_PROPS, buff_size, ev, -1);
 		g_free(buf);
 	}
@@ -858,8 +846,7 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,
 	hal_ev.state = HAL_ACL_STATE_CONNECTED;
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH,
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
 			HAL_EV_ACL_STATE_CHANGED, sizeof(hal_ev), &hal_ev, -1);
 }
 
@@ -878,8 +865,7 @@ static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
 	hal_ev.state = HAL_ACL_STATE_DISCONNECTED;
 	bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH,
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
 			HAL_EV_ACL_STATE_CHANGED, sizeof(hal_ev), &hal_ev, -1);
 }
 
@@ -1225,9 +1211,8 @@ static void get_address(void)
 	ev->props[0].len = sizeof(bdaddr_t);
 	bdaddr2android(&adapter->bdaddr, ev->props[0].val);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_BLUETOOTH, HAL_EV_ADAPTER_PROPS_CHANGED,
-			len, ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);
 
 	g_free(ev);
 }
@@ -1699,11 +1684,9 @@ static uint8_t get_remote_services(void *buf, uint16_t len)
 	return browse_remote_sdp(&addr);
 }
 
-void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-								uint16_t len)
+void bt_adapter_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 {
 	uint8_t status = HAL_STATUS_FAILED;
-	int sk = g_io_channel_unix_get_fd(io);
 
 	switch (opcode) {
 	case HAL_OP_ENABLE:
@@ -1825,11 +1808,11 @@ const bdaddr_t *bt_adapter_get_address(void)
 	return &adapter->bdaddr;
 }
 
-bool bt_adapter_register(GIOChannel *io)
+bool bt_adapter_register(int sk)
 {
 	DBG("");
 
-	notification_io = g_io_channel_ref(io);
+	notification_sk = sk;
 
 	return true;
 }
@@ -1838,6 +1821,5 @@ void bt_adapter_unregister(void)
 {
 	DBG("");
 
-	g_io_channel_unref(notification_io);
-	notification_io = NULL;
+	notification_sk = -1;
 }
diff --git a/android/adapter.h b/android/adapter.h
index 2afc67a..08f4f48 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <glib.h>
 
 #include "lib/bluetooth.h"
 
@@ -33,10 +32,9 @@ typedef void (*bt_adapter_ready)(int err);
 void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
 							bt_adapter_ready cb);
 
-void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-								uint16_t len);
+void bt_adapter_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
 
 const bdaddr_t *bt_adapter_get_address(void);
 
-bool bt_adapter_register(GIOChannel *io);
+bool bt_adapter_register(int sk);
 void bt_adapter_unregister(void);
diff --git a/android/hid.c b/android/hid.c
index 6122c9b..93b828c 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -73,7 +73,7 @@
 /* HID GET REPORT Size Field */
 #define HID_GET_REPORT_SIZE_FIELD	0x08
 
-static GIOChannel *notification_io = NULL;
+static int notification_sk = -1;
 static GIOChannel *ctrl_io = NULL;
 static GIOChannel *intr_io = NULL;
 static GSList *devices = NULL;
@@ -269,8 +269,7 @@ static void bt_hid_notify_state(struct hid_device *dev, uint8_t state)
 	bdaddr2android(&dev->dst, ev.bdaddr);
 	ev.state = state;
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-				HAL_SERVICE_ID_HIDHOST,
+	ipc_send(notification_sk, HAL_SERVICE_ID_HIDHOST,
 				HAL_EV_HID_CONN_STATE, sizeof(ev), &ev, -1);
 }
 
@@ -328,8 +327,7 @@ static void bt_hid_notify_proto_mode(struct hid_device *dev, uint8_t *buf,
 		ev.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
 	}
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-				HAL_SERVICE_ID_HIDHOST,
+	ipc_send(notification_sk, HAL_SERVICE_ID_HIDHOST,
 				HAL_EV_HID_PROTO_MODE, sizeof(ev), &ev, -1);
 }
 
@@ -372,9 +370,8 @@ static void bt_hid_notify_get_report(struct hid_device *dev, uint8_t *buf,
 	}
 
 send:
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_GET_REPORT,
-						ev_len, ev, -1);
+	ipc_send(notification_sk, HAL_SERVICE_ID_HIDHOST,
+					HAL_EV_HID_GET_REPORT, ev_len, ev, -1);
 	g_free(ev);
 }
 
@@ -453,8 +450,7 @@ static void bt_hid_set_info(struct hid_device *dev)
 	memset(ev.descr, 0, sizeof(ev.descr));
 	memcpy(ev.descr, dev->rd_data, ev.descr_len);
 
-	ipc_send(g_io_channel_unix_get_fd(notification_io),
-			HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_INFO,
+	ipc_send(notification_sk, HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_INFO,
 							sizeof(ev), &ev, -1);
 }
 
@@ -931,7 +927,7 @@ static uint8_t bt_hid_send_data(struct hal_cmd_hid_send_data *cmd,
 	return HAL_STATUS_FAILED;
 }
 
-void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
+void bt_hid_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 {
 	uint8_t status = HAL_STATUS_FAILED;
 
@@ -968,8 +964,7 @@ void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len)
 		break;
 	}
 
-	ipc_send_rsp(g_io_channel_unix_get_fd(io), HAL_SERVICE_ID_HIDHOST,
-								status);
+	ipc_send_rsp(sk, HAL_SERVICE_ID_HIDHOST, status);
 }
 
 static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
@@ -1043,15 +1038,13 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	}
 }
 
-bool bt_hid_register(GIOChannel *io, const bdaddr_t *addr)
+bool bt_hid_register(int sk, 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,
@@ -1075,6 +1068,8 @@ bool bt_hid_register(GIOChannel *io, const bdaddr_t *addr)
 		return false;
 	}
 
+	notification_sk = sk;
+
 	return true;
 }
 
@@ -1082,8 +1077,7 @@ void bt_hid_unregister(void)
 {
 	DBG("");
 
-	g_io_channel_unref(notification_io);
-	notification_io = NULL;
+	notification_sk = -1;
 
 	if (ctrl_io) {
 		g_io_channel_shutdown(ctrl_io, TRUE, NULL);
diff --git a/android/hid.h b/android/hid.h
index 674b35a..688086a 100644
--- a/android/hid.h
+++ b/android/hid.h
@@ -21,7 +21,7 @@
  *
  */
 
-void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len);
+void bt_hid_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
 
-bool bt_hid_register(GIOChannel *io, const bdaddr_t *addr);
+bool bt_hid_register(int sk, const bdaddr_t *addr);
 void bt_hid_unregister(void);
diff --git a/android/main.c b/android/main.c
index 558ca11..2c587b1 100644
--- a/android/main.c
+++ b/android/main.c
@@ -80,33 +80,34 @@ static void service_register(void *buf, uint16_t len)
 {
 	struct hal_cmd_register_module *m = buf;
 	const bdaddr_t *adapter_bdaddr = bt_adapter_get_address();
+	int sk = g_io_channel_unix_get_fd(hal_notif_io);
 
 	if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id])
 		goto failed;
 
 	switch (m->service_id) {
 	case HAL_SERVICE_ID_BLUETOOTH:
-		if (!bt_adapter_register(hal_notif_io))
+		if (!bt_adapter_register(sk))
 			goto failed;
 
 		break;
 	case HAL_SERVICE_ID_SOCK:
-		if (!bt_socket_register(hal_notif_io, adapter_bdaddr))
+		if (!bt_socket_register(sk, adapter_bdaddr))
 			goto failed;
 
 		break;
 	case HAL_SERVICE_ID_HIDHOST:
-		if (!bt_hid_register(hal_notif_io, adapter_bdaddr))
+		if (!bt_hid_register(sk, adapter_bdaddr))
 			goto failed;
 
 		break;
 	case HAL_SERVICE_ID_A2DP:
-		if (!bt_a2dp_register(hal_notif_io, adapter_bdaddr))
+		if (!bt_a2dp_register(sk, adapter_bdaddr))
 			goto failed;
 
 		break;
 	case HAL_SERVICE_ID_PAN:
-		if (!bt_a2dp_register(hal_notif_io, adapter_bdaddr))
+		if (!bt_a2dp_register(sk, adapter_bdaddr))
 			goto failed;
 
 		break;
@@ -256,24 +257,19 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 		handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
 		break;
 	case HAL_SERVICE_ID_BLUETOOTH:
-		bt_adapter_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
-								msg->len);
+		bt_adapter_handle_cmd(fd, msg->opcode, msg->payload, msg->len);
 		break;
 	case HAL_SERVICE_ID_HIDHOST:
-		bt_hid_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
-								msg->len);
+		bt_hid_handle_cmd(fd, msg->opcode, msg->payload, msg->len);
 		break;
 	case HAL_SERVICE_ID_SOCK:
-		bt_sock_handle_cmd(hal_cmd_io, msg->opcode, msg->payload,
-								msg->len);
+		bt_sock_handle_cmd(fd, 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);
+		bt_a2dp_handle_cmd(fd, 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);
+		bt_pan_handle_cmd(fd, msg->opcode, msg->payload, msg->len);
 		break;
 	default:
 		ipc_send_rsp(fd, msg->service_id, HAL_STATUS_FAILED);
diff --git a/android/pan.c b/android/pan.c
index 0f6f1c7..061e611 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -35,7 +35,7 @@
 #include "hal-msg.h"
 #include "ipc.h"
 
-static GIOChannel *notification_io = NULL;
+static int notification_sk = -1;
 
 static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)
 {
@@ -65,8 +65,7 @@ static uint8_t bt_pan_disconnect(struct hal_cmd_pan_connect *cmd, uint16_t len)
 	return HAL_STATUS_FAILED;
 }
 
-void bt_pan_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-								uint16_t len)
+void bt_pan_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 {
 	uint8_t status = HAL_STATUS_FAILED;
 
@@ -88,15 +87,14 @@ void bt_pan_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 		break;
 	}
 
-	ipc_send_rsp(g_io_channel_unix_get_fd(io), HAL_SERVICE_ID_A2DP,
-								status);
+	ipc_send_rsp(sk, HAL_SERVICE_ID_A2DP, status);
 }
 
-bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr)
+bool bt_pan_register(int sk, const bdaddr_t *addr)
 {
 	DBG("");
 
-	notification_io = g_io_channel_ref(io);
+	notification_sk = sk;
 
 	return true;
 }
@@ -105,6 +103,5 @@ void bt_pan_unregister(void)
 {
 	DBG("");
 
-	g_io_channel_unref(notification_io);
-	notification_io = NULL;
+	notification_sk = -1;
 }
diff --git a/android/pan.h b/android/pan.h
index 1ffba9d..2430378 100644
--- a/android/pan.h
+++ b/android/pan.h
@@ -21,7 +21,7 @@
  *
  */
 
-void bt_pan_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len);
+void bt_pan_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
 
-bool bt_pan_register(GIOChannel *io, const bdaddr_t *addr);
+bool bt_pan_register(int sk, const bdaddr_t *addr);
 void bt_pan_unregister(void);
diff --git a/android/socket.c b/android/socket.c
index c1b0c1d..c283c5f 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -50,10 +50,8 @@ static int handle_connect(void *buf)
 	return -1;
 }
 
-void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-							uint16_t len)
+void bt_sock_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 {
-	int sk = g_io_channel_unix_get_fd(io);
 	int fd;
 
 	switch (opcode) {
@@ -79,7 +77,7 @@ void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
 	ipc_send_rsp(sk, HAL_SERVICE_ID_SOCK, HAL_STATUS_FAILED);
 }
 
-bool bt_socket_register(GIOChannel *io, const bdaddr_t *addr)
+bool bt_socket_register(int sk, const bdaddr_t *addr)
 {
 	DBG("");
 
diff --git a/android/socket.h b/android/socket.h
index 2b3b940..7aa5574 100644
--- a/android/socket.h
+++ b/android/socket.h
@@ -21,8 +21,7 @@
  *
  */
 
-void bt_sock_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
-						uint16_t len);
+void bt_sock_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len);
 
-bool bt_socket_register(GIOChannel *io, const bdaddr_t *addr);
+bool bt_socket_register(int sk, const bdaddr_t *addr);
 void bt_socket_unregister(void);
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 3/4] android: Remove includes from adapter.h
From: Szymon Janc @ 2013-11-07  9:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383815437-521-1-git-send-email-szymon.janc@tieto.com>

This is internal header and dependencies should be included in
respective .c files.
---
 android/adapter.c | 1 +
 android/adapter.h | 6 ------
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 69b3695..a84aaf8 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <errno.h>
+#include <stdlib.h>
 
 #include <glib.h>
 
diff --git a/android/adapter.h b/android/adapter.h
index 08f4f48..c62b859 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -21,12 +21,6 @@
  *
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "lib/bluetooth.h"
-
 typedef void (*bt_adapter_ready)(int err);
 
 void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 4/4] android: Use payload member to access message data
From: Szymon Janc @ 2013-11-07  9:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1383815437-521-1-git-send-email-szymon.janc@tieto.com>

This make it similar to other places in code.
---
 android/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/main.c b/android/main.c
index 2c587b1..71fc60b 100644
--- a/android/main.c
+++ b/android/main.c
@@ -254,7 +254,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 
 	switch (msg->service_id) {
 	case HAL_SERVICE_ID_CORE:
-		handle_service_core(msg->opcode, buf + sizeof(*msg), msg->len);
+		handle_service_core(msg->opcode, msg->payload, msg->len);
 		break;
 	case HAL_SERVICE_ID_BLUETOOTH:
 		bt_adapter_handle_cmd(fd, msg->opcode, msg->payload, msg->len);
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 1/2 v2] android: Use BASELEN define for property changed
From: Lukasz Rymanowski @ 2013-11-07  9:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski

---
 android/adapter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/android/adapter.c b/android/adapter.c
index 1d462c8..45a40f9 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -47,6 +47,8 @@
 
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
+#define BASELEN_PROP_CHANGED sizeof(struct hal_ev_adapter_props_changed) \
+				+ (sizeof(struct hal_property))
 
 static GIOChannel *notification_io = NULL;
 /* This list contains addresses which are asked for records */
@@ -90,7 +92,7 @@ static void adapter_name_changed(const uint8_t *name)
 {
 	struct hal_ev_adapter_props_changed *ev;
 	size_t len = strlen((const char *) name);
-	uint8_t buf[sizeof(*ev) + sizeof(struct hal_property) + len];
+	uint8_t buf[BASELEN_PROP_CHANGED + len];
 
 	memset(buf, 0, sizeof(buf));
 	ev = (void *) buf;
-- 
1.8.4


^ permalink raw reply related

* [PATCH 2/2] android: Add set/get for discovery timeout
From: Lukasz Rymanowski @ 2013-11-07  9:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, szymon.janc, Lukasz Rymanowski
In-Reply-To: <1383815991-18523-1-git-send-email-lukasz.rymanowski@tieto.com>

Android handles discoverable timeout in Settings app, however still
expects BT stack to maintain this value so we should do it as well.
Otherwise we will get some unexpected behaviour.
For now we keep discovery_timeout only during runtime, but we need to move
it to some local storage once we will have it.

Note: That since Android Settings up handles timer there is no reason to
use discovery timer we have in kernel.
---
 android/adapter.c | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 45a40f9..92e51b2 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -47,6 +47,9 @@
 
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
+/* Default discoverable timeout 120sec as in Android */
+#define DEFAULT_DISCOVERABLE_TIMEOUT 120
+
 #define BASELEN_PROP_CHANGED sizeof(struct hal_ev_adapter_props_changed) \
 				+ (sizeof(struct hal_property))
 
@@ -69,6 +72,7 @@ struct bt_adapter {
 	uint32_t current_settings;
 
 	bool discovering;
+	uint32_t discoverable_timeout;
 };
 
 struct browse_req {
@@ -1103,6 +1107,17 @@ static uint8_t set_adapter_name(uint8_t *name, uint16_t len)
 	return HAL_STATUS_FAILED;
 }
 
+static uint8_t set_discoverable_timeout(uint8_t *timeout)
+{
+	/* Android handles discoverable timeout in Settings app.
+	 * There is no need to use kernel feature for that.
+	 * Just need to store this value here */
+
+	/* TODO: This should be in some storage */
+	memcpy(&adapter->discoverable_timeout, timeout, sizeof(uint32_t));
+
+	return HAL_STATUS_SUCCESS;
+}
 static void read_info_complete(uint8_t status, uint16_t length, const void *param,
 							void *user_data)
 {
@@ -1171,6 +1186,8 @@ void bt_adapter_init(uint16_t index, struct mgmt *mgmt, bt_adapter_ready cb)
 	adapter->index = index;
 	adapter->discovering = false;
 	adapter->ready = cb;
+	/* TODO: Read it from some storage */
+	adapter->discoverable_timeout = DEFAULT_DISCOVERABLE_TIMEOUT;
 
 	if (mgmt_send(mgmt, MGMT_OP_READ_INFO, index, 0, NULL,
 					read_info_complete, NULL, NULL) > 0)
@@ -1288,11 +1305,25 @@ static bool get_devices(void)
 
 static bool get_discoverable_timeout(void)
 {
-	DBG("Not implemented");
+	struct hal_ev_adapter_props_changed *ev;
+	int len = sizeof(uint32_t);
+	uint8_t buf[BASELEN_PROP_CHANGED + len];
 
-	/* TODO: Add implementation */
 
-	return false;
+	memset(buf, 0, sizeof(buf));
+	ev = (void *) buf;
+
+	ev->num_props = 1;
+	ev->status = HAL_STATUS_SUCCESS;
+
+	ev->props[0].type = HAL_PROP_ADAPTER_DISC_TIMEOUT;
+	ev->props[0].len = len;
+	memcpy(&ev->props[0].val, &adapter->discoverable_timeout, sizeof(uint32_t));
+
+	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+				HAL_EV_ADAPTER_PROPS_CHANGED, sizeof(buf), ev, -1);
+
+	return true;
 }
 
 static bool get_property(void *buf, uint16_t len)
@@ -1443,6 +1474,7 @@ static uint8_t set_property(void *buf, uint16_t len)
 	case HAL_PROP_ADAPTER_NAME:
 		return set_adapter_name(cmd->val, cmd->len);
 	case HAL_PROP_ADAPTER_DISC_TIMEOUT:
+		return set_discoverable_timeout(cmd->val);
 	default:
 		DBG("Unhandled property type 0x%x", cmd->type);
 		return HAL_STATUS_FAILED;
-- 
1.8.4


^ permalink raw reply related

* [RFC 0/3] Fix ascii to hex conversion in HAL to deamon ipc PDU
From: Ravi kumar Veeramally @ 2013-11-07  9:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

In case of set report and send data HAL receives the data in ascii format
but it should be in hex. This patch set updates the document, provides
utility and fix the issue in set report case.

Ravi kumar Veeramally (3):
  android/hid: Remove fixed number of hid set report data length in ipc
    doc
  android/hid: Add a ascii2hex utility
  android/hid: Fix set report data format

 android/Android.mk      |  1 +
 android/Makefile.am     |  2 +-
 android/hal-ipc-api.txt |  2 +-
 android/hal-msg.h       |  2 +-
 android/hid.c           | 12 +++++++---
 android/utils.c         | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
 android/utils.h         |  3 +++
 7 files changed, 76 insertions(+), 6 deletions(-)
 create mode 100644 android/utils.c

-- 
1.8.3.2


^ permalink raw reply

* [RFC 1/3] android/hid: Remove fixed number of hid set report data length in ipc doc
From: Ravi kumar Veeramally @ 2013-11-07  9:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383816421-18878-1-git-send-email-ravikumar.veeramally@linux.intel.com>

HAL receives data in ascii format but it should be in hex format. So remove
fixed size of report data length and depend on report length parameter.
---
 android/hal-ipc-api.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index c39cb0d..297f565 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -553,7 +553,7 @@ Commands and responses:
 		Command parameters: Remote address (6 octets)
 		                    Report type (1 octet)
 		                    Report length (2 octets)
-		                    Report data (670 octets)
+		                    Report data (Report length)
 
 		Response parameters: <none>
 
-- 
1.8.3.2


^ permalink raw reply related

* [RFC 2/3] android/hid: Add a ascii2hex utility
From: Ravi kumar Veeramally @ 2013-11-07  9:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383816421-18878-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Data from few interfaces on HAL is in ascii format but it should be
in hex format. This conversion utility does that job.
---
 android/Android.mk  |  1 +
 android/Makefile.am |  2 +-
 android/utils.c     | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/utils.h     |  3 +++
 4 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 android/utils.c

diff --git a/android/Android.mk b/android/Android.mk
index d76dfaf..9493f89 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -27,6 +27,7 @@ LOCAL_SRC_FILES := \
 	ipc.c ipc.h \
 	a2dp.c \
 	pan.c \
+	utils.c \
 	../src/log.c \
 	../src/shared/mgmt.c \
 	../src/shared/util.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 8619641..eb0c8d7 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -9,7 +9,7 @@ noinst_PROGRAMS += android/bluetoothd
 android_bluetoothd_SOURCES = android/main.c \
 				src/log.c \
 				android/hal-msg.h \
-				android/utils.h \
+				android/utils.h android/utils.c \
 				src/sdpd-database.c src/sdpd-server.c \
 				src/sdpd-service.c src/sdpd-request.c \
 				src/glib-helper.h src/glib-helper.c \
diff --git a/android/utils.c b/android/utils.c
new file mode 100644
index 0000000..9179a6f
--- /dev/null
+++ b/android/utils.c
@@ -0,0 +1,60 @@
+/*
+ *
+ *  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 <glib.h>
+#include "utils.h"
+
+static inline uint8_t ascii2hex_c(uint8_t ascii)
+{
+	return g_ascii_isdigit(ascii) ? (ascii - '0') :
+				(g_ascii_toupper(ascii) - 'A' + 10);
+}
+
+int ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex)
+{
+	uint8_t h;
+	int i;
+
+	if (!ascii || !hex)
+		return -1;
+
+	i = 0;
+
+	while (i < ascii_len) {
+		h = ascii2hex_c(ascii[i++]) << 4;
+
+		if (!(i < ascii_len)) {
+			*hex++ = h;
+			break;
+		}
+
+		h |= ascii2hex_c(ascii[i++]);
+		*hex++ = h;
+	}
+
+	return 0;
+}
diff --git a/android/utils.h b/android/utils.h
index 5b009bc..2ec3fc1 100644
--- a/android/utils.h
+++ b/android/utils.h
@@ -21,6 +21,7 @@
  *
  */
 
+#include "lib/bluetooth.h"
 
 static inline void android2bdaddr(const void *buf, bdaddr_t *dst)
 {
@@ -31,3 +32,5 @@ static inline void bdaddr2android(const bdaddr_t *src, void *buf)
 {
 	baswap(buf, src);
 }
+
+int ascii2hex(const uint8_t *ascii, int ascii_len, uint8_t *hex);
-- 
1.8.3.2


^ permalink raw reply related

* [RFC 3/3] android/hid: Fix set report data format
From: Ravi kumar Veeramally @ 2013-11-07  9:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383816421-18878-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Data is in ascii format from HAL. Convert it to hex and send it to
hid device.
---
 android/hal-msg.h |  2 +-
 android/hid.c     | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index a5e5c76..89366df 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -293,7 +293,7 @@ struct hal_cmd_hid_set_report {
 	uint8_t  bdaddr[6];
 	uint8_t  type;
 	uint16_t len;
-	uint8_t  data[670];
+	uint8_t  data[0];
 } __attribute__((packed));
 
 #define HAL_OP_HID_SEND_DATA		0x09
diff --git a/android/hid.c b/android/hid.c
index c38c4c1..e28e22d 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -898,18 +898,24 @@ static uint8_t bt_hid_set_report(struct hal_cmd_hid_set_report *cmd,
 		return HAL_STATUS_FAILED;
 
 	dev = l->data;
-	req_size = 1 + cmd->len;
+	/* Report data coming from HAL is in ascii format, so convert
+	 * it to hex and calculate length according to it. */
+	req_size = 1 + ((cmd->len + 1) / 2);
 	req = g_try_malloc0(req_size);
 	if (!req)
 		return HAL_STATUS_NOMEM;
 
 	req[0] = HID_MSG_SET_REPORT | cmd->type;
-	memcpy(req + 1, cmd->data, req_size - 1);
+
+	if (!ascii2hex(cmd->data, cmd->len, (req + 1))) {
+		g_free(req);
+		return HAL_STATUS_FAILED;
+	}
 
 	fd = g_io_channel_unix_get_fd(dev->ctrl_io);
 
 	if (write(fd, req, req_size) < 0) {
-		error("error while querying device protocol");
+		error("error while sending report");
 		g_free(req);
 		return HAL_STATUS_FAILED;
 	}
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/2] android: Remove redundant command complete callback
From: Jakub Tyszkowski @ 2013-11-07  9:31 UTC (permalink / raw)
  To: linux-bluetooth

This patch removes command complete callback used only for verbose error
reporting.

---
 android/adapter.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/android/adapter.c b/android/adapter.c
index 1d462c8..da5984a 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -625,14 +625,6 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
 						sizeof(cp), &cp, -1);
 }
 
-static void confirm_name_complete(uint8_t status, uint16_t length,
-					const void *param, void *user_data)
-{
-	if (status != MGMT_STATUS_SUCCESS)
-		error("Failed to confirm name: %s (0x%02x)",
-						mgmt_errstr(status), status);
-}
-
 static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
 {
 	struct mgmt_cp_confirm_name cp;
@@ -642,8 +634,7 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
 	cp.addr.type = addr_type;
 
 	if (mgmt_reply(adapter->mgmt, MGMT_OP_CONFIRM_NAME, adapter->index,
-					sizeof(cp), &cp, confirm_name_complete,
-					NULL, NULL) == 0)
+					sizeof(cp), &cp, NULL, NULL, NULL) == 0)
 		error("Failed to send confirm name request");
 }
 
-- 
1.8.4.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