Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH 3/4] Added command argument "-J" to indicate preference of using AMP vs BR/EDR.
From: Gustavo F. Padovan @ 2010-07-31 23:14 UTC (permalink / raw)
  To: Inga Stotland; +Cc: linux-bluetooth, rshaffer, johan.hedberg, marcel
In-Reply-To: <1280514626-22559-4-git-send-email-ingas@codeaurora.org>

Hi Inga,

* Inga Stotland <ingas@codeaurora.org> [2010-07-30 11:30:25 -0700]:

> Possible values: "require_br_edr", "prefer_amp", "prefer_br_edr"
> ---
>  test/l2test.c |   34 +++++++++++++++++++++++++++++++++-
>  1 files changed, 33 insertions(+), 1 deletions(-)
	
I would prefer to review and merge the kernel bits first and then go to
the userspace stuff. Doing that we'll have more sure that the socket
options won't change.

-- 
Gustavo F. Padovan
http://padovan.org

^ permalink raw reply

* Re: [PATCH] Bluetooth: Remove __exit from rfcomm_cleanup_ttys()
From: Marcel Holtmann @ 2010-07-31 23:10 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth, Gustavo F. Padovan
In-Reply-To: <1280617025-4001-1-git-send-email-gustavo@padovan.org>

Hi Gustavo,

> rfcomm_cleanup_ttys() is also called from rfcomm_init(), so it can't have
> __exit.
> 
> Reported-by: Mat Martineau <mathewm@codeaurora.org>
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
>  net/bluetooth/rfcomm/tty.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH] bluetooth: Use list_head for hci blacklist head.
From: Marcel Holtmann @ 2010-07-31 23:08 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: David Miller, linux-bluetooth
In-Reply-To: <20100731173259.GA1661@jh-x301>

Hi Johan,

> > > The bdaddr in the list root is completely unused and just
> > > taking up space.
> > > 
> > > Signed-off-by: David S. Miller <davem@davemloft.net>
> > 
> > looks fine to me.
> > 
> > Acked-by: Marcel Holtmann <marcel@holtmann.org>
> > 
> > in case you wanna add it directly to net-next-2.6 tree.
> > 
> > Johan, wanna do a quick test-run of this patch and add Tested-by.
> 
> Seems to work fine.
> 
> Tested-by: Johan Hedberg <johan.hedberg@nokia.com>

thanks.

Dave, I have put the patch into my tree now and will send it to John
shortly. I think it is better that way for the Bluetooth 3.0 guys that
are rebasing against wireless-next-2.6.

Regards

Marcel



^ permalink raw reply

* [PATCH] Bluetooth: Remove __exit from rfcomm_cleanup_ttys()
From: Gustavo F. Padovan @ 2010-07-31 22:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, Gustavo F. Padovan
In-Reply-To: <alpine.DEB.2.00.1007301330030.5809@linux-sea-02>

From: Gustavo F. Padovan <padovan@profusion.mobi>

rfcomm_cleanup_ttys() is also called from rfcomm_init(), so it can't have
__exit.

Reported-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 net/bluetooth/rfcomm/tty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 026205c..befc3a5 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -1183,7 +1183,7 @@ int __init rfcomm_init_ttys(void)
 	return 0;
 }
 
