Linux bluetooth development
 help / color / mirror / Atom feed
* Failed to connect: org.bluez.Error.NotReady
From: Brian J. Murrell @ 2013-12-13 15:33 UTC (permalink / raw)
  To: linux-bluetooth

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

So I was happily chugging along using bluez5 on F20 with the previously
mentioned mouse and all of a sudden it stopped working.  So to
bluetoothctl I go:

$ bluetoothctl 
[NEW] Controller 00:02:72:1E:E0:12 pc.interlinx.bc.ca-0 [default]
[NEW] Device 00:0D:E6:68:B4:6F Samsung WEP850
[NEW] Device 70:F3:95:3E:92:34 brian-laptop
[NEW] Device 7C:1E:52:6E:59:D2 Microsoft Sculpt Touch Mouse
[bluetooth]# info 7C:1E:52:6E:59:D2
Device 7C:1E:52:6E:59:D2
	Name: Microsoft Sculpt Touch Mouse
	Alias: Microsoft Sculpt Touch Mouse
	Class: 0x000580
	Icon: input-mouse
	Paired: yes
	Trusted: yes
	Blocked: no
	Connected: no
	LegacyPairing: no
	UUID: Service Discovery Serve.. (00001000-0000-1000-8000-00805f9b34fb)
	UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	Modalias: usb:v045Ep077Cd011E
[bluetooth]# connect 7C:1E:52:6E:59:D2
Attempting to connect to 7C:1E:52:6E:59:D2
Failed to connect: org.bluez.Error.NotReady

I've tried unplugging and plugging in the dongle.  Not sure what else to
do at this point.

Any ideas?

Cheers,
b.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* Re: [PATCH BlueZ] android: Add initial Android Bluetooth Audio protocol API doc
From: Luiz Augusto von Dentz @ 2013-12-13 15:28 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth@vger.kernel.org
In-Reply-To: <20131213144922.GE30037@x220.p-661hnu-f1>

Hi Johan,

On Fri, Dec 13, 2013 at 4:49 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Luiz,
>
> On Fri, Dec 13, 2013, Luiz Augusto von Dentz wrote:
>> This IPC is used to communicate Android BlueZ daemon and AudioFlinger
>> plugin.
>> ---
>>  android/audio-ipc-api.txt | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 50 insertions(+)
>>  create mode 100644 android/audio-ipc-api.txt
>
> This seems to be missing an addition to EXTRA_DIST. Once you've fixed
> that feel free to push this yourself.

Will fix it.

> Also, I assume you've got missing bits, like those for suspending and
> resuming streams planned for later patches?

It seems this is handled by upper layer, we just have to make sure the
events are propagated by using the audia state notification, anyway if
we latter find out it is still necessary to synchronize via Audio IPC
we can extend the IPC with some extra bits like you said.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] android/bluetooth: Add support for getting remote device UUIDs property
From: Johan Hedberg @ 2013-12-13 14:54 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1386944441-785-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Fri, Dec 13, 2013, Szymon Janc wrote:
> This allows to query for remote device UUIDs property.
> ---
>  android/bluetooth.c | 91 ++++++++++++++++++++++++++---------------------------
>  1 file changed, 45 insertions(+), 46 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH v2 1/5] android/tester: Add property check and bdname set success test case
From: Johan Hedberg @ 2013-12-13 14:53 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth
In-Reply-To: <1386938665-7179-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

Hi Grzegorz,

On Fri, Dec 13, 2013, Grzegorz Kolodziejczyk wrote:
> This adds handling of property check, bdname set property success.
> ---
>  android/android-tester.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 75 insertions(+)

All five patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH BlueZ] android: Add initial Android Bluetooth Audio protocol API doc
From: Johan Hedberg @ 2013-12-13 14:49 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1386938480-12049-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Fri, Dec 13, 2013, Luiz Augusto von Dentz wrote:
> This IPC is used to communicate Android BlueZ daemon and AudioFlinger
> plugin.
> ---
>  android/audio-ipc-api.txt | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
>  create mode 100644 android/audio-ipc-api.txt

This seems to be missing an addition to EXTRA_DIST. Once you've fixed
that feel free to push this yourself.

Also, I assume you've got missing bits, like those for suspending and
resuming streams planned for later patches?

Johan

^ permalink raw reply

* Re: [PATCH] android/bluetooth: Fix missing property change notification
From: Johan Hedberg @ 2013-12-13 14:46 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1386938291-26279-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Fri, Dec 13, 2013, Szymon Janc wrote:
> After setting new discoverable timeout property change notification
> with new value should be send.
> ---
>  android/bluetooth.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/2] bnep: Refactored bnep connect and disconnect calls
From: Johan Hedberg @ 2013-12-13 14:46 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1386938150-5683-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Fri, Dec 13, 2013, Ravi kumar Veeramally wrote:
> Refactored bnep connect and disconnect calls to simply and
> keeping bnep related functionality behind curtains.
> Provided bnep_struct, bnep_new and bnep_free to intialize
> and free the bnep_stuct with basic parameters. bnep_connect
> calls takes care of bnep_setup until interface up then connect
> callback will be called, disconnect_cb is registered as watchdog
> and it will triggered by remote device on disconnect or any other
> I/O error. bnep_disconnect should be called only when iface is
> up/connected.
> ---
>  android/pan.c                 |  97 ++++++++++++-------------------
>  profiles/network/bnep.c       | 131 ++++++++++++++++++++++++++++++------------
>  profiles/network/bnep.h       |  14 +++--
>  profiles/network/connection.c |  50 ++++++++++------
>  4 files changed, 173 insertions(+), 119 deletions(-)

This is a bit too much stuff in a single patch which makes it hard to
follow exactly what the patch is doing. Could you please try to split
this up into multiple patches? Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/8] android/tester: Add Socket test invalid params: chan and uuid
From: Johan Hedberg @ 2013-12-13 14:45 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1386861474-29524-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Thu, Dec 12, 2013, Andrei Emeltchenko wrote:
> For the socket listen() call parameters channel and uuid cannot be both
> zeroes.
> ---
>  android/android-tester.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 5/8] android/socket: Do not close fd on unref
From: Johan Hedberg @ 2013-12-13 14:39 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1386861474-29524-5-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Thu, Dec 12, 2013, Andrei Emeltchenko wrote:
> We close file descriptors in cleanup_rfsock() and leaving the default
> value gives us glib warnings if we close fd already and got G_IO_NVAL in
> server_cb from bt_io.
> ---
>  android/socket.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/android/socket.c b/android/socket.c
> index 5e8f8e5..9d759be 100644
> --- a/android/socket.c
> +++ b/android/socket.c
> @@ -736,6 +736,7 @@ static void handle_listen(const void *buf, uint16_t len)
>  	rfsock->real_sock = g_io_channel_unix_get_fd(io);
>  
>  	g_io_channel_unref(io);
> +	g_io_channel_set_close_on_unref(io, FALSE);

Strictly speaking this function is not allowed to touch "io" after it
drops its own reference to it, i.e. these calls should be in the
opposite order. I fixed it up myself this time.

Johan

^ permalink raw reply

* [PATCH] android/bluetooth: Add support for getting remote device UUIDs property
From: Szymon Janc @ 2013-12-13 14:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This allows to query for remote device UUIDs property.
---
 android/bluetooth.c | 91 ++++++++++++++++++++++++++---------------------------
 1 file changed, 45 insertions(+), 46 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index c60c9a2..97d4aae 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -75,6 +75,8 @@ struct device {
 
 	uint32_t class;
 	int32_t rssi;
+
+	GSList *uuids;
 };
 
 struct browse_req {
@@ -166,6 +168,7 @@ static void free_device(struct device *dev)
 {
 	g_free(dev->name);
 	g_free(dev->friendly_name);
+	g_slist_free_full(dev->uuids, g_free);
 	g_free(dev);
 }
 
@@ -383,40 +386,50 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
 	}
 }
 
-static void browse_req_free(struct browse_req *req)
+static  void send_device_property(const bdaddr_t *bdaddr, uint8_t type,
+						uint16_t len, const void *val)
 {
-	g_slist_free_full(req->uuids, g_free);
-	g_free(req);
+	uint8_t buf[BASELEN_REMOTE_DEV_PROP + len];
+	struct hal_ev_remote_device_props *ev = (void *) buf;
+
+	ev->status = HAL_STATUS_SUCCESS;
+	bdaddr2android(bdaddr, ev->bdaddr);
+	ev->num_props = 1;
+	ev->props[0].type = type;
+	ev->props[0].len = len;
+	memcpy(ev->props[0].val, val, len);
+
+	ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH, HAL_EV_REMOTE_DEVICE_PROPS,
+							sizeof(buf), buf);
 }
 
-static void fill_uuids(GSList *list, void *buf)
+static void send_device_uuids_notif(struct device *dev)
 {
-	for (; list; list = g_slist_next(list)) {
-		memcpy(buf, list->data, sizeof(uint128_t));
-		buf += sizeof(uint128_t);
+	uint8_t buf[sizeof(uint128_t) * g_slist_length(dev->uuids)];
+	uint8_t *ptr = buf;
+	GSList *l;
+
+	for (l = dev->uuids; l; l = g_slist_next(l)) {
+		memcpy(ptr, l->data, sizeof(uint128_t));
+		ptr += sizeof(uint128_t);
 	}
+
+	send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_UUIDS, sizeof(buf),
+									buf);
 }
 
