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: [PATCHv5 01/14] shared/gatt: Add discover_secondary_services()
Date: Wed, 22 Oct 2014 15:37:03 +0200	[thread overview]
Message-ID: <7564815.XQcDrbhVg6@uw000953> (raw)
In-Reply-To: <1413454646-23076-2-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Thursday 16 of October 2014 12:17:13 Marcin Kraglak wrote:
> This pach implements searching Secondary Services in given range.

typo pach -> patch

> ---
>  src/shared/gatt-helpers.c | 56 +++++++++++++++++++++++++++++++++--------------
>  src/shared/gatt-helpers.h |  5 +++++
>  2 files changed, 45 insertions(+), 16 deletions(-)
> 
> diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
> index 55e6992..4dc787f 100644
> --- a/src/shared/gatt-helpers.c
> +++ b/src/shared/gatt-helpers.c
> @@ -175,6 +175,7 @@ struct discovery_op {
>  	uint16_t end_handle;
>  	int ref_count;
>  	bt_uuid_t uuid;
> +	uint16_t service_type;
>  	struct bt_gatt_result *result_head;
>  	struct bt_gatt_result *result_tail;
>  	bt_gatt_discovery_callback_t callback;
> @@ -487,7 +488,7 @@ static void read_by_grp_type_cb(uint8_t opcode, const void *pdu,
>  
>  		put_le16(last_end + 1, pdu);
>  		put_le16(op->end_handle, pdu + 2);
> -		put_le16(GATT_PRIM_SVC_UUID, pdu + 4);
> +		put_le16(op->service_type, pdu + 4);
>  
>  		if (bt_att_send(op->att, BT_ATT_OP_READ_BY_GRP_TYPE_REQ,
>  							pdu, sizeof(pdu),
> @@ -569,7 +570,7 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
>  
>  		put_le16(last_end + 1, pdu);
>  		put_le16(op->end_handle, pdu + 2);
> -		put_le16(GATT_PRIM_SVC_UUID, pdu + 4);
> +		put_le16(op->service_type, pdu + 4);
>  		put_uuid_le(&op->uuid, pdu + 6);
>  
>  		if (bt_att_send(op->att, BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,
> @@ -594,21 +595,12 @@ done:
>  		op->callback(success, att_ecode, final_result, op->user_data);
>  }
>  
> -bool bt_gatt_discover_all_primary_services(struct bt_att *att, bt_uuid_t *uuid,
> -					bt_gatt_discovery_callback_t callback,
> -					void *user_data,
> -					bt_gatt_destroy_func_t destroy)
> -{
> -	return bt_gatt_discover_primary_services(att, uuid, 0x0001, 0xffff,
> -							callback, user_data,
> -							destroy);
> -}
> -
> -bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
> +static bool discover_services(struct bt_att *att, bt_uuid_t *uuid,
>  					uint16_t start, uint16_t end,
>  					bt_gatt_discovery_callback_t callback,
>  					void *user_data,
> -					bt_gatt_destroy_func_t destroy)
> +					bt_gatt_destroy_func_t destroy,
> +					bool primary)
>  {
>  	struct discovery_op *op;
>  	bool result;
> @@ -625,6 +617,8 @@ bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
>  	op->callback = callback;
>  	op->user_data = user_data;
>  	op->destroy = destroy;
> +	/* set service uuid to primary or secondary */
> +	op->service_type = primary ? GATT_PRIM_SVC_UUID : GATT_SND_SVC_UUID;
>  
>  	/* If UUID is NULL, then discover all primary services */
>  	if (!uuid) {
> @@ -632,7 +626,7 @@ bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
>  
>  		put_le16(start, pdu);
>  		put_le16(end, pdu + 2);
> -		put_le16(GATT_PRIM_SVC_UUID, pdu + 4);
> +		put_le16(op->service_type, pdu + 4);
>  
>  		result = bt_att_send(att, BT_ATT_OP_READ_BY_GRP_TYPE_REQ,
>  							pdu, sizeof(pdu),
> @@ -652,7 +646,7 @@ bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
>  
>  		put_le16(start, pdu);
>  		put_le16(end, pdu + 2);
> -		put_le16(GATT_PRIM_SVC_UUID, pdu + 4);
> +		put_le16(op->service_type, pdu + 4);
>  		put_uuid_le(&op->uuid, pdu + 6);
>  
>  		result = bt_att_send(att, BT_ATT_OP_FIND_BY_TYPE_VAL_REQ,
> @@ -668,6 +662,36 @@ bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
>  	return result;
>  }
>  
> +bool bt_gatt_discover_all_primary_services(struct bt_att *att, bt_uuid_t *uuid,
> +					bt_gatt_discovery_callback_t callback,
> +					void *user_data,
> +					bt_gatt_destroy_func_t destroy)
> +{
> +	return bt_gatt_discover_primary_services(att, uuid, 0x0001, 0xffff,
> +							callback, user_data,
> +							destroy);
> +}
> +
> +bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
> +					uint16_t start, uint16_t end,
> +					bt_gatt_discovery_callback_t callback,
> +					void *user_data,
> +					bt_gatt_destroy_func_t destroy)
> +{
> +	return discover_services(att, uuid, start, end, callback, user_data,
> +								destroy, true);
> +}
> +
> +bool bt_gatt_discover_secondary_services(struct bt_att *att, bt_uuid_t *uuid,
> +					uint16_t start, uint16_t end,
> +					bt_gatt_discovery_callback_t callback,
> +					void *user_data,
> +					bt_gatt_destroy_func_t destroy)
> +{
> +	return discover_services(att, uuid, start, end, callback, user_data,
> +								destroy, false);
> +}
> +
>  bool bt_gatt_discover_included_services(struct bt_att *att,
>  					uint16_t start, uint16_t end,
>  					bt_uuid_t *uuid,
> diff --git a/src/shared/gatt-helpers.h b/src/shared/gatt-helpers.h
> index f6f4b62..8a25dea 100644
> --- a/src/shared/gatt-helpers.h
> +++ b/src/shared/gatt-helpers.h
> @@ -72,6 +72,11 @@ bool bt_gatt_discover_primary_services(struct bt_att *att, bt_uuid_t *uuid,
>  					bt_gatt_discovery_callback_t callback,
>  					void *user_data,
>  					bt_gatt_destroy_func_t destroy);
> +bool bt_gatt_discover_secondary_services(struct bt_att *att, bt_uuid_t *uuid,
> +					uint16_t start, uint16_t end,
> +					bt_gatt_discovery_callback_t callback,
> +					void *user_data,
> +					bt_gatt_destroy_func_t destroy);
>  bool bt_gatt_discover_included_services(struct bt_att *att,
>  					uint16_t start, uint16_t end,
>  					bt_uuid_t *uuid,

This is not related to this patch only but I have a feeling that those
functions names are getting to long. Maybe we should think of something
more compact?

-- 
Best regards, 
Szymon Janc

  reply	other threads:[~2014-10-22 13:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-16 10:17 [PATCHv5 00/14] Included service discovery Marcin Kraglak
2014-10-16 10:17 ` [PATCHv5 01/14] shared/gatt: Add discover_secondary_services() Marcin Kraglak
2014-10-22 13:37   ` Szymon Janc [this message]
2014-10-16 10:17 ` [PATCHv5 02/14] shared/gatt: Add initial implementation of discover_included_services Marcin Kraglak
2014-10-22 13:37   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 03/14] shared/gatt: Discover included services 128 bit UUIDS Marcin Kraglak
2014-10-22 18:43   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 04/14] shared/gatt: Add extra check in characteristic iterator Marcin Kraglak
2014-10-22 17:49   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 05/14] shared/gatt: Add included service iterator Marcin Kraglak
2014-10-22 18:43   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 06/14] shared/gatt: Remove not needed function parameter Marcin Kraglak
2014-10-16 10:17 ` [PATCHv5 07/14] shared/gatt: Distinguish Primary from Secondary services Marcin Kraglak
2014-10-16 10:17 ` [PATCHv5 08/14] tools/btgatt-client: Print type of service Marcin Kraglak
2014-10-22 18:00   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 09/14] shared/gatt: Discover secondary services Marcin Kraglak
2014-10-16 10:17 ` [PATCHv5 10/14] shared/gatt: Discover included services Marcin Kraglak
2014-10-22 18:20   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 11/14] shared/gatt: Add gatt-client include service iterator Marcin Kraglak
2014-10-22 18:29   ` Szymon Janc
2014-10-16 10:17 ` [PATCHv5 12/14] tools/btgatt-client: Print found include services Marcin Kraglak
2014-10-16 10:17 ` [PATCHv5 13/14] shared/gatt: Fix searching descriptors Marcin Kraglak
2014-10-16 10:17 ` [PATCHv5 14/14] shared/gatt: Add function bt_gatt_result_included_count() Marcin Kraglak
2014-10-22  6:25 ` [PATCHv5 00/14] Included service discovery Marcin Kraglak
2014-10-22 14:54   ` Luiz Augusto von Dentz
2014-10-22 15:35     ` Arman Uguray
2014-10-22 18:39       ` Szymon Janc
2014-10-23  7:55         ` Luiz Augusto von Dentz
2014-10-24 19:32           ` Arman Uguray

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=7564815.XQcDrbhVg6@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