-void __exit rfcomm_cleanup_ttys(void)
+void rfcomm_cleanup_ttys(void)
 {
 	tty_unregister_driver(rfcomm_tty_driver);
 	put_tty_driver(rfcomm_tty_driver);
-- 
1.7.1.1

^ permalink raw reply related

* Re: [PATCH] Bluetooth: Don't send RFC for Basic Mode if only it is supported
From: Gustavo F. Padovan @ 2010-07-31 22:41 UTC (permalink / raw)
  To: Ville Tervo; +Cc: linux-bluetooth@vger.kernel.org, Gustavo F. Padovan
In-Reply-To: <4C52CFDC.9070907@nokia.com>

Hi Ville,

* Ville Tervo <ville.tervo@nokia.com> [2010-07-30 16:13:00 +0300]:

> Hi,
> 
> On 07/29/2010 09:00 PM, ext Gustavo F. Padovan wrote:
> >From: Gustavo F. Padovan<padovan@profusion.mobi>
> >
> >If the remote side doesn't support Enhanced Retransmission Mode neither
> >Streaming Mode, we shall not send the RFC option.
> >Some devices that only supports Basic Mode do not understanding the RFC
> >option. This patch fix the regression found with that devices.
> 
> 
> Yes this is better. After some research i found out that quite many
> old devices are not handling properly unknown options.

Nice, we can put this upstream, do you agree?

> 
> However I found another regression. And this kind of patch is needed
> also. Otherwise the info rsp code is reading feat_mask from failed
> response (and does invalid memory access).
> 
> 
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index 0f34e12..1e174a4 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -3348,6 +3348,13 @@ static inline int
> l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
> 
>         del_timer(&conn->info_timer);
> 
> +       if (result != L2CAP_IR_SUCCESS) {
> +               conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
> +               conn->info_ident = 0;
> +               l2cap_conn_start(conn);
> +               return 0;
> +       }
> +
>         if (type == L2CAP_IT_FEAT_MASK) {
>                 conn->feat_mask = get_unaligned_le32(rsp->data);
> 

Ack. Send a proper GIT patch then we can push this fix. 


-- 
Gustavo F. Padovan
http://padovan.org

^ permalink raw reply

* Re: [PATCH] bluetooth: Use list_head for hci blacklist head.
From: Johan Hedberg @ 2010-07-31 17:32 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: David Miller, linux-bluetooth
In-Reply-To: <1280592977.12579.1.camel@localhost.localdomain>

Hi,

On Sat, Jul 31, 2010, Marcel Holtmann wrote:
> > The bdaddr in the list root is completely unused and just
> > taking up space.
> > 
> > Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> looks fine to me.
> 
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
> 
> in case you wanna add it directly to net-next-2.6 tree.
> 
> Johan, wanna do a quick test-run of this patch and add Tested-by.

Seems to work fine.

Tested-by: Johan Hedberg <johan.hedberg@nokia.com>

Johan

^ permalink raw reply

* Re: [PATCH] bluetooth: Use list_head for hci blacklist head.
From: Marcel Holtmann @ 2010-07-31 16:16 UTC (permalink / raw)
  To: David Miller; +Cc: linux-bluetooth, Johan Hedberg
In-Reply-To: <20100730.215449.226772568.davem@davemloft.net>

Hi Dave,

> The bdaddr in the list root is completely unused and just
> taking up space.
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>

looks fine to me.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

in case you wanna add it directly to net-next-2.6 tree.

Johan, wanna do a quick test-run of this patch and add Tested-by.

Regards

Marcel



^ permalink raw reply

* [PATCH 6/6] Support for generating dictionary value of service UUIDs.
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280576713-1398-1-git-send-email-ingas@codeaurora.org>

Add service UUIDs from EIR to device properties in "Device Found" signal.
---
 src/adapter.c  |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/adapter.h  |    4 +-
 src/dbus-hci.c |    6 ++--
 3 files changed, 97 insertions(+), 8 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 2560440..b353fa6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2748,8 +2748,84 @@ static void emit_device_found(const char *path, const char *address,
 	g_dbus_send_message(connection, signal);
 }
 
+static int get_uuid_count_eir(uint8_t *eir_data)
+{
+	uint8_t len = 0;
+	int count = 0;
+
+	while (len < EIR_DATA_LENGTH) {
+		uint8_t type = eir_data[1];
+		uint8_t field_len = eir_data[0];
+		if (type == EIR_UUID16_SOME || type == EIR_UUID16_ALL)
+			count += field_len/2;
+		else if (type == EIR_UUID32_SOME || type == EIR_UUID32_ALL)
+			count += field_len/4;
+		else if (type == EIR_UUID128_SOME || type == EIR_UUID128_ALL)
+			count += field_len/16;
+		len += field_len + 1;
+		eir_data += field_len + 1;
+	}
+
+	return count;
+}
+
+static void get_uuids_eir(char **uuids, uint8_t *eir_data)
+{
+	uint8_t len = 0;
+
+	/* Count UUID16, UUID32 and UUID128 */
+	while (len < EIR_DATA_LENGTH) {
+		uint8_t field_len = eir_data[0];
+		uint8_t type = eir_data[1];
+		int count;
+		uuid_t service;
+		int size;
+		uint8_t *data = &eir_data[2];
+		int i, k;
+
+		/* Generate uuids in SDP format (EIR data is Little Endian) */
+		if (type == EIR_UUID16_SOME || type == EIR_UUID16_ALL) {
+			size = 2;
+			count = field_len/size;
+			service.type = SDP_UUID16;
+			for (i = 0; i < count; i++) {
+				uint16_t val16 = data[1];
+				val16 = (val16<<8) + data[0];
+				service.value.uuid16 = val16;
+				*uuids++ = bt_uuid2string(&service);
+				data += size;
+			}
+		} else if (type == EIR_UUID32_SOME || type == EIR_UUID32_ALL) {
+			size = 4;
+			count = field_len/size;
+			service.type = SDP_UUID32;
+			for (i = 0; i < count; i++) {
+				uint32_t val32 = data[3];
+				for (k = size-2; k >= 0; k--)
+					val32 = (val32<<8) + data[k];
+				service.value.uuid32 = val32;
+				*uuids++ = bt_uuid2string(&service);
+				data += size;
+			}
+		} else if (type == EIR_UUID128_SOME || type == EIR_UUID128_ALL) {
+			size = 16;
+			count = field_len/size;
+			service.type = SDP_UUID128;
+			for (i = 0; i < count; i++) {
+				for (k = 0; k < size; k++)
+					service.value.uuid128.data[k] = data[size-k-1];
+				*uuids++ = bt_uuid2string(&service);
+				data += size;
+			}
+		}
+
+		len += field_len + 1;
+		eir_data += field_len + 1;
+	}
+}
+
 void adapter_emit_device_found(struct btd_adapter *adapter,
-				struct remote_dev_info *dev)
+				struct remote_dev_info *dev, uint8_t *eir_data)
 {
 	struct btd_device *device;
 	char peer_addr[18], local_addr[18];
@@ -2757,6 +2833,8 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 	dbus_bool_t paired = FALSE;
 	dbus_int16_t rssi = dev->rssi;
 	char *alias;
+	char **uuids = NULL;
+	int uuid_count = 0;
 
 	ba2str(&dev->bdaddr, peer_addr);
 	ba2str(&adapter->bdaddr, local_addr);
@@ -2776,6 +2854,15 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 	} else
 		alias = g_strdup(dev->alias);
 
+	/* Extract UUIDs from extended inquiry response if any*/
+	if (eir_data != NULL)
+		uuid_count = get_uuid_count_eir(eir_data);
+
+	if (uuid_count > 0) {
+		uuids = g_new0(char *, uuid_count + 1);
+		get_uuids_eir(uuids, eir_data);
+	}
+
 	emit_device_found(adapter->path, paddr,
 			"Address", DBUS_TYPE_STRING, &paddr,
 			"Class", DBUS_TYPE_UINT32, &dev->class,
@@ -2785,15 +2872,17 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 			"Alias", DBUS_TYPE_STRING, &alias,
 			"LegacyPairing", DBUS_TYPE_BOOLEAN, &dev->legacy,
 			"Paired", DBUS_TYPE_BOOLEAN, &paired,
+			"UUIDs", DBUS_TYPE_ARRAY, &uuids, uuid_count,
 			NULL);
 
 	g_free(alias);
+	g_strfreev(uuids);
 }
 
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 				int8_t rssi, uint32_t class, const char *name,
 				const char *alias, gboolean legacy,
-				name_status_t name_status)
+				name_status_t name_status, uint8_t *eir_data)
 {
 	struct remote_dev_info *dev, match;
 
@@ -2832,7 +2921,7 @@ done:
 	adapter->found_devices = g_slist_sort(adapter->found_devices,
 						(GCompareFunc) dev_rssi_cmp);
 
-	adapter_emit_device_found(adapter, dev);
+	adapter_emit_device_found(adapter, dev, eir_data);
 }
 
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
diff --git a/src/adapter.h b/src/adapter.h
index 8226514..a7eca0e 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -113,10 +113,10 @@ struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 				int8_t rssi, uint32_t class, const char *name,
 				const char *alias, gboolean legacy,
-				name_status_t name_status);
+				name_status_t name_status, uint8_t *eir_data);
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 void adapter_emit_device_found(struct btd_adapter *adapter,
-				struct remote_dev_info *dev);
+				struct remote_dev_info *dev, uint8_t *eir_data);
 void adapter_update_oor_devices(struct btd_adapter *adapter);
 void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
 void adapter_setname_complete(bdaddr_t *local, uint8_t status);
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index b83506f..6d27caa 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -515,7 +515,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	if (dev) {
 		adapter_update_found_devices(adapter, peer, rssi, class,
 						NULL, NULL, dev->legacy,
-						NAME_NOT_REQUIRED);
+						NAME_NOT_REQUIRED, data);
 		return;
 	}
 