-static void remote_uuids_callback(struct browse_req *req)
+static void set_device_uuids(struct device *dev, GSList *uuids)
 {
-	struct hal_ev_remote_device_props *ev;
-	int len;
-
-	len = sizeof(*ev) + sizeof(struct hal_property) + (sizeof(uint128_t) *
-						g_slist_length(req->uuids));
-	ev = g_malloc(len);
+	g_slist_free_full(dev->uuids, g_free);
+	dev->uuids = uuids;
 
-	ev->status = HAL_STATUS_SUCCESS;
-	bdaddr2android(&req->bdaddr, &ev->bdaddr);
-	ev->num_props = 1;
-	ev->props[0].type = HAL_PROP_DEVICE_UUIDS;
-	ev->props[0].len = sizeof(uint128_t) * g_slist_length(req->uuids);
-	fill_uuids(req->uuids, ev->props[0].val);
-
-	ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH, HAL_EV_REMOTE_DEVICE_PROPS,
-								len, ev);
+	send_device_uuids_notif(dev);
+}
 
-	g_free(ev);
+static void browse_req_free(struct browse_req *req)
+{
+	g_slist_free_full(req->uuids, g_free);
+	g_free(req);
 }
 
 static int uuid_128_cmp(gconstpointer a, gconstpointer b)
@@ -476,6 +489,7 @@ static void update_records(struct browse_req *req, sdp_list_t *recs)
 static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
 {
 	struct browse_req *req = user_data;
+	struct device *dev;
 	uuid_t uuid;
 
 	/* If we have a valid response and req->search_uuid == 2, then L2CAP
@@ -500,7 +514,11 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
 	}
 
 done:
-	remote_uuids_callback(req);
+	dev = find_device(&req->bdaddr);
+	if (dev) {
+		set_device_uuids(dev, req->uuids);
+		req->uuids = NULL;
+	}
 
 	browse_reqs = g_slist_remove(browse_reqs, req);
 	browse_req_free(req);
@@ -573,23 +591,6 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
 	browse_remote_sdp(&addr->bdaddr);
 }
 
-static  void send_device_property(const bdaddr_t *bdaddr, uint8_t type,
-						uint16_t len, const void *val)
-{
-	uint8_t buf[BASELEN_REMOTE_DEV_PROP + len];
-	struct hal_ev_remote_device_props *ev = (void *) buf;
-
-	ev->status = HAL_STATUS_SUCCESS;
-	bdaddr2android(bdaddr, ev->bdaddr);
-	ev->num_props = 1;
-	ev->props[0].type = type;
-	ev->props[0].len = len;
-	memcpy(ev->props[0].val, val, len);
-
-	ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH, HAL_EV_REMOTE_DEVICE_PROPS,
-							sizeof(buf), buf);
-}
-
 static uint8_t get_device_name(struct device *dev)
 {
 	send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_NAME,
@@ -2288,11 +2289,9 @@ static void handle_get_adapter_props_cmd(const void *buf, uint16_t len)
 
 static uint8_t get_device_uuids(struct device *dev)
 {
-	DBG("Not implemented");
+	send_device_uuids_notif(dev);
 
-	/* TODO */
-
-	return HAL_STATUS_FAILED;
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t get_device_class(struct device *dev)
-- 
1.8.3.2


^ permalink raw reply related

* Re: [RFC v2 BlueZ] build: Add coverage support
From: Anderson Lizardo @ 2013-12-13 13:23 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: BlueZ development
In-Reply-To: <1386874657-26642-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Thu, Dec 12, 2013 at 4:57 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> +clean-local: clean-coverage
> +       @find $(top_builddir) -name "*.gcda" -exec $(RM) {} \;
> +       @find $(top_builddir) -name "*.gcno" -exec $(RM) {} \;

Another simplification suggestion:  Replace " -exec $(RM) {} \;" with
"-delete", e.g.:

@find $(top_builddir) -name "*.gcda" -delete

BTW if the deletion fails (e.g. file was created as root but cleanup
is done as non-root), the find command will fail. If it is desirable
that the cleanup never fail, you may need to add a "-" before the
command (or use "|| true", whatever is the convention in BlueZ).

Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH] Adding missing test scripts to Makefile.tools
From: Johan Hedberg @ 2013-12-13 12:51 UTC (permalink / raw)
  To: Sebastian; +Cc: linux-bluetooth, Sebastian
In-Reply-To: <1386880421-19461-2-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

On Thu, Dec 12, 2013, Sebastian wrote:
> ---
>  Makefile.tools | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile.tools b/Makefile.tools
> index 78034f5..b306c34 100644
> --- a/Makefile.tools
> +++ b/Makefile.tools
> @@ -289,6 +289,7 @@ test_scripts += test/sap_client.py test/bluezutils.py \
>  		test/test-thermometer test/test-profile test/test-health \
>  		test/test-health-sink test/service-record.dtd \
>  		test/service-did.xml test/service-spp.xml test/service-opp.xml \
> -		test/service-ftp.xml test/simple-player test/test-nap \
> +		test/opp-client test/service-ftp.xml test/ftp-client \
> +		test/simple-player test/test-nap \
>  		test/test-heartrate test/test-alert test/test-hfp \
> -		test/test-cyclingspeed
> +		test/test-cyclingspeed test/pbap-client test/map-client

Looks otherwise fine, but you'll need to fix your git author information
and resend. We're not going to have an entry in the git history simply
from someone called "Sebastian". It should also contain a last name.

Johan

^ permalink raw reply

* [PATCH v2 5/5] android/tester: Add bdname get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-13 12:44 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386938665-7179-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds bdname set property success test case. First bdname is set and
then is read.
---
 android/android-tester.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index f347edf..36266e7 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -606,6 +606,15 @@ static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
 	.expected_property.len = sizeof(bt_bdaddr_t)
 };
 
+static const struct generic_data bluetooth_getprop_bdname_success_test = {
+	.expected_hal_callbacks = {adapter_prop_bdname, adapter_prop_bdname,
+							adapter_test_end},
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_BDNAME,
+	.expected_property.val = "test_bdname_setget",
+	.expected_property.len = 17
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -875,6 +884,22 @@ static void test_getprop_bdaddr_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_bdname_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t *prop = &test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->set_adapter_property(prop);
+	check_expected_status(adapter_status);
+
+	adapter_status = data->if_bluetooth->get_adapter_property((*prop).type);
+	check_expected_status(adapter_status);
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -925,6 +950,11 @@ int main(int argc, char *argv[])
 					setup_enabled_adapter,
 					test_getprop_bdaddr_success, teardown);
 
+	test_bredrle("Test Get BDNAME - Success",
+					&bluetooth_getprop_bdname_success_test,
+					setup_enabled_adapter,
+					test_getprop_bdname_success, teardown);
+
 	test_bredrle("Test Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH v2 4/5] android/tester: Add bdaddr get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-13 12:44 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386938665-7179-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds bdaddr set property success test case.
---
 android/android-tester.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 369af31..f347edf 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -598,6 +598,14 @@ static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
 	.expected_property.len = sizeof(test_setprop_disctimeout_val)
 };
 
+static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
+	.expected_hal_callbacks = {adapter_prop_bdaddr, adapter_test_end},
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_BDADDR,
+	.expected_property.val = NULL,
+	.expected_property.len = sizeof(bt_bdaddr_t)
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -854,6 +862,19 @@ static void test_setprop_disctimeout_succes(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_bdaddr_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t prop = test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+	check_expected_status(adapter_status);
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -899,6 +920,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_setprop_disctimeout_succes, teardown);
 
