Linux bluetooth development
 help / color / mirror / Atom feed
* [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

* Re: [PATCH 1/2] android/tester: Add new id to hal_bluetooth_callbacks_id
From: Luiz Augusto von Dentz @ 2013-12-13  9:03 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1386921905-28047-1-git-send-email-lukasz.rymanowski@tieto.com>

Hi Lukasz,

On Fri, Dec 13, 2013 at 10:05 AM, Lukasz Rymanowski
<lukasz.rymanowski@tieto.com> wrote:
> Added adapter_prop_tod id to represents BT_PROPERTY_TYPE_OF_DEVICE
> property changed.
> ---
>  android/android-tester.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index a50ed7b..16ddcc4 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -55,6 +55,7 @@ enum hal_bluetooth_callbacks_id {
>         adapter_prop_uuids,
>         adapter_prop_cod,
>         adapter_prop_scan_mode,
> +       adapter_prop_tod,
>         adapter_prop_disc_timeout,
>         adapter_prop_service_record,
>         adapter_prop_bonded_devices
> @@ -484,7 +485,7 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
>                         remove_expected_hal_cb();
>                         break;
>                 case BT_PROPERTY_TYPE_OF_DEVICE:
> -                       if (hal_cb != adapter_prop_bdaddr) {
> +                       if (hal_cb != adapter_prop_tod) {
>                                 tester_test_failed();
>                                 return;
>                         }
> --
> 1.8.4

Too late, I already fixed it myself, but thanks anyway.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH 2/2] android/tester: Update expected adapter properties
From: Lukasz Rymanowski @ 2013-12-13  8:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, Lukasz Rymanowski
In-Reply-To: <1386921905-28047-1-git-send-email-lukasz.rymanowski@tieto.com>

Bluetooth daemon supports now BT_PROPERTY_ADAPTER_BONDED_DEVICES and
BT_PROPERTY_TYPE_OF_DEVICE. Android tester needs to be updated with this
expected properties. Test result with this patch:

Test Summary
------------
Test Init                                     Passed       0.026 seconds
Test Enable - Success                         Passed       0.027 seconds
Test Enable - Done                            Passed       0.030 seconds
Test Disable - Success                        Passed       0.036 seconds
Test Socket Init                              Passed       0.020 seconds
Test Socket Listen - Invalid sock type        Passed       0.088 seconds
Test Socket Listen - Invalid: L2CAP           Passed       0.025 seconds

Total: 7, Passed: 7 (100.0%), Failed: 0, Not Run: 0
---
 android/android-tester.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 16ddcc4..fbcbb27 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -38,7 +38,8 @@
 
 #define adapter_props adapter_prop_bdaddr, adapter_prop_bdname, \
 			adapter_prop_uuids, adapter_prop_cod, \
-			adapter_prop_scan_mode, adapter_prop_disc_timeout
+			adapter_prop_tod, adapter_prop_scan_mode, \
+			adapter_prop_bonded_devices, adapter_prop_disc_timeout
 
 /*
  * those are assigned to HAL methods and callbacks, we use ID later
-- 
1.8.4


^ permalink raw reply related

* [PATCH 1/2] android/tester: Add new id to hal_bluetooth_callbacks_id
From: Lukasz Rymanowski @ 2013-12-13  8:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, Lukasz Rymanowski

Added adapter_prop_tod id to represents BT_PROPERTY_TYPE_OF_DEVICE
property changed.
---
 android/android-tester.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a50ed7b..16ddcc4 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -55,6 +55,7 @@ enum hal_bluetooth_callbacks_id {
 	adapter_prop_uuids,
 	adapter_prop_cod,
 	adapter_prop_scan_mode,
+	adapter_prop_tod,
 	adapter_prop_disc_timeout,
 	adapter_prop_service_record,
 	adapter_prop_bonded_devices
@@ -484,7 +485,7 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
 			remove_expected_hal_cb();
 			break;
 		case BT_PROPERTY_TYPE_OF_DEVICE:
-			if (hal_cb != adapter_prop_bdaddr) {
+			if (hal_cb != adapter_prop_tod) {
 				tester_test_failed();
 				return;
 			}
-- 
1.8.4


^ permalink raw reply related

* Re: [REGRESSION] rfcomm (userland) broken by commit 29cd718b
From: Alexander Holler @ 2013-12-12 23:35 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Gustavo Padovan, Gianluca Anzolin, marcel, linux-bluetooth,
	gregkh, jslaby, linux-kernel
In-Reply-To: <52AA1E62.1030109@hurleysoftware.com>

Am 12.12.2013 21:36, schrieb Peter Hurley:

>> What currently happens is that when one kills rfcomm (and any other
>> terminal which might use that tty), the entry in /dev doesn't
>> disappear. That means the same call to refcomm with the same device
>> (e.g. [/dev/]rfcomm1 doesn't work.
> 
> Thanks for the report, Alexander.
> 
> Point 4 above details a different situation; something else is
> happening.
> 
> Would you please detail the necessary steps to reproduce this regression?
> (How do you 'kill' rfcomm? etc.  Shell command lines would be best.)

Just call

rfcomm connect rfcomm9 01:23:45:67:89:ab

wait until the connection happened  (a message will appear) and then
press ctrl-c. This still terminates the bluetooth connection, but the
device in /dev is now left.

Regards,

Alexander Holler

^ permalink raw reply

* Re: [REGRESSION] rfcomm (userland) broken by commit 29cd718b
From: Peter Hurley @ 2013-12-12 20:36 UTC (permalink / raw)
  To: Alexander Holler, Gustavo Padovan, Gianluca Anzolin, marcel,
	linux-bluetooth, gregkh, jslaby, linux-kernel
In-Reply-To: <52AA1854.500@ahsoftware.de>

On 12/12/2013 03:11 PM, Alexander Holler wrote:
> Hello,
>
> since commit 29cd718beba999bda4bdbbf59b5a4d25c07e1547 "rfcomm: don't release the port in rfcomm_dev_state_change()" the userland utility rfcomm (both from bluez 4.101 and 5.12) is broken.
>
> In detail the following note in the patch
>
> Am 19.09.2013 18:24, schrieb Gustavo Padovan:
>> Hi Gianluca,
>>
>> 2013-08-27 Gianluca Anzolin <gianluca@sottospazio.it>:
>>
>>> When the dlc is closed, rfcomm_dev_state_change() tries to release the
>>> port in the case it cannot get a reference to the tty. However this is
>>> racy and not even needed.
>>>
>>> Infact as Peter Hurley points out:
>
> (...)
>
>>> 4. After releasing the dlc lock in rfcomm_dev_add(),
>>>     rfcomm_dev_state_change() will 'see' an incomplete rfcomm_dev if a
>>>     tty reference could not be obtained. Again, the best thing to do here
>>>     is nothing. Any future attempted open() will block on
>>>     rfcomm_dev_carrier_raised(). The unconnected device will exist until
>>>     released by ioctl(RFCOMMRELEASEDEV).
>>>
>>> The patch removes the aforementioned code and uses the
>>> tty_port_tty_hangup() helper to hangup the tty.
>
> reads like the usage of that ioctl now necessary.
>
> What currently happens is that when one kills rfcomm (and any other terminal which might use that tty), the entry in /dev doesn't disappear. That means the same call to refcomm with the same device (e.g. [/dev/]rfcomm1 doesn't work.

Thanks for the report, Alexander.

Point 4 above details a different situation; something else is
happening.

Would you please detail the necessary steps to reproduce this regression?
(How do you 'kill' rfcomm? etc.  Shell command lines would be best.)

> My current solution is to just revert that commit.
> I haven't tested if modifying (the userland utility) rfcomm (adding that ioctl) will help, but that looks only like a longterm solution.

Changes to userspace should not be required; rfcomm should be
handling teardown without help.

Regards,
Peter Hurley

^ permalink raw reply

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

---
 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
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH] Adding missing test scripts to Makefile.tools
From: Sebastian @ 2013-12-12 20:33 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

It seems some obex test scripts are missing from the Makefile.

^ permalink raw reply

* Re: [PATCH bluetooth-next] 6lowpan: fix/move/cleanup debug functions
From: Marcel Holtmann @ 2013-12-12 20:16 UTC (permalink / raw)
  To: Alexander Aring
  Cc: linux-zigbee-devel, werner,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <1386875725-4436-1-git-send-email-alex.aring@gmail.com>

Hi Alex,

> There are several issues on current debug behaviour.
> This patch fix the following issues:
> 
> - Fix debug printout only if DEBUG is defined.
> - Move debug functions of 6LoWPAN code into 6lowpan header.
> - Cleanup codestyle of debug functions.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> net/bluetooth/6lowpan.c       | 27 ---------------------------
> net/ieee802154/6lowpan.c      | 43 +++++--------------------------------------
> net/ieee802154/6lowpan.h      | 32 ++++++++++++++++++++++++++++++++
> net/ieee802154/6lowpan_iphc.c | 26 --------------------------
> 4 files changed, 37 insertions(+), 91 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* [REGRESSION] rfcomm (userland) broken by commit 29cd718b
From: Alexander Holler @ 2013-12-12 20:11 UTC (permalink / raw)
  To: Gustavo Padovan, Gianluca Anzolin, peter, marcel, linux-bluetooth,
	gregkh, jslaby, linux-kernel
In-Reply-To: <20130919162413.GG4006@joana>

Hello,

since commit 29cd718beba999bda4bdbbf59b5a4d25c07e1547 "rfcomm: don't 
release the port in rfcomm_dev_state_change()" the userland utility 
rfcomm (both from bluez 4.101 and 5.12) is broken.

In detail the following note in the patch

Am 19.09.2013 18:24, schrieb Gustavo Padovan:
> Hi Gianluca,
>
> 2013-08-27 Gianluca Anzolin <gianluca@sottospazio.it>:
>
>> When the dlc is closed, rfcomm_dev_state_change() tries to release the
>> port in the case it cannot get a reference to the tty. However this is
>> racy and not even needed.
>>
>> Infact as Peter Hurley points out:

(...)

>> 4. After releasing the dlc lock in rfcomm_dev_add(),
>>     rfcomm_dev_state_change() will 'see' an incomplete rfcomm_dev if a
>>     tty reference could not be obtained. Again, the best thing to do here
>>     is nothing. Any future attempted open() will block on
>>     rfcomm_dev_carrier_raised(). The unconnected device will exist until
>>     released by ioctl(RFCOMMRELEASEDEV).
>>
>> The patch removes the aforementioned code and uses the
>> tty_port_tty_hangup() helper to hangup the tty.

reads like the usage of that ioctl now necessary.

What currently happens is that when one kills rfcomm (and any other 
terminal which might use that tty), the entry in /dev doesn't disappear. 
That means the same call to refcomm with the same device (e.g. 
[/dev/]rfcomm1 doesn't work.

My current solution is to just revert that commit.
I haven't tested if modifying (the userland utility) rfcomm (adding that 
ioctl) will help, but that looks only like a longterm solution.

Regards,

Alexander Holler

^ permalink raw reply

* [PATCH bluetooth-next] 6lowpan: fix/move/cleanup debug functions
From: Alexander Aring @ 2013-12-12 19:15 UTC (permalink / raw)
  To: linux-zigbee-devel; +Cc: werner, linux-bluetooth, Alexander Aring

There are several issues on current debug behaviour.
This patch fix the following issues:

- Fix debug printout only if DEBUG is defined.
- Move debug functions of 6LoWPAN code into 6lowpan header.
- Cleanup codestyle of debug functions.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/bluetooth/6lowpan.c       | 27 ---------------------------
 net/ieee802154/6lowpan.c      | 43 +++++--------------------------------------
 net/ieee802154/6lowpan.h      | 32 ++++++++++++++++++++++++++++++++
 net/ieee802154/6lowpan_iphc.c | 26 --------------------------
 4 files changed, 37 insertions(+), 91 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 5ad8b48..37239db 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -167,33 +167,6 @@ static struct lowpan_dev *lookup_dev(struct l2cap_conn *conn)
 	return dev;
 }
 
-/* print data in line */
-static inline void raw_dump_inline(const char *caller, char *msg,
-				   unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s: ", caller, msg);
-
-	print_hex_dump_debug("", DUMP_PREFIX_NONE,
-			     16, 1, buf, len, false);
-}
-
-/* print data in a table format:
- *
- * addr: xx xx xx xx xx xx
- * addr: xx xx xx xx xx xx
- * ...
- */
-static inline void raw_dump_table(const char *caller, char *msg,
-				  unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s:\n", caller, msg);
-
-	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET,
-			     16, 1, buf, len, false);
-}
-
 static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
 {
 	struct sk_buff *skb_cp;
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 53d0bd5..48b25c0 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -101,37 +101,6 @@ static inline void lowpan_address_flip(u8 *src, u8 *dest)
 		(dest)[IEEE802154_ADDR_LEN - i - 1] = (src)[i];
 }
 
-/* list of all 6lowpan devices, uses for package delivering */
-/* print data in line */
-static inline void lowpan_raw_dump_inline(const char *caller, char *msg,
-				   unsigned char *buf, int len)
-{
-#ifdef DEBUG
-	if (msg)
-		pr_debug("(%s) %s: ", caller, msg);
-	print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE,
-		       16, 1, buf, len, false);
-#endif /* DEBUG */
-}
-
-/*
- * print data in a table format:
- *
- * addr: xx xx xx xx xx xx
- * addr: xx xx xx xx xx xx
- * ...
- */
-static inline void lowpan_raw_dump_table(const char *caller, char *msg,
-				   unsigned char *buf, int len)
-{
-#ifdef DEBUG
-	if (msg)
-		pr_debug("(%s) %s:\n", caller, msg);
-	print_hex_dump(KERN_DEBUG, "\t", DUMP_PREFIX_OFFSET,
-		       16, 1, buf, len, false);
-#endif /* DEBUG */
-}
-
 static int lowpan_header_create(struct sk_buff *skb,
 			   struct net_device *dev,
 			   unsigned short type, const void *_daddr,
@@ -153,8 +122,8 @@ static int lowpan_header_create(struct sk_buff *skb,
 	if (!saddr)
 		saddr = dev->dev_addr;
 
-	lowpan_raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8);
-	lowpan_raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8);
+	raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8);
+	raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8);
 
 	lowpan_header_compress(skb, dev, type, daddr, saddr, len);
 
