linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Mariusz Skamra <mariusz.skamra@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 13/28] android/hog: Replace definitions of characteristic uuids with bt_uuids
Date: Thu, 02 Apr 2015 17:26:25 +0200	[thread overview]
Message-ID: <5759776.KHdNPGdBs4@leonov> (raw)
In-Reply-To: <1427906444-11769-14-git-send-email-mariusz.skamra@tieto.com>

Hi Mariusz,

On Wednesday 01 of April 2015 18:40:29 Mariusz Skamra wrote:
> Instead of using simply define and then convert the uuid values to
> bt_uuid everytime the char_discovered_cb is called, it's better to
> define these bt_uuids directly.
> ---
>  android/hog.c | 40 ++++++++++++++++++----------------------
>  1 file changed, 18 insertions(+), 22 deletions(-)
> 
> diff --git a/android/hog.c b/android/hog.c
> index 08196d4..e1ccaf3 100644
> --- a/android/hog.c
> +++ b/android/hog.c
> @@ -61,12 +61,6 @@
>  #include "android/bas.h"
>  #include "android/hog.h"
> 
> -#define HOG_INFO_UUID		0x2A4A
> -#define HOG_REPORT_MAP_UUID	0x2A4B
> -#define HOG_REPORT_UUID		0x2A4D
> -#define HOG_PROTO_MODE_UUID	0x2A4E
> -#define HOG_CONTROL_POINT_UUID	0x2A4C
> -
>  #define HOG_REPORT_TYPE_INPUT	1
>  #define HOG_REPORT_TYPE_OUTPUT	2
>  #define HOG_REPORT_TYPE_FEATURE	3
> @@ -77,6 +71,17 @@
>  #define HOG_REPORT_MAP_MAX_SIZE        512
>  #define HID_INFO_SIZE			4
> 
> +static const bt_uuid_t info_uuid = { .type = BT_UUID16,
> +					.value.u16 = 0x2A4A };
> +static const bt_uuid_t report_map_uuid = { .type = BT_UUID16,
> +					.value.u16 = 0x2A4B };
> +static const bt_uuid_t control_point_uuid = { .type = BT_UUID16,
> +					.value.u16 = 0x2A4C };
> +static const bt_uuid_t report_uuid = { .type = BT_UUID16,
> +					.value.u16 = 0x2A4D };
> +static const bt_uuid_t protocol_mode_uuid = { .type = BT_UUID16,
> +					.value.u16 = 0x2A4E };

We usually keep those as defines and create by_uuid where needed. Since this 
is used only in discovery (ie not performance critical) I'd just skip this 
patch for now.