+	test_bredrle("Test Get BDADDR - Success",
+					&bluetooth_getprop_bdaddr_success_test,
+					setup_enabled_adapter,
+					test_getprop_bdaddr_success, teardown);
+
 	test_bredrle("Test Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH v2 3/5] android/tester: Add discovery timeout set prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-13 12:44 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386938665-7179-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds discovery timeout set property success test case.
---
 android/android-tester.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index fc521a4..369af31 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -43,6 +43,7 @@
 
 static bt_scan_mode_t test_setprop_scanmode_val =
 					BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+static uint32_t test_setprop_disctimeout_val = 120;
 
 /*
  * those are assigned to HAL methods and callbacks, we use ID later
@@ -589,6 +590,14 @@ static const struct generic_data bluetooth_setprop_scanmode_success_test = {
 	.expected_property.len = sizeof(bt_scan_mode_t)
 };
 
+static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
+	.expected_hal_callbacks = {adapter_prop_disc_timeout, adapter_test_end},
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.expected_property.val = &test_setprop_disctimeout_val,
+	.expected_property.len = sizeof(test_setprop_disctimeout_val)
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -832,6 +841,19 @@ static void test_setprop_scanmode_succes(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_setprop_disctimeout_succes(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t *prop = &test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->set_adapter_property(prop);
+	check_expected_status(adapter_status);
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -872,6 +894,11 @@ int main(int argc, char *argv[])
 				setup_enabled_adapter,
 				test_setprop_scanmode_succes, teardown);
 
+	test_bredrle("Test Set DISCOVERY_TIMEOUT - Success",
+				&bluetooth_setprop_disctimeout_success_test,
+				setup_enabled_adapter,
+				test_setprop_disctimeout_succes, teardown);
+
 	test_bredrle("Test Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH v2 2/5] android/tester: Add scan mode set prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-13 12:44 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386938665-7179-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This adds scan mode set property success test case.
---
 android/android-tester.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 0a31b53..fc521a4 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -41,6 +41,9 @@
 			adapter_prop_type, adapter_prop_scan_mode, \
 			adapter_prop_bonded_devices, adapter_prop_disc_timeout
 
+static bt_scan_mode_t test_setprop_scanmode_val =
+					BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+
 /*
  * those are assigned to HAL methods and callbacks, we use ID later
  * on mapped in switch-case due to different functions prototypes.
@@ -577,6 +580,15 @@ static const struct generic_data bluetooth_setprop_bdname_success_test = {
 	.expected_property.len = 11
 };
 
+static const struct generic_data bluetooth_setprop_scanmode_success_test = {
+	.expected_hal_callbacks = {adapter_prop_scan_mode,
+				adapter_prop_scan_mode, adapter_test_end},
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.expected_property.val = &test_setprop_scanmode_val,
+	.expected_property.len = sizeof(bt_scan_mode_t)
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -807,6 +819,19 @@ static void test_setprop_bdname_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_setprop_scanmode_succes(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t *prop = &test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->set_adapter_property(prop);
+	check_expected_status(adapter_status);
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -842,6 +867,11 @@ int main(int argc, char *argv[])
 					setup_enabled_adapter,
 					test_setprop_bdname_success, teardown);
 
+	test_bredrle("Test Set SCAN_MODE - Success",
+				&bluetooth_setprop_scanmode_success_test,
+				setup_enabled_adapter,
+				test_setprop_scanmode_succes, teardown);
+
 	test_bredrle("Test Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH v2 1/5] android/tester: Add property check and bdname set success test case
From: Grzegorz Kolodziejczyk @ 2013-12-13 12:44 UTC (permalink / raw)
  To: linux-bluetooth

This adds handling of property check, bdname set property success.
---
 android/android-tester.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index f34b4ac..0a31b53 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -65,6 +65,7 @@ enum hal_bluetooth_callbacks_id {
 struct generic_data {
 	uint8_t expected_adapter_status;
 	uint32_t expect_settings_set;
+	bt_property_t expected_property;
 	uint8_t expected_hal_callbacks[];
 };
 
@@ -95,7 +96,9 @@ struct test_data {
 	bool mgmt_settings_set;
 	bool hal_cb_called;
 	bool status_checked;
+	bool property_checked;
 
+	bt_property_t test_property;
 	GSList *expected_callbacks;
 };
 
@@ -111,6 +114,8 @@ static void test_update_state(void)
 		return;
 	if (!(data->status_checked))
 		return;
+	if (!(data->property_checked))
+		return;
 	tester_test_passed();
 }
 
@@ -177,11 +182,20 @@ static void expected_status_init(struct test_data *data)
 		data->status_checked = true;
 }
 
+static void test_property_init(struct test_data *data)
+{
+	const struct generic_data *test_data = data->test_data;
+
+	if (!(test_data->expected_property.type))
+		data->property_checked = true;
+}
+
 static void init_test_conditions(struct test_data *data)
 {
 	hal_cb_init(data);
 	mgmt_cb_init(data);
 	expected_status_init(data);
+	test_property_init(data);
 }
 
 static void check_expected_status(uint8_t status)
@@ -197,6 +211,33 @@ static void check_expected_status(uint8_t status)
 	test_update_state();
 }
 
+static void check_test_property(void)
+{
+	struct test_data *data = tester_get_data();
+	bt_property_t expected_prop = data->test_property;
+	const struct generic_data *test_data = data->test_data;
+	bt_property_t test_prop = test_data->expected_property;
+
+	if (test_prop.type && (expected_prop.type != test_prop.type)) {
+		tester_test_failed();
+		return;
+	}
+
+	if (test_prop.len && (expected_prop.len != test_prop.len)) {
+		tester_test_failed();
+		return;
+	}
+
+	if (test_prop.val && memcmp(expected_prop.val, test_prop.val,
+							expected_prop.len)) {
+		tester_test_failed();
+		return;
+	}
+
+	data->property_checked = true;
+	test_update_state();
+}
+
 static int get_expected_hal_cb(void)
 {
 	struct test_data *data = tester_get_data();
@@ -448,6 +489,7 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
 						bt_property_t *properties)
 {
 	enum hal_bluetooth_callbacks_id hal_cb;
+	struct test_data *data = tester_get_data();
 	int i;
 
 	for (i = 0; i < num_properties; i++) {
@@ -456,6 +498,12 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
 		if (hal_cb == adapter_test_setup_mode)
 			break;
 
+		data->test_property = *properties;
+
+		if (g_slist_next(data->expected_callbacks) ==
+							adapter_test_end)
+			check_test_property();
+
 		switch (properties[i].type) {
 		case BT_PROPERTY_BDADDR:
 			if (hal_cb != adapter_prop_bdaddr)
@@ -521,6 +569,14 @@ static const struct generic_data bluetooth_disable_success_test = {
 	.expected_hal_callbacks = {adapter_state_changed_off, adapter_test_end}
 };
 
+static const struct generic_data bluetooth_setprop_bdname_success_test = {
+	.expected_hal_callbacks = {adapter_prop_bdname, adapter_test_end},
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_BDNAME,
+	.expected_property.val = "test_bdname",
+	.expected_property.len = 11
+};
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -737,6 +793,20 @@ clean:
 		close(sock_fd);
 }
 
+static void test_setprop_bdname_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t *prop = &test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->set_adapter_property(prop);
+
+	check_expected_status(adapter_status);
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -767,6 +837,11 @@ int main(int argc, char *argv[])
 	test_bredrle("Test Disable - Success", &bluetooth_disable_success_test,
 			setup_enabled_adapter, test_disable, teardown);
 
+	test_bredrle("Test Set BDNAME - Success",
+					&bluetooth_setprop_bdname_success_test,
+					setup_enabled_adapter,
+					test_setprop_bdname_success, teardown);
+
 	test_bredrle("Test Socket Init", NULL, setup_socket_interface,
 						test_dummy, teardown);
 
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ] android: Add initial Android Bluetooth Audio protocol API doc
From: Luiz Augusto von Dentz @ 2013-12-13 12:41 UTC (permalink / raw)
  To: linux-bluetooth

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

This IPC is used to communicate Android BlueZ daemon and AudioFlinger
plugin.
---
 android/audio-ipc-api.txt | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 android/audio-ipc-api.txt

diff --git a/android/audio-ipc-api.txt b/android/audio-ipc-api.txt
new file mode 100644
index 0000000..e2b85ab
--- /dev/null
+++ b/android/audio-ipc-api.txt
@@ -0,0 +1,50 @@
+Bluetooth Audio Plugin
+======================
+
+The audio plugin happen to be in a different socket but all the rules for
+HAL socket apply here as well, the abstract socket name is
+"\0bluez_audio_socket" (tentative):
+
+	.--Android--.                             .---Audio---.
+	|  daemon   |                             |   Plugin  |
+	|           |          Command            |           |
+	|           | <-------------------------- |           |
+	|           |                             |           |
+	|           | --------------------------> |           |
+	|           |          Response           |           |
+	|           |                             |           |
+	|           |                             |           |
+	|           |        Notification         |           |
+	|           | --------------------------> |           |
+	|           |                             |           |
+	'-----------'                             '-----------'
+
+
+Identifier: "audio" (BT_AUDIO_ID)
+
+	Opcode 0x00 - Error response
+
+		Response parameters: Status (1 octet)
+
+	Opcode 0x01 - Register Audio Endpoint commmand
+
+		Command parameters: Service UUID (16 octets)
+				    Codec ID (1 octets)
+				    Codec capabilities length (1 octets)
+				    Codec capabilities (variable)
+				    Number of codec presets (1 octets)
+				    Codec preset # length (1 octets)
+				    Codec preset # configuration (variable)
+				    ...
+		Response parameters: Endpoint ID (1 octets)
+
+	Opcode 0x02 - Unregister Audio Endpoint command
+
+		Command parameters: Endpoint ID (1 octets)
+		Response parameters: <none>
+
+	Opcode 0x81 - New Audio Connection notification
+
+		Notification parameters: Endpoint ID (1 octets)
+					 Codec preset # (1 octets)
+					 File descriptor (inline)
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH] android/bluetooth: Fix missing property change notification
From: Szymon Janc @ 2013-12-13 12:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

After setting new discoverable timeout property change notification
with new value should be send.
---
 android/bluetooth.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 4bb2c92..c60c9a2 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1387,6 +1387,10 @@ static uint8_t set_adapter_discoverable_timeout(const void *buf, uint16_t len)
 	/* TODO: This should be in some storage */
 	memcpy(&adapter.discoverable_timeout, timeout, sizeof(uint32_t));
 
+	send_adapter_property(HAL_PROP_ADAPTER_DISC_TIMEOUT,
+					sizeof(adapter.discoverable_timeout),
+					&adapter.discoverable_timeout);
+
 	return HAL_STATUS_SUCCESS;
 }
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 2/2] bnep: Refactored bnep server apis for bridge addition and deletion
From: Ravi kumar Veeramally @ 2013-12-13 12:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386938150-5683-1-git-send-email-ravikumar.veeramally@linux.intel.com>

To simplify bnep server realted bridge creation and deletion calls
provided extra apis and moved related apis to static.
---
 profiles/network/bnep.c   | 99 +++++++++++++++++++++++++++++++++++++++++------
 profiles/network/bnep.h   | 15 +++----
 profiles/network/server.c | 81 ++++++--------------------------------
 3 files changed, 104 insertions(+), 91 deletions(-)

diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 752e00e..6e1af74 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -151,7 +151,7 @@ int bnep_cleanup(void)
 	return 0;
 }
 
-int bnep_conndel(const bdaddr_t *dst)
+static int bnep_conndel(const bdaddr_t *dst)
 {
 	struct bnep_conndel_req req;
 
@@ -167,7 +167,7 @@ int bnep_conndel(const bdaddr_t *dst)
 	return 0;
 }
 
-int bnep_connadd(int sk, uint16_t role, char *dev)
+static int bnep_connadd(int sk, uint16_t role, char *dev)
 {
 	struct bnep_connadd_req req;
 
@@ -187,7 +187,7 @@ int bnep_connadd(int sk, uint16_t role, char *dev)
 	return 0;
 }
 
-int bnep_if_up(const char *devname)
+static int bnep_if_up(const char *devname)
 {
 	struct ifreq ifr;
 	int sk, err;
@@ -212,7 +212,7 @@ int bnep_if_up(const char *devname)
 	return 0;
 }
 
-int bnep_if_down(const char *devname)
+static int bnep_if_down(const char *devname)
 {
 	struct ifreq ifr;
 	int sk, err;
@@ -464,7 +464,7 @@ void bnep_free(struct bnep_conn *bc)
 	g_free(bc);
 }
 
