Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data
@ 2010-11-19 14:50 Anderson Lizardo
  2010-11-19 14:50 ` [PATCH 2/2] Avoid reallocations of services UUID array Anderson Lizardo
  2010-11-19 15:29 ` [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data Johan Hedberg
  0 siblings, 2 replies; 4+ messages in thread
From: Anderson Lizardo @ 2010-11-19 14:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

For LE devices, service UUIDs present in advertising data are merged
into a single list. This change makes the same thing for BR/EDR devices.
---
 src/adapter.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 8136229..c650a63 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3004,12 +3004,6 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 	} else
 		alias = g_strdup(dev->alias);
 
-	if (dev->services) {
-		g_slist_foreach(dev->services, (GFunc) g_free, NULL);
-		g_slist_free(dev->services);
-		dev->services = NULL;
-	}
-
 	emit_device_found(adapter->path, paddr,
 			"Address", DBUS_TYPE_STRING, &paddr,
 			"Class", DBUS_TYPE_UINT32, &dev->class,
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Avoid reallocations of services UUID array
  2010-11-19 14:50 [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data Anderson Lizardo
@ 2010-11-19 14:50 ` Anderson Lizardo
  2010-11-19 14:53   ` Anderson Lizardo
  2010-11-19 15:29 ` [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data Johan Hedberg
  1 sibling, 1 reply; 4+ messages in thread
From: Anderson Lizardo @ 2010-11-19 14:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

The array of service UUIDs used by the DeviceFound signal contains the
same information from the GSList of services. Instead of reallocating
this array on each signal, store it on the remote_dev_info structure and
only reallocate it if there are new UUIDs.
---
 src/adapter.c |   17 ++++++++---------
 src/adapter.h |    3 ++-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index c650a63..1e51d11 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2964,7 +2964,6 @@ 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;
 	size_t uuid_count;
 
 	ba2str(&dev->bdaddr, peer_addr);
@@ -2977,9 +2976,11 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 	/* Extract UUIDs from extended inquiry response if any */
 	dev->services = get_eir_uuids(eir_data, eir_length, dev->services);
 	uuid_count = g_slist_length(dev->services);
-
-	if (dev->services)
-		uuids = strlist2array(dev->services);
+	if (dev->services && dev->uuid_count != uuid_count) {
+		g_strfreev(dev->uuids);
+		dev->uuids = strlist2array(dev->services);
+		dev->uuid_count = uuid_count;
+	}
 
 	if (dev->le) {
 		emit_device_found(adapter->path, paddr,
@@ -2987,9 +2988,8 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 				"RSSI", DBUS_TYPE_INT16, &rssi,
 				"Name", DBUS_TYPE_STRING, &dev->name,
 				"Paired", DBUS_TYPE_BOOLEAN, &paired,
-				"UUIDs", DBUS_TYPE_ARRAY, &uuids, uuid_count,
-				NULL);
-		g_strfreev(uuids);
+				"UUIDs", DBUS_TYPE_ARRAY, &dev->uuids,
+				dev->uuid_count, NULL);
 		return;
 	}
 
@@ -3013,11 +3013,10 @@ 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,
+			"UUIDs", DBUS_TYPE_ARRAY, &dev->uuids, dev->uuid_count,
 			NULL);
 
 	g_free(alias);
-	g_strfreev(uuids);
 }
 
 static struct remote_dev_info *get_found_dev(struct btd_adapter *adapter,
diff --git a/src/adapter.h b/src/adapter.h
index 4af69b3..955bb9a 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -70,7 +70,8 @@ struct remote_dev_info {
 	dbus_bool_t legacy;
 	name_status_t name_status;
 	gboolean le;
-	/* LE adv data */
+	char **uuids;
+	size_t uuid_count;
 	GSList *services;
 	uint8_t evt_type;
 	uint8_t bdaddr_type;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Avoid reallocations of services UUID array
  2010-11-19 14:50 ` [PATCH 2/2] Avoid reallocations of services UUID array Anderson Lizardo
@ 2010-11-19 14:53   ` Anderson Lizardo
  0 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2010-11-19 14:53 UTC (permalink / raw)
  To: linux-bluetooth

On Fri, Nov 19, 2010 at 10:50 AM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> The array of service UUIDs used by the DeviceFound signal contains the
> same information from the GSList of services. Instead of reallocating
> this array on each signal, store it on the remote_dev_info structure and
> only reallocate it if there are new UUIDs.

Oops, just noticed I forgot to free the dev->uuids array. Will send a
fixed patch ASAP.

Regards,
-- 
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data
  2010-11-19 14:50 [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data Anderson Lizardo
  2010-11-19 14:50 ` [PATCH 2/2] Avoid reallocations of services UUID array Anderson Lizardo
@ 2010-11-19 15:29 ` Johan Hedberg
  1 sibling, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2010-11-19 15:29 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Anderson,

On Fri, Nov 19, 2010, Anderson Lizardo wrote:
> For LE devices, service UUIDs present in advertising data are merged
> into a single list. This change makes the same thing for BR/EDR devices.
> ---
>  src/adapter.c |    6 ------
>  1 files changed, 0 insertions(+), 6 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-19 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19 14:50 [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data Anderson Lizardo
2010-11-19 14:50 ` [PATCH 2/2] Avoid reallocations of services UUID array Anderson Lizardo
2010-11-19 14:53   ` Anderson Lizardo
2010-11-19 15:29 ` [PATCH 1/2] Merge service UUIDs from different BR/EDR EIR data Johan Hedberg

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