Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Marcin Kraglak <marcin.kraglak@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv3 4/4] android: Pass found uuids to remote_device_properties_cb
Date: Mon, 04 Nov 2013 09:32:07 +0100	[thread overview]
Message-ID: <8190776.PXI2XqkyCW@uw000953> (raw)
In-Reply-To: <1383552410-2220-4-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

> diff --git a/android/adapter.c b/android/adapter.c
> index 0470522..9fe7d7d 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -1486,9 +1486,87 @@ static void browse_req_free(struct browse_req *req)
>  	g_free(req);
>  }
>  
> +static void fill_uuids(GSList *list, void *buf)
> +{
> +	for (; list; list = (GSList *)g_list_next(list)) {

This should use g_slist_next(). 

> +		memcpy(buf, list->data, sizeof(uint128_t));
> +		buf += sizeof(uint128_t);
> +	}
> +}
> +
> +static void remote_uuids_callback(struct browse_req *req)
> +{
> +	struct hal_ev_remote_device_props *ev;
> +	int len;
> +
> +	len = sizeof(*ev) + sizeof(struct hal_property) + (sizeof(uint128_t) *
> +						g_slist_length(req->uuids));
> +	ev = g_malloc(len);
> +
> +	ev->status = HAL_STATUS_SUCCESS;
> +	bdaddr2android(req->bdaddr, &ev->bdaddr);
> +	ev->num_props = 1;
> +	ev->props[0].type = HAL_PROP_DEVICE_UUIDS;
> +	ev->props[0].len = sizeof(uint128_t) * g_slist_length(req->uuids);
> +	fill_uuids(req->uuids, ev->props[0].val);
> +
> +	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
> +				HAL_EV_REMOTE_DEVICE_PROPS, len, ev, -1);
> +
> +	g_free(ev);
> +}
> +
> +static int uuid_128_cmp(gconstpointer a, gconstpointer b)
> +{
> +	return memcmp(a, b, sizeof(uint128_t));
> +}
> +
>  static void update_records(struct browse_req *req, sdp_list_t *recs)
>  {
> -	/* TODO cache found uuids */
> +	for (; recs; recs = recs->next) {
> +		sdp_record_t *rec = (sdp_record_t *) recs->data;
> +		sdp_list_t *svcclass = NULL;
> +		uuid_t uuid128;
> +		uuid_t *temp;
> +		uint8_t *u;
> +
> +		if (!rec)
> +			break;
> +
> +		if (sdp_get_service_classes(rec, &svcclass) < 0)
> +			continue;
> +
> +		if (svcclass == NULL)
> +			continue;
> +
> +		temp = svcclass->data;
> +
> +		switch (temp->type) {
> +		case SDP_UUID16:
> +			sdp_uuid16_to_uuid128(&uuid128, temp);
> +			break;
> +		case SDP_UUID32:
> +			sdp_uuid32_to_uuid128(&uuid128, temp);
> +			break;
> +		case SDP_UUID128:
> +			memcpy(&uuid128, temp, sizeof(uuid_t));
> +			break;
> +		default:
> +			continue;
> +		}
> +
> +		u = g_malloc(16);/* size of 128 bit uuid */
> +		memcpy(u, &uuid128.value.uuid128,
> +				sizeof(uuid128.value.uuid128));
> +
> +		/* Check if uuid is already added */
> +		if (g_slist_find_custom(req->uuids, u, uuid_128_cmp))
> +			g_free(u);
> +		else
> +			req->uuids = g_slist_append(req->uuids, u);
> +
> +		sdp_list_free(svcclass, free);
> +	}
>  }
>  
>  static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
> @@ -1518,6 +1596,7 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
>  	}
>  
>  done:
> +	remote_uuids_callback(req);
>  	sdp_req_list = g_list_remove(sdp_req_list, req->bdaddr);
>  	browse_req_free(req);
>  }
> 

-- 
BR
Szymon Janc


      reply	other threads:[~2013-11-04  8:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04  8:06 [PATCHv3 1/4] android/hal: Send get_remote_services cmd Marcin Kraglak
2013-11-04  8:06 ` [PATCHv3 2/4] android: Add stub of get_remote_services command Marcin Kraglak
2013-11-04  8:24   ` Johan Hedberg
2013-11-04  8:06 ` [PATCHv3 3/4] android: Initial implementation of get_remote_services Marcin Kraglak
2013-11-04  8:06 ` [PATCHv3 4/4] android: Pass found uuids to remote_device_properties_cb Marcin Kraglak
2013-11-04  8:32   ` Szymon Janc [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8190776.PXI2XqkyCW@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcin.kraglak@tieto.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox