diff options
| -rw-r--r-- | hcid/adapter.c | 24 | ||||
| -rw-r--r-- | hcid/device.c | 7 | ||||
| -rw-r--r-- | hcid/device.h | 4 | 
3 files changed, 30 insertions, 5 deletions
| diff --git a/hcid/adapter.c b/hcid/adapter.c index 31eb8309..eca12fbb 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -3178,6 +3178,7 @@ static DBusHandlerResult list_devices(DBusConnection *conn,  static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err)  { +	sdp_list_t *uuids, *seq, *next, *svcclass;  	struct adapter *adapter = user_data;  	DBusMessage *reply;  	const char *path; @@ -3188,7 +3189,28 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err)  		goto failed;  	} -	path = device_create(adapter, adapter->create->address, recs); +	uuids = NULL; +	for (seq = recs; seq; seq = next) { +		sdp_record_t *rec = (sdp_record_t *) seq->data; + +		if (!rec) +			break; + +		svcclass = NULL; +		if (sdp_get_service_classes(rec, &svcclass) == 0) { +			/* Extract the first element and skip the remainning */ +			uuid_t *u = malloc(sizeof(uuid_t)); +			memcpy(u, svcclass->data, sizeof(uuid_t)); +			uuids = sdp_list_append(uuids, u); +			sdp_list_free(svcclass, free); +		} + +		next = seq->next; +	} + +	sdp_list_free(recs, (sdp_free_func_t) sdp_record_free); + +	path = device_create(adapter, adapter->create->address, uuids);  	if (!path)  		goto failed; diff --git a/hcid/device.c b/hcid/device.c index 51e6bebc..713fcff0 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -38,6 +38,8 @@  #include <bluetooth/bluetooth.h>  #include <bluetooth/hci.h>  #include <bluetooth/hci_lib.h> +#include <bluetooth/sdp.h> +#include <bluetooth/sdp_lib.h>  #include <glib.h> @@ -746,6 +748,7 @@ void device_foreach(GFunc func, gpointer user_data)  static void device_free(struct device *device)  { +	sdp_list_free(device->uuids, (sdp_free_func_t) free);  	g_free(device->path);  	g_free(device);  } @@ -791,7 +794,7 @@ static DBusSignalVTable device_signals[] = {  };  const char *device_create(struct adapter *adapter, -		const char *address, sdp_list_t *recs) +		const char *address, sdp_list_t *uuids)  {  	struct device *device; @@ -817,7 +820,7 @@ const char *device_create(struct adapter *adapter,  	device_list = g_slist_append(device_list, device);  	device->adapter = adapter; -	device->records = recs; +	device->uuids = uuids;  	return device->path;  } diff --git a/hcid/device.h b/hcid/device.h index 0eaa92c7..4bdf9b0e 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -25,12 +25,12 @@  struct device {  	char		*path;  	struct adapter	*adapter; -	sdp_list_t	*records; +	sdp_list_t	*uuids;  };  gboolean device_init(DBusConnection *conn);  void device_cleanup(void);  void device_foreach(GFunc func, gpointer user_data);  const char *device_create(struct adapter *adapter, -		const char *address, sdp_list_t *recs); +		const char *address, sdp_list_t *uuids);  void device_remove(const char *path); | 