> +
>  struct bt_hog {
>  	int			ref_count;
>  	uint16_t		service_handle;
> @@ -300,7 +305,6 @@ static void external_report_reference_cb(bool success,
> uint8_t status, void *user_data)
>  {
>  	struct bt_hog *hog = user_data;
> -	uint16_t uuid16;
>  	bt_uuid_t uuid;
>  	struct queue *chrs;
> 
> @@ -315,12 +319,12 @@ static void external_report_reference_cb(bool success,
> uint8_t status, return;
>  	}
> 
> -	uuid16 = get_le16(value);
> -	DBG("External report reference read, external report characteristic "
> -						"UUID: 0x%04x", uuid16);
> +	DBG("External report characteristic UUID: 0x%04x", get_le16(value));
> +
> +	bt_uuid16_create(&uuid, get_le16(value));
> 
>  	/* Do not discover if is not a Report */
> -	if (uuid16 != HOG_REPORT_UUID)
> +	if (bt_uuid_cmp(&uuid, &report_uuid))
>  		return;
> 
>  	chrs = queue_new();
> @@ -329,7 +333,6 @@ static void external_report_reference_cb(bool success,
> uint8_t status, return;
>  	}
> 
> -	bt_uuid16_create(&uuid, uuid16);
>  	gatt_db_read_by_type(hog->db, 0x0001, 0xffff, uuid, chrs);
> 
>  	if (queue_isempty(chrs))
> @@ -823,18 +826,11 @@ static void char_discovered_cb(struct
> gatt_db_attribute *attrib, void *user_data)
>  {
>  	struct bt_hog *hog = user_data;
> -	bt_uuid_t report_uuid, report_map_uuid, proto_mode_uuid, ctrlpt_uuid;
> -	bt_uuid_t info_uuid, uuid;
> +	bt_uuid_t uuid;
>  	struct report *report;
>  	uint16_t value_handle;
>  	uint8_t properties;
> 
> -	bt_uuid16_create(&report_uuid, HOG_REPORT_UUID);
> -	bt_uuid16_create(&report_map_uuid, HOG_REPORT_MAP_UUID);
> -	bt_uuid16_create(&info_uuid, HOG_INFO_UUID);
> -	bt_uuid16_create(&proto_mode_uuid, HOG_PROTO_MODE_UUID);
> -	bt_uuid16_create(&ctrlpt_uuid, HOG_CONTROL_POINT_UUID);
> -
>  	gatt_db_attribute_get_char_data(attrib, NULL, &value_handle,
>  							&properties, &uuid);
> 
> @@ -849,11 +845,11 @@ static void char_discovered_cb(struct
> gatt_db_attribute *attrib, } else if (!bt_uuid_cmp(&uuid, &info_uuid)) {
>  		bt_gatt_client_read_value(hog->client, value_handle,
>  						info_read_cb, hog, NULL);
> -	} else if (!bt_uuid_cmp(&uuid, &proto_mode_uuid)) {
> +	} else if (!bt_uuid_cmp(&uuid, &protocol_mode_uuid)) {
>  		hog->proto_mode_handle = value_handle;
>  		bt_gatt_client_read_value(hog->client, value_handle,
>  						proto_mode_read_cb, hog, NULL);
> -	} else if (!bt_uuid_cmp(&uuid, &ctrlpt_uuid)) {
> +	} else if (!bt_uuid_cmp(&uuid, &control_point_uuid)) {
>  		hog->ctrlpt_handle = value_handle;
>  	}
>  }

-- 
BR
Szymon Janc

  reply	other threads:[~2015-04-02 15:26 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 16:40 [PATCH 00/28] android/hog Introduce bt_gatt_client Mariusz Skamra
2015-04-01 16:40 ` [PATCH 01/28] android/hidhost: Create bt_gatt_client Mariusz Skamra
2015-04-02 14:16   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 02/28] android/hog: Introduce bt_gatt_client Mariusz Skamra
2015-04-02 14:17   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 03/28] shared/gatt-client: Expose gatt_db Mariusz Skamra
2015-04-02 14:20   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 04/28] android/hog: Remove tracking gatt operations Mariusz Skamra
2015-04-01 16:40 ` [PATCH 05/28] android/hog: Use bt_gatt_client to read characteristic value Mariusz Skamra
2015-04-01 16:40 ` [PATCH 06/28] android/hog: Use bt_gatt_client to register for notifications Mariusz Skamra
2015-04-01 16:40 ` [PATCH 07/28] android/hog: Use bt_gatt_client to write without response Mariusz Skamra
2015-04-01 16:40 ` [PATCH 08/28] android/hog: Replace gatt_write_char with bt_gatt_client_write_value Mariusz Skamra
2015-04-01 16:40 ` [PATCH 09/28] android/hog: Use gatt_db to search for services and characteristics in db Mariusz Skamra
2015-04-02 15:22   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 10/28] android/hog: Add helper to create uhid device Mariusz Skamra
2015-04-01 16:40 ` [PATCH 11/28] lib/uuid: Add define for HoG UUID Mariusz Skamra
2015-04-01 16:40 ` [PATCH 12/28] android/hog: Replace list of reports with a queue of reports Mariusz Skamra
2015-04-01 16:40 ` [PATCH 13/28] android/hog: Replace definitions of characteristic uuids with bt_uuids Mariusz Skamra
2015-04-02 15:26   ` Szymon Janc [this message]
2015-04-01 16:40 ` [PATCH 14/28] android/hog: Replace GSList of hog instances with queue of instances Mariusz Skamra
2015-04-02 15:29   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 15/28] android/dis: Remove tracking pending gatt operations Mariusz Skamra
2015-04-01 16:40 ` [PATCH 16/28] android/dis: Introduce bt_gatt_client Mariusz Skamra
2015-04-01 16:40 ` [PATCH 17/28] android/scpp: Remove tracking pending gatt operations Mariusz Skamra
2015-04-01 16:40 ` [PATCH 18/28] android/scpp: Introduce bt_gatt_client Mariusz Skamra
2015-04-02 15:34   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 19/28] android/scpp: Merge refresh_discovered_cb with iwin_discovered_cb Mariusz Skamra
2015-04-01 16:40 ` [PATCH 20/28] android/bas: Remove tracking pending gatt operations Mariusz Skamra
2015-04-01 16:40 ` [PATCH 21/28] android/bas: Start using bt_gatt_client Mariusz Skamra
2015-04-02 15:37   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 22/28] android/hog: Strip btio dependencies Mariusz Skamra
2015-04-02 15:39   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 23/28] android/hog: Enable Input Report notifications only if uhid is created Mariusz Skamra
2015-04-01 16:40 ` [PATCH 24/28] android/bas: Enable Battery Level notifications after reconnection Mariusz Skamra
2015-04-01 16:40 ` [PATCH 25/28] android/hog: Add MIN definition Mariusz Skamra
2015-04-02 15:41   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 26/28] android/hog: Remove attrib/ Mariusz Skamra
2015-04-02 15:44   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 27/28] android/hog: Remove glib dependencies Mariusz Skamra
2015-04-02 15:45   ` Szymon Janc
2015-04-01 16:40 ` [PATCH 28/28] android/hog: Remove redundant code Mariusz Skamra

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=5759776.KHdNPGdBs4@leonov \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mariusz.skamra@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;
as well as URLs for NNTP newsgroup(s).