@@ -566,7 +566,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 
 	/* add in the list to track name sent/pending */
 	adapter_update_found_devices(adapter, peer, rssi, class, name, alias,
-					legacy, name_status);
+					legacy, name_status, data);
 
 	g_free(name);
 	g_free(alias);
@@ -642,7 +642,7 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status,
 	if (dev_info) {
 		g_free(dev_info->name);
 		dev_info->name = g_strdup(name);
-		adapter_emit_device_found(adapter, dev_info);
+		adapter_emit_device_found(adapter, dev_info, NULL);
 	}
 
 	if (device)
-- 
1.7.2

-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 5/6] Handle arrays in device properties dictionary
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280576713-1398-1-git-send-email-ingas@codeaurora.org>

---
 src/adapter.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index af60495..2560440 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2700,6 +2700,7 @@ static void append_dict_valist(DBusMessageIter *iter,
 	DBusMessageIter dict;
 	const char *key;
 	int type;
+	int n_elements;
 	void *val;
 
 	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
@@ -2711,7 +2712,12 @@ static void append_dict_valist(DBusMessageIter *iter,
 	while (key) {
 		type = va_arg(var_args, int);
 		val = va_arg(var_args, void *);
-		dict_append_entry(&dict, key, type, val);
+		if (type == DBUS_TYPE_ARRAY) {
+			n_elements = va_arg(var_args, int);
+			if (n_elements > 0)
+				dict_append_array(&dict, key, DBUS_TYPE_STRING, val, n_elements);
+		} else
+			dict_append_entry(&dict, key, type, val);
 		key = va_arg(var_args, char *);
 	}
 
-- 
1.7.2

-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 4/6] Fix in logic to write EIR when SDP records are changed.
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280576713-1398-1-git-send-email-ingas@codeaurora.org>

Whenver SDP service record is added/deleted/modified check for whether 
class of device needs to be updated as well. If the update is 
needed, proceed as before and new EIR will be written subsequently. 
If the class of device is already present, just update EIR and return.
---
 src/adapter.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 789a196..af60495 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -137,6 +137,8 @@ struct btd_adapter {
 	gint ref;
 };
 
+static void update_ext_inquiry_response(struct btd_adapter *adapter);
+
 static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
 					guint interval);
 
@@ -216,11 +218,15 @@ static int adapter_set_service_classes(struct btd_adapter *adapter,
 	adapter->wanted_cod &= 0x00ffff;
 	adapter->wanted_cod |= (value << 16);
 
-	/* If we already have the CoD we want or the cache is enabled or an
-	 * existing CoD write is in progress just bail out */
-	if (adapter->current_cod == adapter->wanted_cod ||
-			adapter->cache_enable || adapter->pending_cod)
+	/* If the cache is enabled or an existing CoD write is in progress
+	 * just bail out */
+	if(adapter->cache_enable || adapter->pending_cod)
 		return 0;
+	/* If we already have the CoD we want, update EIR and return */
+	if (adapter->current_cod == adapter->wanted_cod) {
+		update_ext_inquiry_response(adapter);
+		return 0;
+	}
 
 	DBG("Changing service classes to 0x%06x", adapter->wanted_cod);
 
-- 
1.7.2

-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 3/6] Support for adding UUID128 to extended inquiry response
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280576713-1398-1-git-send-email-ingas@codeaurora.org>

---
 src/sdpd-service.c |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index c20df2e..1314ada 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -49,6 +49,8 @@
 #include "manager.h"
 #include "adapter.h"
 
+#define SIZEOF_UUID128 16
+
 static sdp_record_t *server = NULL;
 
 static uint16_t did_vendor = 0x0000;
@@ -174,6 +176,62 @@ static void update_svclass_list(const bdaddr_t *src)
 
 }
 
+static void eir_generate_uuid128(sdp_list_t *list,
+					uint8_t *ptr, uint16_t *eir_len)
+{
+	int i, k, index = 0;
+	uint16_t len = *eir_len;
+	uint8_t *uuid128;
+	gboolean truncated = FALSE;
+
+	/* Store UUID128 in place, skip 2 bytes to insert type and length later */
+	uuid128 = ptr + 2;
+
+	for (; list; list = list->next) {
+		sdp_record_t *rec = (sdp_record_t *) list->data;
+
+		if (rec->svclass.type != SDP_UUID128)
+			continue;
+
+		/* Stop if not enough space to put next UUID128 */
+		if ((len + 2 + SIZEOF_UUID128) > EIR_DATA_LENGTH) {
+			truncated = TRUE;
+			break;
+		}
+
+		/* Check for duplicates, EIR data is Little Endian */
+		for (i = 0; i < index; i++) {
+			for (k = 0; k < SIZEOF_UUID128; k++) {
+				if (uuid128[i*SIZEOF_UUID128 + k] !=
+					rec->svclass.value.uuid128.data[SIZEOF_UUID128 - k])
+					break;
+			}
+			if (k == SIZEOF_UUID128)
+				break;
+		}
+
+		if (i < index)
+			continue;
+
+		/* EIR data is Little Endian */
+		for (k = 0; k < SIZEOF_UUID128; k++)
+			uuid128[index*SIZEOF_UUID128 + k] =
+				rec->svclass.value.uuid128.data[SIZEOF_UUID128 - 1 - k];
+
+		len += SIZEOF_UUID128;
+		index++;
+	}
+
+	if (index > 0 || truncated) {
+		/* EIR Data length */
+		ptr[0] = (index * SIZEOF_UUID128) + 1;
+		/* EIR Data type */
+		ptr[1] = (truncated) ? EIR_UUID128_SOME : EIR_UUID128_ALL;
+		len += 2;
+		*eir_len = len;
+	}
+}
+
 void create_ext_inquiry_response(const char *name,
 					int8_t tx_power, sdp_list_t *services,
 					uint8_t *data)
@@ -271,6 +329,10 @@ void create_ext_inquiry_response(const char *name,
 			*ptr++ = (uuid16[i] & 0xff00) >> 8;
 		}
 	}
+
+	/* Group all UUID128 types */
+	if (eir_len <= EIR_DATA_LENGTH - 2)
+		eir_generate_uuid128(services, ptr, &eir_len);
 }
 
 void register_public_browse_group(void)
-- 
1.7.2

-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 2/6] Clean up code that generates extended inquiry response.
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280576713-1398-1-git-send-email-ingas@codeaurora.org>