-int bnep_add_to_bridge(const char *devname, const char *bridge)
+static int bnep_add_to_bridge(const char *devname, const char *bridge)
 {
 	int ifindex;
 	struct ifreq ifr;
@@ -495,7 +495,7 @@ int bnep_add_to_bridge(const char *devname, const char *bridge)
 	return 0;
 }
 
-int bnep_del_from_bridge(const char *devname, const char *bridge)
+static int bnep_del_from_bridge(const char *devname, const char *bridge)
 {
 	int ifindex = if_nametoindex(devname);
 	struct ifreq ifr;
@@ -535,19 +535,19 @@ ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp)
 	return send(sk, &rsp, sizeof(rsp), 0);
 }
 
-uint16_t bnep_setup_chk(uint16_t dst, uint16_t src)
+static uint16_t bnep_setup_chk(uint16_t dst, uint16_t src)
 {
 	/* Allowed PAN Profile scenarios */
 	switch (dst) {
 	case BNEP_SVC_NAP:
 	case BNEP_SVC_GN:
 		if (src == BNEP_SVC_PANU)
-			return 0;
+			return BNEP_SUCCESS;
 		return BNEP_CONN_INVALID_SRC;
 	case BNEP_SVC_PANU:
 		if (src == BNEP_SVC_PANU ||  src == BNEP_SVC_GN ||
 							src == BNEP_SVC_NAP)
-			return 0;
+			return BNEP_SUCCESS;
 
 		return BNEP_CONN_INVALID_SRC;
 	}
@@ -555,8 +555,8 @@ uint16_t bnep_setup_chk(uint16_t dst, uint16_t src)
 	return BNEP_CONN_INVALID_DST;
 }
 
-uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
-								uint16_t *src)
+static uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req,
+						uint16_t *dst, uint16_t *src)
 {
 	const uint8_t bt_base[] = { 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
 					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
@@ -601,3 +601,80 @@ uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
 
 	return BNEP_SUCCESS;
 }
+
+int bnep_validate_setup_rsp(int sk, uint16_t *dst)
+{
+	uint8_t packet[BNEP_MTU];
+	struct bnep_setup_conn_req *req = (void *) packet;
+	uint16_t src;
+	uint8_t pkt[3];
+	int n, rsp = BNEP_CONN_NOT_ALLOWED;
+
+	/* Reading BNEP_SETUP_CONNECTION_REQUEST_MSG */
+	n = read(sk, packet, sizeof(packet));
+	if (n < 0) {
+		error("read(): %s(%d)", strerror(errno), errno);
+		return n;
+	}
+
+	/* Highest known Control command ID
+	 * is BNEP_FILTER_MULT_ADDR_RSP = 0x06 */
+	if (req->type == BNEP_CONTROL &&
+				req->ctrl > BNEP_FILTER_MULT_ADDR_RSP) {
+		pkt[0] = BNEP_CONTROL;
+		pkt[1] = BNEP_CMD_NOT_UNDERSTOOD;
+		pkt[2] = req->ctrl;
+
+		send(sk, pkt, sizeof(pkt), 0);
+		return -EINVAL;
+	}
+
+	if (req->type != BNEP_CONTROL || req->ctrl != BNEP_SETUP_CONN_REQ)
+		return -EINVAL;
+
+	rsp = bnep_setup_decode(req, dst, &src);
+	if (rsp)
+		return rsp;
+
+	rsp = bnep_setup_chk(*dst, src);
+
+	return rsp;
+}
+
+int bnep_server_add(int sk, uint16_t dst, char *bridge, char *iface,
+						const bdaddr_t *addr)
+{
+	if (!bridge || !bridge || !iface || !addr)
+		return -EINVAL;
+
+	if (bnep_connadd(sk, dst, iface) < 0) {
+		error("Can't add connection to the bridge %s: %s(%d)",
+						bridge, strerror(errno), errno);
+		return -errno;
+	}
+
+	if (bnep_add_to_bridge(iface, bridge) < 0) {
+		error("Can't add %s to the bridge %s: %s(%d)",
+					iface, bridge, strerror(errno), errno);
+		bnep_conndel(addr);
+		return -errno;
+	}
+
+	if (bnep_if_up(iface) < 0) {
+		error("Can't up the interface %s: %s(%d)",
+						iface, strerror(errno), errno);
+		return -errno;
+	}
+
+	return 0;
+}
+
+void bnep_server_delete(char *bridge, char *iface, const bdaddr_t *addr)
+{
+	if (!bridge || !iface || !addr)
+		return;
+
+	bnep_del_from_bridge(iface, bridge);
+	bnep_if_down(iface);
+	bnep_conndel(addr);
+}
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index fcb35f7..36cfee0 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -30,13 +30,6 @@ uint16_t bnep_service_id(const char *svc);
 const char *bnep_uuid(uint16_t id);
 const char *bnep_name(uint16_t id);
 
-int bnep_connadd(int sk, uint16_t role, char *dev);
-int bnep_conndel(const bdaddr_t *dst);
-int bnep_if_up(const char *devname);
-int bnep_if_down(const char *devname);
-int bnep_add_to_bridge(const char *devname, const char *bridge);
-int bnep_del_from_bridge(const char *devname, const char *bridge);
-
 struct bnep_conn *bnep_new(uint16_t src, uint16_t dst,
 						const bdaddr_t *dst_addr);
 void bnep_free(struct bnep_conn *bnep);
@@ -46,7 +39,9 @@ int bnep_connect(struct bnep_conn *bnep, int sk, bnep_connect_cb conn_cb,
 				bnep_disconnect_cb disconn_cb, void *data);
 void bnep_disconnect(struct bnep_conn *bnep);
 
+int bnep_server_add(int sk, uint16_t dst, char *bridge, char *iface,
+							const bdaddr_t *addr);
+void bnep_server_delete(char *bridge, char *iface, const bdaddr_t *addr);
+
+int bnep_validate_setup_rsp(int sk, uint16_t *dst);
 ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
-uint16_t bnep_setup_chk(uint16_t dst_role, uint16_t src_role);
-uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
-								uint16_t *src);
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 73741ec..432b6d5 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -251,35 +251,6 @@ static sdp_record_t *server_record_new(const char *name, uint16_t id)
 	return record;
 }
 
-static int server_connadd(struct network_server *ns,
-				struct network_session *session,
-				uint16_t dst_role)
-{
-	char devname[16];
-	int err, nsk;
-
-	nsk = g_io_channel_unix_get_fd(session->io);
-	err = bnep_connadd(nsk, dst_role, devname);
-	if (err < 0)
-		return err;
-
-	info("Added new connection: %s", devname);
-
-	if (bnep_add_to_bridge(devname, ns->bridge) < 0) {
-		error("Can't add %s to the bridge %s: %s(%d)",
-				devname, ns->bridge, strerror(errno), errno);
-		return -EPERM;
-	}
-
-	bnep_if_up(devname);
-
-	strncpy(session->dev, devname, sizeof(devname));
-
-	ns->sessions = g_slist_append(ns->sessions, session);
-
-	return 0;
-}
-
 static void session_free(void *data)
 {
 	struct network_session *session = data;
@@ -311,10 +282,8 @@ static gboolean bnep_setup(GIOChannel *chan,
 {
 	struct network_adapter *na = user_data;
 	struct network_server *ns;
-	uint8_t packet[BNEP_MTU];
-	struct bnep_setup_conn_req *req = (void *) packet;
-	uint16_t src_role, dst_role, rsp = BNEP_CONN_NOT_ALLOWED;
-	int n, sk;
+	uint16_t dst;
+	int sk, rsp = BNEP_CONN_NOT_ALLOWED;
 
 	if (cond & G_IO_NVAL)
 		return FALSE;
@@ -325,45 +294,18 @@ static gboolean bnep_setup(GIOChannel *chan,
 	}
 
 	sk = g_io_channel_unix_get_fd(chan);
-
-	/* Reading BNEP_SETUP_CONNECTION_REQUEST_MSG */
-	n = read(sk, packet, sizeof(packet));
-	if (n < 0) {
-		error("read(): %s(%d)", strerror(errno), errno);
-		return FALSE;
-	}
-
-	/* Highest known Control command ID
-	 * is BNEP_FILTER_MULT_ADDR_RSP = 0x06 */
-	if (req->type == BNEP_CONTROL &&
-				req->ctrl > BNEP_FILTER_MULT_ADDR_RSP) {
-		uint8_t pkt[3];
-
-		pkt[0] = BNEP_CONTROL;
-		pkt[1] = BNEP_CMD_NOT_UNDERSTOOD;
-		pkt[2] = req->ctrl;
-
-		send(sk, pkt, sizeof(pkt), 0);
-
-		return FALSE;
-	}
-
-	if (req->type != BNEP_CONTROL || req->ctrl != BNEP_SETUP_CONN_REQ)
+	rsp = bnep_validate_setup_rsp(sk, &dst);
+	if (rsp < 0)
 		return FALSE;
 
-	rsp = bnep_setup_decode(req, &dst_role, &src_role);
-	if (rsp)
-		goto reply;
-
-	rsp = bnep_setup_chk(dst_role, src_role);
-	if (rsp)
+	if (rsp > 0)
 		goto reply;
 
 	rsp = BNEP_CONN_NOT_ALLOWED;
 
-	ns = find_server(na->servers, dst_role);
+	ns = find_server(na->servers, dst);
 	if (!ns) {
-		error("Server unavailable: (0x%x)", dst_role);
+		error("Server unavailable: (0x%x)", dst);
 		goto reply;
 	}
 
@@ -377,9 +319,11 @@ static gboolean bnep_setup(GIOChannel *chan,
 		goto reply;
 	}
 
-	if (server_connadd(ns, na->setup, dst_role) < 0)
+	if (bnep_server_add(sk, dst, ns->bridge, na->setup->dev,
+							&na->setup->dst) < 0)
 		goto reply;
 
+	ns->sessions = g_slist_append(ns->sessions, na->setup);
 	na->setup = NULL;
 
 	rsp = BNEP_SUCCESS;
@@ -524,10 +468,7 @@ static void server_remove_sessions(struct network_server *ns)
 		if (*session->dev == '\0')
 			continue;
 
-		bnep_del_from_bridge(session->dev, ns->bridge);
-		bnep_if_down(session->dev);
-
-		bnep_conndel(&session->dst);
+		bnep_server_delete(ns->bridge, session->dev, &session->dst);
 	}
 
 	g_slist_free_full(ns->sessions, session_free);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/2] bnep: Refactored bnep connect and disconnect calls
From: Ravi kumar Veeramally @ 2013-12-13 12:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

Refactored bnep connect and disconnect calls to simply and
keeping bnep related functionality behind curtains.
Provided bnep_struct, bnep_new and bnep_free to intialize
and free the bnep_stuct with basic parameters. bnep_connect
calls takes care of bnep_setup until interface up then connect
callback will be called, disconnect_cb is registered as watchdog
and it will triggered by remote device on disconnect or any other
I/O error. bnep_disconnect should be called only when iface is
up/connected.
---
 android/pan.c                 |  97 ++++++++++++-------------------
 profiles/network/bnep.c       | 131 ++++++++++++++++++++++++++++++------------
 profiles/network/bnep.h       |  14 +++--
 profiles/network/connection.c |  50 ++++++++++------
 4 files changed, 173 insertions(+), 119 deletions(-)

diff --git a/android/pan.c b/android/pan.c
index e410f54..0cae6ac 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -54,7 +54,7 @@ struct pan_device {
 	uint8_t		conn_state;
 	uint8_t		role;
 	GIOChannel	*io;
-	guint		watch;
+	struct bnep_conn *bnep;
 };
 
 static int device_cmp(gconstpointer s, gconstpointer user_data)
@@ -65,24 +65,6 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
 	return bacmp(&dev->dst, dst);
 }
 