@@ -290,8 +259,7 @@ static int process_data(struct sk_buff *skb)
 	u8 iphc0, iphc1;
 	const struct ieee802154_addr *_saddr, *_daddr;
 
-	lowpan_raw_dump_table(__func__, "raw skb data dump", skb->data,
-				skb->len);
+	raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len);
 	/* at least two bytes will be used for the encoding */
 	if (skb->len < 2)
 		goto drop;
@@ -429,7 +397,7 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head,
 	hlen = (type == LOWPAN_DISPATCH_FRAG1) ?
 			LOWPAN_FRAG1_HEAD_SIZE : LOWPAN_FRAGN_HEAD_SIZE;
 
-	lowpan_raw_dump_inline(__func__, "6lowpan fragment header", head, hlen);
+	raw_dump_inline(__func__, "6lowpan fragment header", head, hlen);
 
 	frag = netdev_alloc_skb(skb->dev,
 				hlen + mlen + plen + IEEE802154_MFR_SIZE);
@@ -449,8 +417,7 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head,
 	skb_copy_to_linear_data_offset(frag, mlen + hlen,
 				       skb_network_header(skb) + offset, plen);
 
-	lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data,
-								frag->len);
+	raw_dump_table(__func__, " raw fragment dump", frag->data, frag->len);
 
 	return dev_queue_xmit(frag);
 }
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
index 535606d..10909e5 100644
--- a/net/ieee802154/6lowpan.h
+++ b/net/ieee802154/6lowpan.h
@@ -232,6 +232,38 @@
 					dest = 16 bit inline */
 #define LOWPAN_NHC_UDP_CS_P_11	0xF3 /* source & dest = 0xF0B + 4bit inline */
 