Minor fix when skipping duplicate UUID16 from EIR.
---
 src/sdpd-service.c |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index cdbb4f4..c20df2e 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -180,35 +180,41 @@ void create_ext_inquiry_response(const char *name,
 {
 	sdp_list_t *list = services;
 	uint8_t *ptr = data;
-	uint16_t uuid[24];
+	uint16_t eir_len = 0;
+	uint16_t uuid16[EIR_DATA_LENGTH/2];
 	int i, index = 0;
+	gboolean truncated = FALSE;
 
 	if (name) {
 		int len = strlen(name);
 
+		/* EIR Data type */
 		if (len > 48) {
 			len = 48;
-			ptr[1] = 0x08;
+			ptr[1] = EIR_NAME_SHORT;
 		} else
-			ptr[1] = 0x09;
+			ptr[1] = EIR_NAME_COMPLETE;
 
+		/* EIR Data length */
 		ptr[0] = len + 1;
 
 		memcpy(ptr + 2, name, len);
 
-		ptr += len + 2;
+		eir_len += (len + 2);
+		ptr += (len + 2);
 	}
 
 	if (tx_power != 0) {
 		*ptr++ = 2;
-		*ptr++ = 0x0a;
+		*ptr++ = EIR_TX_POWER;
 		*ptr++ = (uint8_t) tx_power;
+		eir_len += 3;
 	}
 
 	if (did_vendor != 0x0000) {
 		uint16_t source = 0x0002;
 		*ptr++ = 9;
-		*ptr++ = 0x10;
+		*ptr++ = EIR_DEVICE_ID;
 		*ptr++ = (source & 0x00ff);
 		*ptr++ = (source & 0xff00) >> 8;
 		*ptr++ = (did_vendor & 0x00ff);
@@ -217,10 +223,10 @@ void create_ext_inquiry_response(const char *name,
 		*ptr++ = (did_product & 0xff00) >> 8;
 		*ptr++ = (did_version & 0x00ff);
 		*ptr++ = (did_version & 0xff00) >> 8;
+		eir_len += 10;
 	}
 
-	ptr[1] = 0x03;
-
+	/* Group all UUID16 types */
 	for (; list; list = list->next) {
 		sdp_record_t *rec = (sdp_record_t *) list->data;
 
@@ -233,28 +239,36 @@ void create_ext_inquiry_response(const char *name,
 		if (rec->svclass.value.uuid16 == PNP_INFO_SVCLASS_ID)
 			continue;
 
-		if (index > 23) {
-			ptr[1] = 0x02;
+		/* Stop if not enough space to put next UUID16 */
+		if ((eir_len + 2 + sizeof(uint16_t)) > EIR_DATA_LENGTH) {
+			truncated = TRUE;
 			break;
 		}
 
+		/* Check for duplicates */
 		for (i = 0; i < index; i++)
-			if (uuid[i] == rec->svclass.value.uuid16)
+			if (uuid16[i] == rec->svclass.value.uuid16)
 				break;
 
-		if (i == index - 1)
+		if (i < index)
 			continue;
 
-		uuid[index++] = rec->svclass.value.uuid16;
+		uuid16[index++] = rec->svclass.value.uuid16;
+		eir_len += sizeof(uint16_t);
 	}
 
 	if (index > 0) {
-		ptr[0] = (index * 2) + 1;
+		/* EIR Data length */
+		ptr[0] = (index * sizeof(uint16_t)) + 1;
+		/* EIR Data type */
+		ptr[1] = (truncated) ? EIR_UUID16_SOME : EIR_UUID16_ALL;
+
 		ptr += 2;
+		eir_len += 2;
 
 		for (i = 0; i < index; i++) {
-			*ptr++ = (uuid[i] & 0x00ff);
-			*ptr++ = (uuid[i] & 0xff00) >> 8;
+			*ptr++ = (uuid16[i] & 0x00ff);
+			*ptr++ = (uuid16[i] & 0xff00) >> 8;
 		}
 	}
 }
-- 
1.7.2

^ permalink raw reply related

* [PATCH 1/6] Spec constants for Extended Inquiry Response field types
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280576713-1398-1-git-send-email-ingas@codeaurora.org>

---
 src/sdpd.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/sdpd.h b/src/sdpd.h
index e93b0b6..c1d69a9 100644
--- a/src/sdpd.h
+++ b/src/sdpd.h
@@ -34,6 +34,19 @@
 #define SDPDBG(fmt...)
 #endif
 
+#define EIR_DATA_LENGTH  240
+
+#define EIR_UUID16_SOME             0x02  /* 16-bit UUID, more available */
+#define EIR_UUID16_ALL              0x03  /* 16-bit UUID, all listed */
+#define EIR_UUID32_SOME             0x04  /* 32-bit UUID, more available */
+#define EIR_UUID32_ALL              0x05  /* 32-bit UUID, all listed */
+#define EIR_UUID128_SOME            0x06  /* 128-bit UUID, more available */
+#define EIR_UUID128_ALL             0x07  /* 128-bit UUID, all listed */
+#define EIR_NAME_SHORT              0x08  /* shortened local name */
+#define EIR_NAME_COMPLETE           0x09  /* complete local name */
+#define EIR_TX_POWER                0x0A  /* transmit power level */
+#define EIR_DEVICE_ID               0x10  /* device ID */
+
 typedef struct request {
 	bdaddr_t device;
 	bdaddr_t bdaddr;
-- 
1.7.2

-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH v5 0/6] Enhanced support for extended inquiry response
From: Inga Stotland @ 2010-07-31 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel

EIR needs to be updated whenever local SDP record database changes.
Previously, when an SDP record was added/removed/updated, EIR would 
be written in callback fired off HCI "Command Complete" event set off by
"Write Class Of Device" command. However, if the class of device did not
need to be updated, the EIR write was not happening either. This
implementation has been augmented to write new EIR when modification
in SDP database does not lead to updating of class of device.

Added support for UUID128 service descriptors in local EIR. 

Service UUIDs are written to "device properties" dictionary  when emitting
"Device Found" signal. This allows peek at available services offered by 
a remote device without establishing SDP connection.


-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply

* 3 concurrent SCO connection
From: Ahmed Ragab @ 2010-07-31 11:27 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

As per the the Bluetooth documentation on the sig group each Bluetooth dongle
Is allowed to make up to 3 sco connections. in order to do that we have to
Bind the same dongle (since we have multiple dongles ) to an rfcomm
connection 3 times which is not possible
Since it will give address already in use error. so how can i make the
same dongle make 3 rfcomm connections
And 3 sco connection or is there a limitation on the number of rfcomm
connections if we want to make 3 sco
Connection.

Regards

elmasri

^ permalink raw reply

* [PATCH] bluetooth: Use list_head for hci blacklist head.
From: David Miller @ 2010-07-31  4:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel


The bdaddr in the list root is completely unused and just
taking up space.

Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 8b28962..4568b93 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -132,7 +132,7 @@ struct hci_dev {
 
 	struct inquiry_cache	inq_cache;
 	struct hci_conn_hash	conn_hash;
-	struct bdaddr_list	blacklist;
+	struct list_head	blacklist;
 
 	struct hci_dev_stats	stat;
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8303f1c..c52f091 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -924,7 +924,7 @@ int hci_register_dev(struct hci_dev *hdev)
 
 	hci_conn_hash_init(hdev);
 
-	INIT_LIST_HEAD(&hdev->blacklist.list);
+	INIT_LIST_HEAD(&hdev->blacklist);
 
 	memset(&hdev->stat, 0, sizeof(struct hci_dev_stats));
 
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 4f170a5..83acd16 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -168,9 +168,8 @@ static int hci_sock_release(struct socket *sock)
 struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr)
 {
 	struct list_head *p;
-	struct bdaddr_list *blacklist = &hdev->blacklist;
 
-	list_for_each(p, &blacklist->list) {
+	list_for_each(p, &hdev->blacklist) {
 		struct bdaddr_list *b;
 
 		b = list_entry(p, struct bdaddr_list, list);
@@ -202,7 +201,7 @@ static int hci_blacklist_add(struct hci_dev *hdev, void __user *arg)
 
 	bacpy(&entry->bdaddr, &bdaddr);
 
-	list_add(&entry->list, &hdev->blacklist.list);
+	list_add(&entry->list, &hdev->blacklist);
 
 	return 0;
 }
@@ -210,9 +209,8 @@ static int hci_blacklist_add(struct hci_dev *hdev, void __user *arg)
 int hci_blacklist_clear(struct hci_dev *hdev)
 {
 	struct list_head *p, *n;
-	struct bdaddr_list *blacklist = &hdev->blacklist;
 
-	list_for_each_safe(p, n, &blacklist->list) {
+	list_for_each_safe(p, n, &hdev->blacklist) {
 		struct bdaddr_list *b;
 
 		b = list_entry(p, struct bdaddr_list, list);
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index ce44c47..8fb967b 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -439,12 +439,11 @@ static const struct file_operations inquiry_cache_fops = {
 static int blacklist_show(struct seq_file *f, void *p)
 {
 	struct hci_dev *hdev = f->private;
-	struct bdaddr_list *blacklist = &hdev->blacklist;
 	struct list_head *l;
 
 	hci_dev_lock_bh(hdev);
 
-	list_for_each(l, &blacklist->list) {
+	list_for_each(l, &hdev->blacklist) {
 		struct bdaddr_list *b;
 		bdaddr_t bdaddr;
 

^ permalink raw reply related

* Re: Copyrights and Legal header
From: Marcel Holtmann @ 2010-07-30 21:38 UTC (permalink / raw)
  To: ingas; +Cc: Ron Shaffer, linux-bluetooth, johan.hedberg
In-Reply-To: <6c8d968ad4264d852b7dfc70b813cf70.squirrel@www.codeaurora.org>

Hi Inga,

> A quick question re Copyrights and Legal header. If I am adding a
> completely new file in bluez user space, what are the guidelines for the
> license and copyrights header?

it has to be the same as the other ones. Except the copyright line will
state you or your company as copyright holders.

Regards

Marcel



^ permalink raw reply

* Re: obexd 0.29 and N900 PC Suite
From: Marcel J.E. Mol @ 2010-07-30 20:49 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Harald Schmitt, linux-bluetooth
In-Reply-To: <AANLkTimKLcbg2d5Ev5AVBhQqRRrgV-aKKkTRfRzOFAK=@mail.gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset*=utf-8''%E2%80%9Cus-ascii, Size: 1827 bytes --]

On Fri, Jul 30, 2010 at 06:08:23PM +0300, Luiz Augusto von Dentz wrote:
> Hi,
> 
> On Fri, Jul 30, 2010 at 1:29 PM, Harald Schmitt <linux@hschmitt.de> wrote:
> > I have testes following command and it seems to work:
> > dbus-send --system --type=signal / com.meego.usb_moded.sig_usb_state_ind
> > string:'ovi_suite'
> > If one would just add this line to pcsuite-enable.sh under the SIGUSR1 then
> > both types of obexd would work?
> > Luiz could you confirm this? Do we also need a dbus-command for disconnect
> > with string:'USB disconnected' in pcsuite-disable.sh?
> 
> Hmm it may work with that but I would first just revert the patch I
> suggest other day since without that part there could be some other
> components still sending SIGUSR1 to obexd which might kill it, maybe I
> can just reintroduce SIGUSR1 and then have a config option saying
> which method to use for usb cable detection. What do you guys think?

Well, I just tested the dbus method on the n900 with an obexd 0.29 
(including the updates I already posted here plus a few other updates
including a basic IRMC server implementation) and pcsuite seems to 
work fine. But I did not test extensively (contact/calendar download
work file and file browsing too).

I don't know if there are other tools using signalling to obexd, maybe
people from the nokia n900/maemo group can tell...

-Marcel
-- 
     ======--------         Marcel J.E. Mol                MESA Consulting B.V.
    =======---------        ph. +31-(0)6-54724868          P.O. Box 112
    =======---------        marcel@mesa.nl                 2630 AC  Nootdorp
__==== www.mesa.nl ---____U_n_i_x______I_n_t_e_r_n_e_t____ The Netherlands ____
 They couldn't think of a number,           Linux user 1148  --  counter.li.org
    so they gave me a name!  -- Rupert Hine  --  www.ruperthine.com

^ permalink raw reply

* Re: [PATCH 2/2] Bluetooth: Add __init and __exit marks to RFCOMM
From: Mat Martineau @ 2010-07-30 20:39 UTC (permalink / raw)
  To: gustavo; +Cc: linux-bluetooth, marcel, padovan
In-Reply-To: <1279947885-19304-2-git-send-email-gustavo@padovan.org>


Gustavo -

On Sat, 24 Jul 2010, Gustavo F. Padovan wrote:

> From: Gustavo F. Padovan <padovan@profusion.mobi>
>
> Those annotation save memory and space on the binary. __init code is
> discarded just after execute and __exit code is discarded if the module is
> built into the kernel image or unload of modules is not allowed.
>
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> net/bluetooth/rfcomm/sock.c |    2 +-
> net/bluetooth/rfcomm/tty.c  |    4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
> index 43fbf6b..44a6232 100644
> --- a/net/bluetooth/rfcomm/sock.c
> +++ b/net/bluetooth/rfcomm/sock.c
> @@ -1152,7 +1152,7 @@ error:
> 	return err;
> }
>
> -void rfcomm_cleanup_sockets(void)
> +void __exit rfcomm_cleanup_sockets(void)
> {
> 	debugfs_remove(rfcomm_sock_debugfs);
>
> diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
> index 309b6c2..026205c 100644
> --- a/net/bluetooth/rfcomm/tty.c
> +++ b/net/bluetooth/rfcomm/tty.c
> @@ -1153,7 +1153,7 @@ static const struct tty_operations rfcomm_ops = {
> 	.tiocmset		= rfcomm_tty_tiocmset,
> };
>
> -int rfcomm_init_ttys(void)
> +int __init rfcomm_init_ttys(void)
> {
> 	rfcomm_tty_driver = alloc_tty_driver(RFCOMM_TTY_PORTS);
> 	if (!rfcomm_tty_driver)
> @@ -1183,7 +1183,7 @@ int rfcomm_init_ttys(void)
> 	return 0;
> }
>
> -void rfcomm_cleanup_ttys(void)
> +void __exit rfcomm_cleanup_ttys(void)
> {
> 	tty_unregister_driver(rfcomm_tty_driver);
> 	put_tty_driver(rfcomm_tty_driver);

The change to rfcomm_cleanup_ttys() causes a warning:

WARNING: modpost: Found 1 section mismatch(es).

rfcomm_cleanup_ttys() is also called by rfcomm_init, so it should not 
be marked with __exit.

--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply

* seeking debug advice for a hanging serial device
From: Steve Castellotti @ 2010-07-30 20:19 UTC (permalink / raw)
  To: linux-bluetooth

Hello all-

    I am in the process of writing a device driver for a consumer-grade
Bluetooth EEG headset which presents packets of information through a
serial protocol, transmitting data packets at 512 Hz. The code is being
written in Python using the Pyserial module and has been verified to
work reliably when executed on the Windows platform.

    However under Linux, the device frequently hangs within 5 seconds of
attempting to read the data stream.

    This occurs whether through my code (which is platform agnostic) or
simply cat'ing the RFCOMM device from a console (both in normal and raw
mode).

    I have tested this hardware using three different Bluetooth adapters
on six different systems running three different Linux distributions on
two different processor architectures, all with the same results:

Windows XP: Works without error

Windows Vista: Works without error

Fedora 12 (x86): Fails on two different systems running the same/latest
software updates available
    bluez-4.58-1.fc12.i686
    kernel 2.6.32.16-141.fc12.i686.PAE

Fedora 13 (x86): Fails
    bluez-4.64.1.fc13.i686
    kernel 2.6.33.6-147.fc13.i686.PAE

Maemo 5 (ARM): Fails
    bluez 4.60-0maemo1.5+0m5
    kernel 2.6.28-omap1


    Under Linux, I am connecting to my device with the following
command:

rfcomm connect rfcomm0 XX:XX:XX:XX:XX:XX 3


    I connect on the third channel because the first channel is also a
serial port but is used for operating the headset as a hands-free device
for connecting to a mobile phone or VOIP application. The second channel
does not respond.


    If I simply run:

cat /dev/rfcomm0


    I will get packet bytes dumped to the console for 2 seconds or so,
then the device hangs until I disconnect (sometimes requiring "rfcomm
release /dev/rfcomm0" or power cycling the device).

    When running through my code I am careful to set the baud rate and
similar parameters exactly as described in the device documentation. The
portion of the code which reads from the device executes in a separate
thread from the processing of the data within the packets, so there
should be no issues regards a buffer under-run or similar (and I have
also tested code which simple reads from the device and prints bytes to
the console as the sole process in the main thread). The same result
occurs however, I might receive packets for 2-5 seconds, then the device
(or at least the Bluetooth connection) hangs.

    If I connect to the device using rfcomm in "raw" mode ("-r") then
the system itself will actually hang along with the device, requiring a
complete power-cycle of my test machine as well to fully recover.

    On very rare occasions I have managed to access the stream past the
first several seconds, in which case the device will continue to operate
quite happily for an hour or more without interruption. This is without
changes to code or connection procedure.


    I am at a complete loss as to how to proceed next with further
debugging. Granted I am coding in Python which is perhaps one layer
removed from the hardware versus coding in C, but the identical code and
modules work without issue under Windows on multiple systems.

    Can anyone please offer me some pointers or directions to explore?

    I am happy to produce any sort of relevant kernel or Bluetooth
device debug logs if they might prove relevant (though I would
appreciate a link to a document or procedure explaining a preferred
method for collecting such data).


Cheers


Steve Castellotti




^ permalink raw reply

* Re: Copyrights and Legal header
From: ingas @ 2010-07-30 19:13 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Ron Shaffer, Inga Stotland, linux-bluetooth, johan.hedberg
In-Reply-To: <1278696935.10421.139.camel@localhost.localdomain>

Hi Marcel,

> Hi Ron,
>
>> >>  void register_public_browse_group(void)
>> >> diff --git a/src/sdpd.h b/src/sdpd.h
>> >> index e93b0b6..8fd8bbe 100644
>> >> --- a/src/sdpd.h
>> >> +++ b/src/sdpd.h
>> >> @@ -6,6 +6,7 @@
>> >>   *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
>> >>   *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
>> >>   *  Copyright (C) 2002-2003  Stephen Crane
>> <steve.crane@rococosoft.com>
>> >> + *  Copyright (C) 2010, Code Aurora Forum. All rights reserved.
>> >
>> > I prefer that we actually see major code contributions that justify a
>> > copyright here before you start adding it. And so let the maintainers
>> > worry about that later on. I don't wanna see just random copyright
>> > additions for obvious fixes or changes that are most likely even
>> derived
>> > from existing code.
>> >
>>
>> I'm unsure of the reasoning unless the idea is to add copyright markings
>> to show attribution and level of contribution. In our case it's just a
>> legal marking.
>>
>> If the reasoning for adding or not adding is the former, does this not
>> rise to that level, and for my own education and future reference why
>> not?
>
> we normally automatically add the copyright for companies or individual
> when they make large contributions. Not just small extensions or fixes
> where it is questionable if they are copyrightable anyway.
>
> For just tracking contributions, we have GIT :)
>
> Regards
>
> Marcel
>

A quick question re Copyrights and Legal header. If I am adding a
completely new file in bluez user space, what are the guidelines for the
license and copyrights header?

Thank you,

Inga

^ permalink raw reply

* [PATCH 4/4] Allow changing AMP vs BR/EDR preference from stdin when connection is up.
From: Inga Stotland @ 2010-07-30 18:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280514626-22559-1-git-send-email-ingas@codeaurora.org>

Use the following keys:

"a", "A" - prefer AMP;
"b", "B" - prefer BR/EDR;
"r", "R" - require BR/EDR
---
 test/l2test.c |   87 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 76 insertions(+), 11 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index 377c12e..1f627a7 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -191,6 +191,46 @@ static void hexdump(unsigned char *s, unsigned long l)
 	}
 }
 
+static void do_keys(int sk)
+{
+	struct pollfd p;
+	int len;
+	char c;
+	int old_amp_pref = amp_pref;
+
+	p.fd = 0;
+	p.events = POLLIN;
+
+	if (poll(&p, 1, 0)) {
+		len = read(0, &c, 1);
+		if (len < 0)
+			return;
+
+		switch (c) {
+		case 'A':
+		case 'a':
+			amp_pref = L2CAP_AMP_PREFER_AMP;
+			break;
+		case 'B':
+		case 'b':
+			amp_pref = L2CAP_AMP_PREFER_BR_EDR;
+			break;
+		case 'R':
+		case 'r':
+			amp_pref = L2CAP_AMP_REQUIRE_BR_EDR;
+			break;
+		default:
+			return;
+		}
+
+		setsockopt(sk, SOL_L2CAP, L2CAP_AMP, &amp_pref, sizeof(amp_pref));
+		syslog(LOG_INFO, "AMP preference updated to %d (previously %d)",
+			amp_pref, old_amp_pref);
+	}
+
+	return;
+}
+
 static int do_connect(char *svr)
 {
 	struct sockaddr_l2 addr;
@@ -584,11 +624,17 @@ static void dump_mode(int sk)
 		fd_set rset;
 
 		FD_ZERO(&rset);
+		FD_SET(0, &rset);
 		FD_SET(sk, &rset);
 
 		if (select(sk + 1, &rset, NULL, NULL, NULL) < 0)
 			return;
 
+		if (FD_ISSET(0, &rset)) {
+			do_keys(sk);
+			continue;
+		}
+
 		if (!FD_ISSET(sk, &rset))
 			continue;
 
@@ -620,7 +666,7 @@ static void dump_mode(int sk)
 static void recv_mode(int sk)
 {
 	struct timeval tv_beg, tv_end, tv_diff;
-	struct pollfd p;
+	struct pollfd p[2];
 	char ts[30];
 	long total;
 	uint32_t seq;
@@ -643,8 +689,11 @@ static void recv_mode(int sk)
 
 	memset(ts, 0, sizeof(ts));
 
-	p.fd = sk;
-	p.events = POLLIN | POLLERR | POLLHUP;
+	p[0].fd = sk;
+	p[0].events = POLLIN | POLLERR | POLLHUP;
+
+	p[1].fd = 0;
+	p[1].events = POLLIN;
 
 	seq = 0;
 	while (1) {
@@ -655,13 +704,19 @@ static void recv_mode(int sk)
 			uint16_t l;
 			int i;
 
-			p.revents = 0;
-			if (poll(&p, 1, -1) <= 0)
+			p[0].revents = 0;
+			p[1].revents = 0;
+			if (poll(p, 2, -1) <= 0)
 				return;
 
-			if (p.revents & (POLLERR | POLLHUP))
+			if (p[0].revents & (POLLERR | POLLHUP))
 				return;
 
+			if (p[1].revents & POLLIN) {
+				do_keys(sk);
+				continue;
+			}
+
 			len = recv(sk, buf, data_size, 0);
 			if (len < 0) {
 				if (reliable && (errno == ECOMM)) {
@@ -780,6 +835,8 @@ static void do_send(int sk)
 
 			sent += len;
 			size -= len;
+
+			do_keys(sk);
 		}
 
 		if (num_frames && delay && count && !(seq % count))
@@ -831,19 +888,27 @@ static void reconnect_mode(char *svr)
 
 static void connect_mode(char *svr)
 {
-	struct pollfd p;
+	struct pollfd p[2];
 	int sk;
 
 	if ((sk = do_connect(svr)) < 0)
 		exit(1);
 
-	p.fd = sk;
-	p.events = POLLERR | POLLHUP;
+	p[0].fd = sk;
+	p[0].events = POLLERR | POLLHUP;
+
+	p[1].fd = 0;
+	p[1].events = POLLIN;
 
 	while (1) {
-		p.revents = 0;
-		if (poll(&p, 1, 500))
+		p[0].revents = 0;
+		p[1].revents = 0;
+		if (poll(p, 2, 500) < 0)
+			break;
+		if (p[0].revents & (POLLERR | POLLHUP))
 			break;
+		if (p[1].revents & POLLIN)
+			do_keys(sk);
 	}
 
 	syslog(LOG_INFO, "Disconnected");
-- 
1.7.2

--
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 3/4] Added command argument "-J" to indicate preference of using AMP vs BR/EDR.
From: Inga Stotland @ 2010-07-30 18:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280514626-22559-1-git-send-email-ingas@codeaurora.org>

Possible values: "require_br_edr", "prefer_amp", "prefer_br_edr"
---
 test/l2test.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index 361f80c..377c12e 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -81,6 +81,9 @@ static int txwin_size = L2CAP_DEFAULT_TX_WINDOW;
 /* Default Max Transmission (number of retries per packet) */
 static int max_transmit = L2CAP_DEFAULT_MAX_TX;
 
+/* Default AMP preference */
+static int amp_pref = L2CAP_AMP_REQUIRE_BR_EDR;
+
 /* Default data size */
 static long data_size = -1;
 static long buffer_size = 2048;
@@ -295,6 +298,14 @@ static int do_connect(char *svr)
 		goto error;
 	}
 
+	/* Set AMP preference */
+	if ((rfcmode == L2CAP_MODE_ERTM || rfcmode == L2CAP_MODE_STREAMING) &&
+		setsockopt(sk, SOL_L2CAP, L2CAP_AMP, &amp_pref, sizeof(amp_pref)) < 0) {
+		syslog(LOG_ERR, "Can't set L2CAP AMP preference: %s (%d)",
+							strerror(errno), errno);
+		goto error;
+	}
+
 	/* Get current options */
 	memset(&opts, 0, sizeof(opts));
 	optlen = sizeof(opts);
@@ -458,6 +469,14 @@ static void do_listen(void (*handler)(int sk))
 		/* Child */
 		close(sk);
 
+		/* Set AMP preference */
+		if ((rfcmode == L2CAP_MODE_ERTM || rfcmode == L2CAP_MODE_STREAMING) &&
+			setsockopt(nsk, SOL_L2CAP, L2CAP_AMP, &amp_pref, sizeof(amp_pref)) < 0) {
+			syslog(LOG_ERR, "Can't set L2CAP AMP preference: %s (%d)",
+				   strerror(errno), errno);
+			goto error;
+		}
+
 		/* Get current options */
 		memset(&opts, 0, sizeof(opts));
 		optlen = sizeof(opts);
@@ -1075,6 +1094,8 @@ static void usage(void)
 		"\t[-F fcs] use CRC16 check (default = 1)\n"
 		"\t[-Q num] Max Transmit value (default = %d)\n"
 		"\t[-Z size] Transmission Window size (default = %d)\n"
+		"\t[-J amp] declare amp preference\n"
+		"\t         (require_br_edr, prefer_amp, prefer_br_edr)\n"
 		"\t[-R] reliable mode\n"
 		"\t[-G] use connectionless channel (datagram)\n"
 		"\t[-U] use sock stream\n"
@@ -1093,7 +1114,7 @@ int main(int argc, char *argv[])
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:Q:Z:RUGAESMT")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:Q:Z:J:RUGAESMT")) != EOF) {
 		switch(opt) {
 		case 'r':
 			mode = RECV;
@@ -1217,6 +1238,17 @@ int main(int argc, char *argv[])
 			fcs = atoi(optarg);
 			break;
 
+		case 'J':
+			if (strcasecmp(optarg, "require_br_edr") == 0)
+				amp_pref = L2CAP_AMP_REQUIRE_BR_EDR;
+			else if (strcasecmp(optarg, "prefer_amp") == 0)
+				amp_pref = L2CAP_AMP_PREFER_AMP;
+			else if (strcasecmp(optarg, "prefer_br_edr") == 0)
+				amp_pref = L2CAP_AMP_PREFER_BR_EDR;
+			else
+				perror("Bad AMP preference");
+			break;
+
 		case 'R':
 			reliable = 1;
 			break;
-- 
1.7.2

--
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 2/4] Use defines for the default values of txwin_size and max_transmit.
From: Inga Stotland @ 2010-07-30 18:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280514626-22559-1-git-send-email-ingas@codeaurora.org>

---
 test/l2test.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index 0bb46f3..361f80c 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -76,10 +76,10 @@ static int omtu = 0;
 static int fcs = 0x01;
 
 /* Default Transmission Window */
-static int txwin_size = 63;
+static int txwin_size = L2CAP_DEFAULT_TX_WINDOW;
 
-/* Default Max Transmission */
-static int max_transmit = 3;
+/* Default Max Transmission (number of retries per packet) */
+static int max_transmit = L2CAP_DEFAULT_MAX_TX;
 
 /* Default data size */
 static long data_size = -1;
@@ -1073,8 +1073,8 @@ static void usage(void)
 		"\t[-D milliseconds] delay after sending num frames (default = 0)\n"
 		"\t[-X mode] select retransmission/flow-control mode\n"
 		"\t[-F fcs] use CRC16 check (default = 1)\n"
-		"\t[-Q num] Max Transmit value (default = 3)\n"
-		"\t[-Z size] Transmission Window size (default = 63)\n"
+		"\t[-Q num] Max Transmit value (default = %d)\n"
+		"\t[-Z size] Transmission Window size (default = %d)\n"
 		"\t[-R] reliable mode\n"
 		"\t[-G] use connectionless channel (datagram)\n"
 		"\t[-U] use sock stream\n"
@@ -1082,7 +1082,8 @@ static void usage(void)
 		"\t[-E] request encryption\n"
 		"\t[-S] secure connection\n"
 		"\t[-M] become master\n"
-		"\t[-T] enable timestamps\n");
+		"\t[-T] enable timestamps\n",
+		L2CAP_DEFAULT_MAX_TX, L2CAP_DEFAULT_TX_WINDOW);
 }
 
 int main(int argc, char *argv[])
-- 
1.7.2

--
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 1/4] Constants for L2CAP and AMP extensions
From: Inga Stotland @ 2010-07-30 18:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, johan.hedberg, marcel, Inga Stotland
In-Reply-To: <1280514626-22559-1-git-send-email-ingas@codeaurora.org>

---
 lib/l2cap.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/l2cap.h b/lib/l2cap.h
index e59cfdd..2f1084c 100644
--- a/lib/l2cap.h
+++ b/lib/l2cap.h
@@ -35,6 +35,8 @@ extern "C" {
 /* L2CAP defaults */
 #define L2CAP_DEFAULT_MTU	672
 #define L2CAP_DEFAULT_FLUSH_TO	0xFFFF
+#define L2CAP_DEFAULT_TX_WINDOW	63
+#define L2CAP_DEFAULT_MAX_TX	3
 
 /* L2CAP socket address */
 struct sockaddr_l2 {
@@ -44,6 +46,12 @@ struct sockaddr_l2 {
 	unsigned short	l2_cid;
 };
 
+/* L2CAP fixed channel CIDs */
+#define L2CAP_SIGNAL_CHAN_CID		0x0001
+#define L2CAP_CONNECTIONLESS_CID	0x0002
+#define L2CAP_AMP_MGR_CID		0x0003
+#define L2CAP_AMP_TEST_CID		0x003F
+
 /* L2CAP socket options */
 #define L2CAP_OPTIONS	0x01
 struct l2cap_options {
@@ -69,6 +77,12 @@ struct l2cap_conninfo {
 #define L2CAP_LM_TRUSTED	0x0008
 #define L2CAP_LM_RELIABLE	0x0010
 #define L2CAP_LM_SECURE		0x0020
+#define L2CAP_LM_FLUSHABLE	0x0040
+
+#define L2CAP_AMP	0x04
+#define L2CAP_AMP_REQUIRE_BR_EDR	0x01
+#define L2CAP_AMP_PREFER_AMP		0x02
+#define L2CAP_AMP_PREFER_BR_EDR	0x03
 
 /* L2CAP command codes */
 #define L2CAP_COMMAND_REJ	0x01
-- 
1.7.2

--
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ 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