-static void pan_device_free(struct pan_device *dev)
-{
-	local_role = HAL_PAN_ROLE_NONE;
-
-	if (dev->watch > 0) {
-		g_source_remove(dev->watch);
-		dev->watch = 0;
-	}
-
-	if (dev->io) {
-		g_io_channel_unref(dev->io);
-		dev->io = NULL;
-	}
-
-	devices = g_slist_remove(devices, dev);
-	g_free(dev);
-}
-
 static void bt_pan_notify_conn_state(struct pan_device *dev, uint8_t state)
 {
 	struct hal_ev_pan_conn_state ev;
@@ -121,22 +103,33 @@ static void bt_pan_notify_ctrl_state(struct pan_device *dev, uint8_t state)
 									&ev);
 }
 
-static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
-								gpointer data)
+static void destroy_pan_device(struct pan_device *dev)
 {
-	struct pan_device *dev = data;
+	if (dev->io) {
+		g_io_channel_shutdown(dev->io, TRUE, NULL);
+		g_io_channel_unref(dev->io);
+		dev->io = NULL;
+	}
 
-	DBG("%s disconnected", dev->iface);
+	if (dev->conn_state == HAL_PAN_STATE_CONNECTED)
+		bnep_disconnect(dev->bnep);
 
-	bnep_if_down(dev->iface);
-	bnep_conndel(&dev->dst);
 	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
+	bnep_free(dev->bnep);
+	devices = g_slist_remove(devices, dev);
+	g_free(dev);
+}
 
-	return FALSE;
+static void bnep_disconn_cb(void *data)
+{
+	struct pan_device *dev = data;
+
+	DBG("%s disconnected", dev->iface);
+
+	destroy_pan_device(dev);
 }
 
-static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
+static void bnep_conn_cb(char *iface, int err, void *data)
 {
 	struct pan_device *dev = data;
 
@@ -144,26 +137,18 @@ static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
 
 	if (err < 0) {
 		error("bnep connect req failed: %s", strerror(-err));
-		bnep_conndel(&dev->dst);
-		bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-		pan_device_free(dev);
+		destroy_pan_device(dev);
 		return;
 	}
 
-	memcpy(dev->iface, iface, sizeof(dev->iface));
-
-	DBG("%s connected", dev->iface);
+	DBG("%s connected", iface);
 
+	memcpy(dev->iface, iface, sizeof(dev->iface));
 	bt_pan_notify_ctrl_state(dev, HAL_PAN_CTRL_ENABLED);
 	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_CONNECTED);
-
-	dev->watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-							bnep_watchdog_cb, dev);
-	g_io_channel_unref(dev->io);
-	dev->io = NULL;
 }
 