+#ifdef DEBUG
+/* print data in line */
+static inline void raw_dump_inline(const char *caller, char *msg,
+				   unsigned char *buf, int len)
+{
+	if (msg)
+		pr_debug("%s():%s: ", caller, msg);
+
+	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, buf, len, false);
+}
+
+/* print data in a table format:
+ *
+ * addr: xx xx xx xx xx xx
+ * addr: xx xx xx xx xx xx
+ * ...
+ */
+static inline void raw_dump_table(const char *caller, char *msg,
+				  unsigned char *buf, int len)
+{
+	if (msg)
+		pr_debug("%s():%s:\n", caller, msg);
+
+	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false);
+}
+#else
+static inline void raw_dump_table(const char *caller, char *msg,
+				  unsigned char *buf, int len) { }
+static inline void raw_dump_inline(const char *caller, char *msg,
+				   unsigned char *buf, int len) { }
+#endif
+
 static inline int lowpan_fetch_skb_u8(struct sk_buff *skb, u8 *val)
 {
 	if (unlikely(!pskb_may_pull(skb, 1)))
diff --git a/net/ieee802154/6lowpan_iphc.c b/net/ieee802154/6lowpan_iphc.c
index 57c0b7a..88e7da5 100644
--- a/net/ieee802154/6lowpan_iphc.c
+++ b/net/ieee802154/6lowpan_iphc.c
@@ -58,32 +58,6 @@
 
 #include "6lowpan.h"
 
-/* print data in line */
-static inline void raw_dump_inline(const char *caller, char *msg,
-				   unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s: ", caller, msg);
-	print_hex_dump_debug("", DUMP_PREFIX_NONE,
-		       16, 1, buf, len, false);
-}
-
-/*
- * print data in a table format:
- *
- * addr: xx xx xx xx xx xx
- * addr: xx xx xx xx xx xx
- * ...
- */
-static inline void raw_dump_table(const char *caller, char *msg,
-				unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s:\n", caller, msg);
-	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET,
-		       16, 1, buf, len, false);
-}
-
 /*
  * Uncompress address function for source and
  * destination address(non-multicast).
-- 
1.8.5.1


^ permalink raw reply related

* [RFC v2 BlueZ] build: Add coverage support
From: Luiz Augusto von Dentz @ 2013-12-12 18:57 UTC (permalink / raw)
  To: linux-bluetooth

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

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
+
+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
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"])
+
 AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 5/5] android/tester: Add bdname get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-12 17:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386868475-9610-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 407bfbe..280870a 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -623,6 +623,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,
@@ -892,6 +901,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; \
@@ -942,6 +967,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 4/5] android/tester: Add bdaddr get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-12 17:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386868475-9610-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 5b7082a..407bfbe 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -615,6 +615,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,
@@ -871,6 +879,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; \
@@ -916,6 +937,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 3/5] android/tester: Add discovery timeout set prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-12 17:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386868475-9610-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 d2c0e2f..5b7082a 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -42,6 +42,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
@@ -606,6 +607,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,
@@ -849,6 +858,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; \
@@ -889,6 +911,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 2/5] android/tester: Add scan mode set prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-12 17:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1386868475-9610-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 dcc0e33..d2c0e2f 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -40,6 +40,9 @@
 			adapter_prop_uuids, adapter_prop_cod, \
 			adapter_prop_scan_mode, 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.
@@ -594,6 +597,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,
@@ -824,6 +836,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; \
@@ -859,6 +884,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 1/5] android/tester: Add property check and bdname set success test case
From: Grzegorz Kolodziejczyk @ 2013-12-12 17:14 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 a50ed7b..dcc0e33 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -63,6 +63,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[];
 };
 
@@ -93,7 +94,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;
 };
 
@@ -109,6 +112,8 @@ static void test_update_state(void)
 		return;
 	if (!(data->status_checked))
 		return;
+	if (!(data->property_checked))
+		return;
 	tester_test_passed();
 }
 
@@ -175,11 +180,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)
@@ -195,6 +209,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();
@@ -446,6 +487,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++) {
@@ -454,6 +496,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) {
@@ -538,6 +586,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,
@@ -754,6 +810,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; \
@@ -784,6 +854,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] sixaxis: Fix device detection
From: Bastien Nocera @ 2013-12-12 16:16 UTC (permalink / raw)
  To: linux-bluetooth


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(-)

diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 45fa170..1154c15 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -301,7 +301,7 @@ static int get_supported_device(struct udev_device *udevice, uint16_t *bus)
 	struct udev_device *hid_parent;
 	uint16_t vid, pid;
 	const char *hid_id;
-	int i;
+	guint i;
 
 	hid_parent = udev_device_get_parent_with_subsystem_devtype(udevice,
 								"hid", NULL);
@@ -313,7 +313,7 @@ static int get_supported_device(struct udev_device *udevice, uint16_t *bus)
 	if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3)
 		return -1;
 
-	for (i = 0; G_N_ELEMENTS(devices); i++) {
+	for (i = 0; i < G_N_ELEMENTS(devices); i++) {
 		if (devices[i].vid == vid && devices[i].pid == pid)
 			return i;
 	}
-- 
1.8.4.2



^ 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