-static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
+static void bt_io_connect_cb(GIOChannel *chan, GError *err, gpointer data)
 {
 	struct pan_device *dev = data;
 	uint16_t src, dst;
@@ -180,7 +165,13 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
 	dst = (dev->role == HAL_PAN_ROLE_NAP) ? BNEP_SVC_NAP : BNEP_SVC_PANU;
 	sk = g_io_channel_unix_get_fd(dev->io);
 
-	perr = bnep_connect(sk, src, dst, bnep_conn_cb, dev);
+	dev->bnep = bnep_new(src, dst, &dev->dst);
+	if (!dev->bnep) {
+		error("unable to allocate memory for dev->bnep");
+		goto fail;
+	}
+
+	perr = bnep_connect(dev->bnep, sk, bnep_conn_cb, bnep_disconn_cb, dev);
 	if (perr < 0) {
 		error("bnep connect req failed: %s", strerror(-perr));
 		goto fail;
@@ -189,8 +180,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
 	return;
 
 fail:
-	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
+	destroy_pan_device(dev);
 }
 
 static void bt_pan_connect(const void *buf, uint16_t len)
@@ -240,7 +230,7 @@ static void bt_pan_connect(const void *buf, uint16_t len)
 	ba2str(&dev->dst, addr);
 	DBG("connecting to %s %s", addr, dev->iface);
 
-	dev->io = bt_io_connect(connect_cb, dev, NULL, &gerr,
+	dev->io = bt_io_connect(bt_io_connect_cb, dev, NULL, &gerr,
 					BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
 					BT_IO_OPT_DEST_BDADDR, &dev->dst,
 					BT_IO_OPT_PSM, BNEP_PSM,
@@ -269,7 +259,7 @@ static void bt_pan_disconnect(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_pan_disconnect *cmd = buf;
 	struct pan_device *dev;
-	uint8_t status;
+	uint8_t status = HAL_STATUS_FAILED;
 	GSList *l;
 	bdaddr_t dst;
 
@@ -278,24 +268,11 @@ static void bt_pan_disconnect(const void *buf, uint16_t len)
 	android2bdaddr(&cmd->bdaddr, &dst);
 
 	l = g_slist_find_custom(devices, &dst, device_cmp);
-	if (!l) {
-		status = HAL_STATUS_FAILED;
+	if (!l)
 		goto failed;
-	}
 
 	dev = l->data;
-
-	if (dev->watch) {
-		g_source_remove(dev->watch);
-		dev->watch = 0;
-	}
-
-	bnep_if_down(dev->iface);
-	bnep_conndel(&dst);
-
-	bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
-	pan_device_free(dev);
-
+	destroy_pan_device(dev);
 	status = HAL_STATUS_SUCCESS;
 
 failed:
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 08037e6..752e00e 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -71,25 +71,16 @@ struct bnep_conn {
 	GIOChannel	*io;
 	uint16_t	src;
 	uint16_t	dst;
+	bdaddr_t	dst_addr;
+	char	iface[16];
 	guint	attempts;
 	guint	setup_to;
 	void	*data;
-	bnep_connect_cb	conn_cb;
+	bnep_connect_cb conn_cb;
+	bnep_disconnect_cb disconn_cb;
+	int watch;
 };
 
-static void free_bnep_connect(struct bnep_conn *bc)
-{
-	if (!bc)
-		return;
-
-	if (bc->io) {
-		g_io_channel_unref(bc->io);
-		bc->io = NULL;
-	}
-
-	g_free(bc);
-}
-
 uint16_t bnep_service_id(const char *svc)
 {
 	int i;
@@ -246,6 +237,39 @@ int bnep_if_down(const char *devname)
 	return 0;
 }
 
+struct bnep_conn *bnep_new(uint16_t src, uint16_t dst,
+						const bdaddr_t *dst_addr)
+{
+	struct bnep_conn *bc;
+
+	DBG("");
+
+	if (!dst_addr)
+		return NULL;
+
+	bc = g_new0(struct bnep_conn, 1);
+	if (!bc)
+		return NULL;
+
+	bc->src = src;
+	bc->dst = dst;
+	bacpy(&bc->dst_addr, dst_addr);
+
+	return bc;
+}
+
+static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
+								gpointer data)
+{
+	struct bnep_conn *bc = data;
+
+	DBG("");
+
+	bc->disconn_cb(bc->data);
+
+	return FALSE;
+}
+
 static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
 								gpointer data)
 {
@@ -253,12 +277,11 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
 	struct bnep_control_rsp *rsp;
 	struct timeval timeo;
 	char pkt[BNEP_MTU];
-	char iface[16];
 	ssize_t r;
 	int sk;
 
 	if (cond & G_IO_NVAL)
-		goto failed;
+		return FALSE;
 
 	if (bc->setup_to > 0) {
 		g_source_remove(bc->setup_to);
@@ -310,24 +333,28 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
 	setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
 
 	sk = g_io_channel_unix_get_fd(bc->io);
-	if (bnep_connadd(sk, bc->src, iface)) {
+	if (bnep_connadd(sk, bc->src, bc->iface)) {
 		error("bnep conn could not be added");
 		goto failed;
 	}
 
-	if (bnep_if_up(iface)) {
-		error("could not up %s", iface);
+	if (bnep_if_up(bc->iface)) {
+		error("could not up %s", bc->iface);
+		bnep_conndel(&bc->dst_addr);
 		goto failed;
 	}
 
-	bc->conn_cb(chan, iface, 0, bc->data);
-	free_bnep_connect(bc);
+	bc->watch = g_io_add_watch(bc->io, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+							bnep_watchdog_cb, bc);
+	g_io_channel_unref(bc->io);
+	bc->io = NULL;
+
+	bc->conn_cb(bc->iface, 0, bc->data);
 
 	return FALSE;
 
 failed:
-	bc->conn_cb(NULL, NULL, -EIO, bc->data);
-	free_bnep_connect(bc);
+	bc->conn_cb(NULL, -EIO, bc->data);
 
 	return FALSE;
 }
@@ -371,40 +398,72 @@ static gboolean bnep_conn_req_to(gpointer user_data)
 			return TRUE;
 	}
 
-	bc->conn_cb(NULL, NULL, -ETIMEDOUT, bc->data);
-	free_bnep_connect(bc);
+	bc->conn_cb(NULL, -ETIMEDOUT, bc->data);
 
 	return FALSE;
 }
 
-int bnep_connect(int sk, uint16_t src, uint16_t dst, bnep_connect_cb conn_cb,
-								void *data)
+int bnep_connect(struct bnep_conn *bc, int sk, bnep_connect_cb conn_cb,
+				bnep_disconnect_cb disconn_cb, void *data)
 {
-	struct bnep_conn *bc;
 	int err;
 
-	if (!conn_cb)
+	if (!bc || !conn_cb || !disconn_cb)
 		return -EINVAL;
 
-	bc = g_new0(struct bnep_conn, 1);
 	bc->io = g_io_channel_unix_new(sk);
-	bc->attempts = 0;
-	bc->src = src;
-	bc->dst = dst;
-	bc->conn_cb = conn_cb;
 	bc->data = data;
+	bc->conn_cb = conn_cb;
+	bc->disconn_cb = disconn_cb;
 
 	err = bnep_setup_conn_req(bc);
 	if (err < 0)
 		return err;
 
 	bc->setup_to = g_timeout_add_seconds(CON_SETUP_TO,
-							bnep_conn_req_to, bc);
-	g_io_add_watch(bc->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+						bnep_conn_req_to, bc);
+	bc->watch = g_io_add_watch(bc->io,
+				G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
 							bnep_setup_cb, bc);
 	return 0;
 }
 
+void bnep_disconnect(struct bnep_conn *bc)
+{
+	DBG("");
+
+	if (!bc)
+		return;
+
+	if (bc->io) {
+		g_io_channel_unref(bc->io);
+		bc->io = NULL;
+	}
+
+	if (bc->watch) {
+		g_source_remove(bc->watch);
+		bc->watch = 0;
+	}
+
+	bnep_if_down(bc->iface);
+	bnep_conndel(&bc->dst_addr);
+}
+
+void bnep_free(struct bnep_conn *bc)
+{
+	DBG("");
+
+	if (!bc)
+		return;
+
+	if (bc->io) {
+		g_io_channel_unref(bc->io);
+		bc->io = NULL;
+	}
+
+	g_free(bc);
+}
+
 int bnep_add_to_bridge(const char *devname, const char *bridge)
 {
 	int ifindex;
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index dd22c40..fcb35f7 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -21,6 +21,8 @@
  *
  */
 
+struct bnep_conn;
+
 int bnep_init(void);
 int bnep_cleanup(void);
 
@@ -35,10 +37,14 @@ int bnep_if_down(const char *devname);
 int bnep_add_to_bridge(const char *devname, const char *bridge);
 int bnep_del_from_bridge(const char *devname, const char *bridge);
 
-typedef void (*bnep_connect_cb) (GIOChannel *chan, char *iface, int err,
-								void *data);
-int bnep_connect(int sk, uint16_t src, uint16_t dst, bnep_connect_cb conn_cb,
-								void *data);
+struct bnep_conn *bnep_new(uint16_t src, uint16_t dst,
+						const bdaddr_t *dst_addr);
+void bnep_free(struct bnep_conn *bnep);
+typedef void (*bnep_connect_cb) (char *iface, int err, void *data);
+typedef void (*bnep_disconnect_cb) (void *data);
+int bnep_connect(struct bnep_conn *bnep, int sk, bnep_connect_cb conn_cb,
+				bnep_disconnect_cb disconn_cb, void *data);
+void bnep_disconnect(struct bnep_conn *bnep);
 
 ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
 uint16_t bnep_setup_chk(uint16_t dst_role, uint16_t src_role);
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index fb3e1ce..c7cc99f 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -72,6 +72,7 @@ struct network_conn {
 	guint		dc_id;
 	struct network_peer *peer;
 	DBusMessage	*connect;
+	struct bnep_conn *bnep;
 };
 
 static GSList *peers = NULL;
@@ -106,8 +107,7 @@ static struct network_conn *find_connection_by_state(GSList *list,
 	return NULL;
 }
 
-static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
-				gpointer data)
+static void bnep_disconn_cb(void *data)
 {
 	struct network_conn *nc = data;
 	DBusConnection *conn = btd_get_dbus_connection();
@@ -126,12 +126,18 @@ static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
 
 	info("%s disconnected", nc->dev);
 
-	bnep_if_down(nc->dev);
 	nc->state = DISCONNECTED;
 	memset(nc->dev, 0, sizeof(nc->dev));
 	strcpy(nc->dev, "bnep%d");
 
-	return FALSE;
+	bnep_free(nc->bnep);
+	nc->bnep = NULL;
+
+	if (nc->io) {
+		g_io_channel_shutdown(nc->io, TRUE, NULL);
+		g_io_channel_unref(nc->io);
+		nc->io = NULL;
+	}
 }
 
 static void local_connect_cb(struct network_conn *nc, int err)
@@ -158,9 +164,17 @@ static void cancel_connection(struct network_conn *nc, int err)
 	if (nc->connect)
 		local_connect_cb(nc, err);
 
-	g_io_channel_shutdown(nc->io, TRUE, NULL);
-	g_io_channel_unref(nc->io);
-	nc->io = NULL;
+	if (nc->io) {
+		g_io_channel_shutdown(nc->io, TRUE, NULL);
+		g_io_channel_unref(nc->io);
+		nc->io = NULL;
+	}
+
+	if (nc->state == CONNECTED)
+		bnep_disconnect(nc->bnep);
+
+	bnep_free(nc->bnep);
+	nc->bnep = NULL;
 
 	nc->state = DISCONNECTED;
 }
@@ -169,11 +183,7 @@ static void connection_destroy(DBusConnection *conn, void *user_data)
 {
 	struct network_conn *nc = user_data;
 
-	if (nc->state == CONNECTED) {
-		bnep_if_down(nc->dev);
-		bnep_conndel(device_get_address(nc->peer->device));
-	} else if (nc->io)
-		cancel_connection(nc, -EIO);
+	cancel_connection(nc, -EIO);
 }
 
 static void disconnect_cb(struct btd_device *device, gboolean removal,
@@ -186,7 +196,7 @@ static void disconnect_cb(struct btd_device *device, gboolean removal,
 	connection_destroy(NULL, user_data);
 }
 
-static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
+static void bnep_conn_cb(char *iface, int err, void *data)
 {
 	struct network_conn *nc = data;
 	const char *path;
@@ -220,11 +230,6 @@ static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
 	nc->state = CONNECTED;
 	nc->dc_id = device_add_disconnect_watch(nc->peer->device, disconnect_cb,
 								nc, NULL);
-	g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-							bnep_watchdog_cb, nc);
-	g_io_channel_unref(nc->io);
-	nc->io = NULL;
-
 	return;
 
 failed:
@@ -242,7 +247,14 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
 	}
 
 	sk = g_io_channel_unix_get_fd(nc->io);
-	perr = bnep_connect(sk, BNEP_SVC_PANU, nc->id, bnep_conn_cb, nc);
+	nc->bnep = bnep_new(BNEP_SVC_PANU, nc->id,
+					device_get_address(nc->peer->device));
+	if (!nc->bnep) {
+		error("unable to allocate memory for nc->bnep");
+		goto failed;
+	}
+
+	perr = bnep_connect(nc->bnep, sk, bnep_conn_cb, bnep_disconn_cb, nc);
 	if (perr < 0) {
 		error("bnep connect(): %s (%d)", strerror(-perr), -perr);
 		goto failed;
-- 
1.8.3.2


^ permalink raw reply related

* Re: [RFC v2 BlueZ] build: Add coverage support
From: Marcel Holtmann @ 2013-12-13 12:34 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1386874657-26642-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

> Coverage is disabled by default but it is automatically enabled by
> bootstrap-configure using --enable-coverage, it creates a new make target
> 'coverage' that can be run after make check or any tester that produces
> .gdca files.
> 
> The build time using --enable-coverage is considerable bigger so if
> that is a problem just disable it, also this is the reason why it is not
> added directly under --enable-maintainer-mode so it is possible to
> turn off coverage without having to turn off maintainer mode.
> 
> Since lcov apparently cannot detect changes to .gcda there is another
> make target 'clean-coverage' so after that make coverage can be
> run again.
> ---
> Makefile.am         | 17 +++++++++++++++++
> acinclude.m4        |  8 ++++++++
> bootstrap-configure |  1 +
> configure.ac        |  5 +++++
> 4 files changed, 31 insertions(+)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 15cc149..4b3351a 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -331,5 +331,22 @@ lib/bluetooth/%.h: lib/%.h
> 	$(AM_V_at)$(MKDIR_P) lib/bluetooth
> 	$(AM_V_GEN)$(LN_S) -f "$(abs_top_builddir)"/$< $@
> 
> +if COVERAGE
> +clean-coverage:
> +	$(RM) -r coverage
> +
> +coverage:
> +	$(AM_V_at)$(MKDIR_P) -p coverage
> +	@lcov --compat-libtool --directory $(top_builddir) --capture \
> +					--output-file coverage/check.info
> +	@genhtml -o coverage/ coverage/check.info

I would actually prefer if we can have some sort AM_V_GEN thing working here. So that make V=1 will end up showing the exact command.

> +
> +clean-local: clean-coverage
> +	@find $(top_builddir) -name "*.gcda" -exec $(RM) {} \;
> +	@find $(top_builddir) -name "*.gcno" -exec $(RM) {} \;
> +	@lcov --directory . --zerocounters
> +	$(RM) -r lib/bluetooth
> +else
> clean-local:
> 	$(RM) -r lib/bluetooth
> +endif

This if for clean-local is not something I like that much. Can we not come up with a better way and leave clean-local as it is. Just make clean-coverage a null-op.

> diff --git a/acinclude.m4 b/acinclude.m4
> index 2065852..4bb8bde 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -51,6 +51,14 @@ AC_DEFUN([MISC_FLAGS], [
> 			misc_ldflags="$misc_ldflags -pie"
> 		fi
> 	])
> +	AC_ARG_ENABLE(coverage, AC_HELP_STRING([--enable-coverage],
> +						[enable coverage flags]), [
> +		enable_coverage=${enableval}
> +		if (test "${enable_coverage}" = "yes"); then
> +			misc_cflags="$misc_cflags --coverage"
> +			misc_ldflags="$misc_ldflags --coverage"
> +		fi
> +	])
> 	AC_SUBST([MISC_CFLAGS], $misc_cflags)
> 	AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
> ])
> diff --git a/bootstrap-configure b/bootstrap-configure
> index c7f08ed..35aa98b 100755
> --- a/bootstrap-configure
> +++ b/bootstrap-configure
> @@ -14,4 +14,5 @@ fi
> 		--enable-experimental \
> 		--enable-android \
> 		--enable-sixaxis \
> +		--enable-coverage \
> 		--disable-datafiles $*
> diff --git a/configure.ac b/configure.ac
> index 18d0b55..5e684a3 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -252,4 +252,9 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
> 					[enable_android=${enableval}])
> AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")
> 
> +if (test "${enable_coverage}" = "yes"); then
> +	AC_CHECK_PROG([LCOV], [lcov], [yes], AC_MSG_ERROR(lcov is required))
> +fi
> +AM_CONDITIONAL([COVERAGE], [test "${enable_coverage}" = "yes"])
> +

Still not 100% convinced that we really want this. I get the feeling that maintainer-mode would be just fine.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] sixaxis: Fix device detection
From: Johan Hedberg @ 2013-12-13  9:54 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth
In-Reply-To: <1386864988.1982.45.camel@nuvo>

Hi Bastien,

On Thu, Dec 12, 2013, Bastien Nocera wrote:
> After searching past the end of the structure, the loop sometimes
> found matches in the daemon's address space...
> 
> This fixes the loop to end after the elements have been exhausted.
> ---
>  plugins/sixaxis.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/2] android/pts: Add PTS test results for OPP
From: Luiz Augusto von Dentz @ 2013-12-13  9:24 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1386862737-30606-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Thu, Dec 12, 2013 at 5:38 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> This will allow for better tracking of current state of implementation.
> ---
>  android/Makefile.am |  3 +-
>  android/pts-opp.txt | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 96 insertions(+), 1 deletion(-)
>  create mode 100644 android/pts-opp.txt
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 1dde8c1..bcd9f2b 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -110,4 +110,5 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
>                 android/pixit-did.txt android/pts-did.txt \
>                 android/pixit-gap.txt android/pixit-hid.txt \
>                 android/pixit-opp.txt android/pixit-pan.txt \
> -               android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt
> +               android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
> +               android/pts-opp.txt
> diff --git a/android/pts-opp.txt b/android/pts-opp.txt
> new file mode 100644
> index 0000000..b9329b9
> --- /dev/null
> +++ b/android/pts-opp.txt
> @@ -0,0 +1,94 @@
> +PTS test results for OPP
> +
> +PTS version: 4.9
> +Tested: 14.11.2013
> +
> +Results:
> +PASS   test passed
> +FAIL   test failed
> +INC    test is inconclusive
> +N/A    test is disabled due to PICS setup
> +
> +-------------------------------------------------------------------------------
> +Test Name              Result  Notes
> +-------------------------------------------------------------------------------
> +TC_CLIENT_OPH_BV_01_I  PASS
> +TC_CLIENT_OPH_BV_02_I  N/A
> +TC_CLIENT_OPH_BV_03_I  PASS
> +TC_CLIENT_OPH_BV_04_I  N/A
> +TC_CLIENT_OPH_BV_05_I  PASS
> +TC_CLIENT_OPH_BV_07_I  N/A
> +TC_CLIENT_OPH_BV_08_I  N/A
> +TC_CLIENT_OPH_BV_09_I  N/A
> +TC_CLIENT_OPH_BV_10_I  N/A
> +TC_CLIENT_OPH_BV_11_I  N/A
> +TC_CLIENT_OPH_BV_12_I  N/A
> +TC_CLIENT_OPH_BV_13_I  N/A
> +TC_CLIENT_OPH_BV_14_I  N/A
> +TC_CLIENT_OPH_BV_15_I  N/A
> +TC_CLIENT_OPH_BV_16_I  N/A
> +TC_CLIENT_OPH_BV_17_I  N/A
> +TC_CLIENT_OPH_BV_18_I  N/A
> +TC_CLIENT_OPH_BV_19_I  PASS
> +TC_CLIENT_OPH_BV_20_I  PASS
> +TC_CLIENT_OPH_BV_22_I  PASS
> +TC_CLIENT_OPH_BV_23_I  PASS
> +TC_CLIENT_OPH_BV_24_I  N/A
> +TC_CLIENT_OPH_BV_25_I  N/A
> +TC_CLIENT_OPH_BV_26_I  N/A
> +TC_CLIENT_OPH_BV_34_I  PASS
> +TC_CLIENT_OPH_BI_01_C  PASS
> +TC_CLIENT_BCP_BV_01_I  N/A
> +TC_CLIENT_BCP_BV_02_I  N/A
> +TC_CLIENT_BCP_BV_03_I  N/A
> +TC_CLIENT_BCP_BV_04_I  N/A
> +TC_CLIENT_BCP_BV_05_I  N/A
> +TC_CLIENT_BCE_BV_01_I  N/A
> +TC_CLIENT_BCE_BV_03_I  N/A
> +TC_CLIENT_BCE_BV_04_I  N/A
> +TC_CLIENT_BCE_BV_05_I  N/A
> +TC_CLIENT_BCE_BV_06_I  N/A
> +TC_CLIENT_BCE_BV_07_I  N/A
> +TC_SERVER_OPH_BV_01_I  PASS
> +TC_SERVER_OPH_BV_02_I  PASS
> +TC_SERVER_OPH_BV_03_I  PASS
> +TC_SERVER_OPH_BV_04_I  PASS
> +TC_SERVER_OPH_BV_05_I  PASS
> +TC_SERVER_OPH_BV_07_I  N/A
> +TC_SERVER_OPH_BV_08_I  N/A
> +TC_SERVER_OPH_BV_09_I  N/A
> +TC_SERVER_OPH_BV_10_I  PASS
> +TC_SERVER_OPH_BV_11_I  N/A
> +TC_SERVER_OPH_BV_12_I  N/A
> +TC_SERVER_OPH_BV_13_I  N/A
> +TC_SERVER_OPH_BV_14_I  PASS
> +TC_SERVER_OPH_BV_15_I  N/A
> +TC_SERVER_OPH_BV_16_I  N/A
> +TC_SERVER_OPH_BV_17_I  N/A
> +TC_SERVER_OPH_BV_18_I  PASS
> +TC_SERVER_OPH_BV_19_I  PASS
> +TC_SERVER_OPH_BV_21_I  N/A
> +TC_SERVER_OPH_BV_22_I  PASS
> +TC_SERVER_OPH_BV_23_I  PASS
> +TC_SERVER_OPH_BV_24_I  N/A
> +TC_SERVER_OPH_BV_25_I  N/A
> +TC_SERVER_OPH_BV_26_I  N/A
> +TC_SERVER_OPH_BV_34_I  PASS
> +TC_SERVER_BCP_BV_01_I  N/A
> +TC_SERVER_BCP_BV_02_I  PASS
> +TC_SERVER_BCP_BV_03_I  N/A
> +TC_SERVER_BCP_BV_04_I  N/A
> +TC_SERVER_BCP_BV_05_I  N/A
> +TC_SERVER_BCE_BV_01_I  N/A
> +TC_SERVER_BCE_BV_03_I  N/A
> +TC_SERVER_BCE_BV_04_I  N/A
> +TC_SERVER_BCE_BV_05_I  N/A
> +TC_SERVER_BCE_BV_06_I  N/A
> +TC_SERVER_BCE_BV_07_I  N/A
> +TC_CLIENT_OPH_BV_27_I  N/A
> +TC_SERVER_OPH_BV_27_I  N/A
> +TC_SERVER_OPH_BV_30_I  N/A
> +TC_SERVER_OPH_BV_31_I  N/A
> +TC_SERVER_OPH_BV_32_I  N/A
> +TC_SERVER_OPH_BV_33_I  N/A
> +-------------------------------------------------------------------------------
> --
> 1.8.3.2

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH 1/2] android/pts: Add PTS test results for GAP
From: Luiz Augusto von Dentz @ 2013-12-13  9:24 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1386855340-22911-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Thu, Dec 12, 2013 at 3:35 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> This will allow for better tracking of current state of implementation.
> ---
>  android/Makefile.am |   2 +-
>  android/pts-gap.txt | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 156 insertions(+), 1 deletion(-)
>  create mode 100644 android/pts-gap.txt
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 0bcab2f..7db0616 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -110,4 +110,4 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
>                 android/pixit-did.txt android/pts-did.txt \
>                 android/pixit-gap.txt android/pixit-hid.txt \
>                 android/pixit-opp.txt android/pixit-pan.txt \
> -               android/pixit-pbap.txt
> +               android/pixit-pbap.txt android/pts-gap.txt
> diff --git a/android/pts-gap.txt b/android/pts-gap.txt
> new file mode 100644
> index 0000000..0ea5539
> --- /dev/null
> +++ b/android/pts-gap.txt
> @@ -0,0 +1,155 @@
> +PTS test results for GAP
> +
> +PTS version: 4.9
> +Tested: 14.11.2013
> +
> +Results:
> +PASS   test passed
> +FAIL   test failed
> +INC    test is inconclusive
> +N/A    test is disabled due to PICS setup
> +
> +-------------------------------------------------------------------------------
> +Test Name              Result  Notes
> +-------------------------------------------------------------------------------
> +TC_MOD_NDIS_BV_01_C    PASS
> +TC_MOD_LDIS_BV_01_C    N/A
> +TC_MOD_LDIS_BV_02_C    N/A
> +TC_MOD_LDIS_BV_03_C    N/A
> +TC_MOD_GDIS_BV_01_C    PASS
> +TC_MOD_GDIS_BV_02_C    PASS
> +TC_MOD_NCON_BV_01_C    PASS
> +TC_MOD_CON_BV_01_C     PASS
> +TC_BROB_BCST_BV_01_C   N/A
> +TC_BROB_BCST_BV_02_C   N/A
> +TC_BROB_BCST_BV_03_C   N/A
> +TC_BROB_OBSV_BV_01_C   N/A
> +TC_BROB_OBSV_BV_02_C   N/A
> +TC_BROB_OBSV_BV_03_C   N/A
> +TC_BROB_OBSV_BV_04_C   N/A
> +TC_BROB_OBSV_BV_05_C   N/A
> +TC_DISC_NONM_BV_01_C   N/A
> +TC_DISC_NONM_BV_02_C   N/A
> +TC_DISC_LIMM_BV_01_C   N/A
> +TC_DISC_LIMM_BV_02_C   N/A
> +TC_DISC_LIMM_BV_03_C   N/A
> +TC_DISC_LIMM_BV_04_C   N/A
> +TC_DISC_GENM_BV_01_C   N/A
> +TC_DISC_GENM_BV_02_C   N/A
> +TC_DISC_GENM_BV_03_C   N/A
> +TC_DISC_GENM_BV_04_C   N/A
> +TC_DISC_LIMP_BV_01_C   N/A
> +TC_DISC_LIMP_BV_02_C   N/A
> +TC_DISC_LIMP_BV_03_C   N/A
> +TC_DISC_LIMP_BV_04_C   N/A
> +TC_DISC_LIMP_BV_05_C   N/A
> +TC_DISC_GENP_BV_01_C   INC     LE not supported yet
> +TC_DISC_GENP_BV_02_C   INC     LE not supported yet
> +TC_DISC_GENP_BV_03_C   INC     LE not supported yet
> +TC_DISC_GENP_BV_04_C   INC     LE not supported yet
> +TC_DISC_GENP_BV_05_C   INC     LE not supported yet
> +TC_IDLE_GIN_BV_01_C    PASS
> +TC_IDLE_LIN_BV_01_C    N/A
> +TC_IDLE_NAMP_BV_01_C   INC     LE not supported yet
> +TC_IDLE_NAMP_BV_02_C   INC     LE not supported yet
> +TC_CONN_NCON_BV_01_C   N/A
> +TC_CONN_NCON_BV_02_C   N/A
> +TC_CONN_NCON_BV_03_C   N/A
> +TC_CONN_DCON_BV_01_C   N/A
> +TC_CONN_DCON_BV_02_C   N/A
> +TC_CONN_DCON_BV_03_C   N/A
> +TC_CONN_UCON_BV_01_C   N/A
> +TC_CONN_UCON_BV_02_C   N/A
> +TC_CONN_UCON_BV_03_C   N/A
> +TC_CONN_UCON_BV_04_C   N/A
> +TC_CONN_UCON_BV_05_C   N/A
> +TC_CONN_ACEP_BV_01_C   INC     LE not supported yet
> +TC_CONN_ACEP_BV_02_C   N/A
> +TC_CONN_GCEP_BV_01_C   INC     LE not supported yet
> +TC_CONN_GCEP_BV_02_C   INC     LE not supported yet
> +TC_CONN_GCEP_BV_03_C   N/A
> +TC_CONN_GCEP_BV_04_C   N/A
> +TC_CONN_SCEP_BV_01_C   INC     LE not supported yet
> +TC_CONN_SCEP_BV_02_C   N/A
> +TC_CONN_DCEP_BV_01_C   INC     LE not supported yet
> +TC_CONN_DCEP_BV_02_C   N/A
> +TC_CONN_DCEP_BV_03_C   INC     LE not supported yet
> +TC_CONN_DCEP_BV_04_C   N/A
> +TC_CONN_CPUP_BV_01_C   N/A
> +TC_CONN_CPUP_BV_02_C   N/A
> +TC_CONN_CPUP_BV_03_C   N/A
> +TC_CONN_CPUP_BV_04_C   INC     LE not supported yet
> +TC_CONN_CPUP_BV_05_C   INC     LE not supported yet
> +TC_CONN_CPUP_BV_06_C   INC     LE not supported yet
> +TC_CONN_TERM_BV_01_C   INC     LE not supported yet
> +TC_CONN_PRDA_BV_01_C   N/A
> +TC_CONN_PRDA_BV_02_C   INC     LE not supported yet
> +TC_BOND_NBON_BV_01_C   N/A
> +TC_BOND_NBON_BV_02_C   N/A
> +TC_BOND_NBON_BV_03_C   N/A
> +TC_BOND_BON_BV_01_C    N/A
> +TC_BOND_BON_BV_02_C    INC     LE not supported yet
> +TC_BOND_BON_BV_03_C    N/A
> +TC_BOND_BON_BV_04_C    INC     LE not supported yet
> +TC_SEC_AUT_BV_11_C     N/A
> +TC_SEC_AUT_BV_12_C     INC     LE not supported yet
> +TC_SEC_AUT_BV_13_C     N/A
> +TC_SEC_AUT_BV_14_C     N/A
> +TC_SEC_AUT_BV_15_C     N/A
> +TC_SEC_AUT_BV_16_C     INC     LE not supported yet
> +TC_SEC_AUT_BV_17_C     N/A
> +TC_SEC_AUT_BV_18_C     N/A
> +TC_SEC_AUT_BV_19_C     N/A
> +TC_SEC_AUT_BV_20_C     N/A
> +TC_SEC_AUT_BV_21_C     N/A
> +TC_SEC_AUT_BV_22_C     N/A
> +TC_SEC_AUT_BV_23_C     N/A
> +TC_SEC_AUT_BV_24_C     N/A
> +TC_SEC_CSIGN_BV_01_C   INC     LE not supported yet
> +TC_SEC_CSIGN_BV_02_C   INC     LE not supported yet
> +TC_SEC_CSIGN_BI_01_C   INC     LE not supported yet
> +TC_SEC_CSIGN_BI_02_C   INC     LE not supported yet
> +TC_SEC_CSIGN_BI_03_C   INC     LE not supported yet
> +TC_SEC_CSIGN_BI_04_C   INC     LE not supported yet
> +TC_PRIV_CONN_BV_01_C   N/A
> +TC_PRIV_CONN_BV_02_C   N/A
> +TC_PRIV_CONN_BV_03_C   N/A
> +TC_PRIV_CONN_BV_04_C   N/A
> +TC_PRIV_CONN_BV_05_C   N/A
> +TC_PRIV_CONN_BV_06_C   N/A
> +TC_PRIV_CONN_BV_07_C   N/A
> +TC_PRIV_CONN_BV_08_C   N/A
> +TC_PRIV_CONN_BV_09_C   N/A
> +TC_ADV_BV_01_C         N/A
> +TC_ADV_BV_02_C         N/A
> +TC_ADV_BV_03_C         N/A
> +TC_ADV_BV_04_C         N/A
> +TC_ADV_BV_05_C         N/A
> +TC_ADV_BV_06_C         N/A
> +TC_ADV_BV_07_C         N/A
> +TC_ADV_BV_08_C         N/A
> +TC_ADV_BV_09_C         N/A
> +TC_ADV_BV_10_C         N/A
> +TC_GAT_BV_01_C         INC     LE not supported yet
> +TC_GAT_BV_02_C         N/A
> +TC_GAT_BV_03_C         N/A
> +TC_GAT_BV_04_C         N/A
> +TC_GAT_BV_05_C         N/A
> +TC_GAT_BV_06_C         N/A
> +TC_GAT_BV_07_C         N/A
> +TC_GAT_BV_08_C         N/A
> +TC_DM_NCON_BV_01_C     N/A
> +TC_DM_CON_BV_01_C      N/A
> +TC_DM_NBON_BV_01_C     N/A
> +TC_DM_BON_BV_01_C      INC     LE not supported yet
> +TC_DM_GIN_BV_01_C      INC     LE not supported yet
> +TC_DM_LIN_BV_01_C      N/A
> +TC_DM_NAD_BV_01_C      PASS
> +TC_DM_NAD_BV_02_C      INC     LE not supported yet
> +TC_DM_LEP_BV_01_C      N/A
> +TC_DM_LEP_BV_02_C      N/A
> +TC_DM_LEP_BV_03_C      N/A
> +TC_DM_LEP_BV_04_C      N/A
> +TC_DM_LEP_BV_05_C      N/A
> +TC_DM_LEP_BV_06_C      INC     LE not supported yet
> +-------------------------------------------------------------------------------
> --
> 1.8.3.2

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply


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