All of lore.kernel.org
 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 22/28] android/hog: Strip btio dependencies
Date: Thu, 02 Apr 2015 17:39:22 +0200	[thread overview]
Message-ID: <3672682.rUp6PO2B6O@leonov> (raw)
In-Reply-To: <1427906444-11769-23-git-send-email-mariusz.skamra@tieto.com>

Hi Mariusz,

On Wednesday 01 of April 2015 18:40:38 Mariusz Skamra wrote:
> bt_io_get from btio library is used only to get address of adapter
> and connected hid device. We can just simply pass this addresses
> using bt_hog_new argument list. It's temporary solution, just to
> be able to move the code to shared.

shared code is required to be LGPL so I'd just skip this patch for now.

> ---
>  android/hidhost.c |  3 ++-
>  android/hog.c     | 36 +++++++++++++++++-------------------
>  android/hog.h     | 10 ++++++----
>  unit/test-hog.c   |  7 ++++++-
>  4 files changed, 31 insertions(+), 25 deletions(-)
> 
> diff --git a/android/hidhost.c b/android/hidhost.c
> index 98eceee..3d4ee85 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -862,7 +862,8 @@ static void hog_conn_cb(const bdaddr_t *addr, int err,
> void *attrib) if (!dev->hog) {
>  		/* TODO: Get device details */
>  		dev->hog = bt_hog_new_default("bluez-input-device", dev->vendor,
> -					dev->product, dev->version, 0);
> +					dev->product, dev->version, addr,
> +					&adapter_addr, 0);
>  		if (!dev->hog) {
>  			error("HoG: unable to create session");
>  			goto fail;
> diff --git a/android/hog.c b/android/hog.c
> index 4565e86..b5b772c 100644
> --- a/android/hog.c
> +++ b/android/hog.c
> @@ -54,8 +54,6 @@
>  #include "attrib/gattrib.h"
>  #include "attrib/gatt.h"
> 
> -#include "btio/btio.h"
> -
>  #include "android/scpp.h"
>  #include "android/dis.h"
>  #include "android/bas.h"
> @@ -82,9 +80,12 @@ static const bt_uuid_t report_uuid = { .type = BT_UUID16,
> static const bt_uuid_t protocol_mode_uuid = { .type = BT_UUID16,
>  					.value.u16 = 0x2A4E };
> 
> +static bdaddr_t	adapter_addr;
> +
>  struct bt_hog {
>  	int			ref_count;
>  	uint16_t		service_handle;
> +	bdaddr_t		device_addr;
>  	char			*name;
>  	uint16_t		vendor;
>  	uint16_t		product;
> @@ -694,22 +695,13 @@ static bool uhid_create(struct bt_hog *hog, const
> uint8_t *value, uint16_t vlen) {
>  	struct uhid_event ev;
>  	int err;
> -	GError *gerr = NULL;
> 
>  	/* create uHID device */
>  	memset(&ev, 0, sizeof(ev));
>  	ev.type = UHID_CREATE;
> 
> -	bt_io_get(g_attrib_get_channel(hog->attrib), &gerr,
> -			BT_IO_OPT_SOURCE, ev.u.create.phys,
> -			BT_IO_OPT_DEST, ev.u.create.uniq,
> -			BT_IO_OPT_INVALID);
> -	if (gerr) {
> -		error("Failed to connection details: %s", gerr->message);
> -		g_error_free(gerr);
> -		return false;
> -	}
> -
> +	ba2str(&adapter_addr, (char *) ev.u.create.phys);
> +	ba2str(&hog->device_addr, (char *) ev.u.create.uniq);
>  	strcpy((char *) ev.u.create.name, hog->name);
>  	ev.u.create.vendor = hog->vendor;
>  	ev.u.create.product = hog->product;
> @@ -881,15 +873,18 @@ static void hog_free(void *data)
>  }
> 
>  struct bt_hog *bt_hog_new_default(const char *name, uint16_t vendor,
> -					uint16_t product, uint16_t version,
> -					uint16_t service_handle)
> +				uint16_t product, uint16_t version,
> +				const bdaddr_t *addr, const bdaddr_t *adapter,
> +				uint16_t service_handle)
>  {
> -	return bt_hog_new(-1, name, vendor, product, version, service_handle);
> +	return bt_hog_new(-1, name, vendor, product, version, addr, adapter,
> +								service_handle);
>  }
> 
>  struct bt_hog *bt_hog_new(int fd, const char *name, uint16_t vendor,
> -					uint16_t product, uint16_t version,
> -					uint16_t service_handle)
> +				uint16_t product, uint16_t version,
> +				const bdaddr_t *addr, const bdaddr_t *adapter,
> +				uint16_t service_handle)
>  {
>  	struct bt_hog *hog;
> 
> @@ -917,6 +912,8 @@ struct bt_hog *bt_hog_new(int fd, const char *name,
> uint16_t vendor, hog->vendor = vendor;
>  	hog->product = product;
>  	hog->version = version;
> +	bacpy(&hog->device_addr, addr);
> +	bacpy(&adapter_addr, adapter);
> 
>  	if (service_handle)
>  		hog->service_handle = service_handle;
> @@ -1017,7 +1014,8 @@ static void hog_attach_hog(struct bt_hog *hog,
> uint16_t service_handle) }
> 
>  	instance = bt_hog_new(hog->uhid_fd, hog->name, hog->vendor,
> -				hog->product, hog->version, service_handle);
> +				hog->product, hog->version, &hog->device_addr,
> +				&adapter_addr, service_handle);
>  	if (!instance)
>  		return;
> 
> diff --git a/android/hog.h b/android/hog.h
> index cfe6873..8fe8422 100644
> --- a/android/hog.h
> +++ b/android/hog.h
> @@ -24,12 +24,14 @@
>  struct bt_hog;
> 
>  struct bt_hog *bt_hog_new_default(const char *name, uint16_t vendor,
> -					uint16_t product, uint16_t version,
> -					uint16_t service_handle);
> +				uint16_t product, uint16_t version,
> +				const bdaddr_t *addr, const bdaddr_t *adapter,
> +				uint16_t service_handle);
> 
>  struct bt_hog *bt_hog_new(int fd, const char *name, uint16_t vendor,
> -					uint16_t product, uint16_t version,
> -					uint16_t service_handle);
> +				uint16_t product, uint16_t version,
> +				const bdaddr_t *addr, const bdaddr_t *adapter,
> +				uint16_t service_handle);
> 
>  struct bt_hog *bt_hog_ref(struct bt_hog *hog);
>  void bt_hog_unref(struct bt_hog *hog);
> diff --git a/unit/test-hog.c b/unit/test-hog.c
> index 5794c5e..16805e7 100644
> --- a/unit/test-hog.c
> +++ b/unit/test-hog.c
> @@ -32,6 +32,8 @@
> 
>  #include <glib.h>
> 
> +#include "lib/bluetooth.h"
> +
>  #include "src/shared/util.h"
>  #include "src/shared/tester.h"
> 
> @@ -179,6 +181,8 @@ static struct context *create_context(gconstpointer
> data) uint16_t vendor = 0x0002;
>  	uint16_t product = 0x0001;
>  	uint16_t version = 0x0001;
> +	const bdaddr_t *device_addr = NULL;
> +	const bdaddr_t *adapter_addr = NULL;
> 
>  	context = g_new0(struct context, 1);
>  	err = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv);
> @@ -196,7 +200,8 @@ static struct context *create_context(gconstpointer
> data) fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
>  	g_assert(fd > 0);
> 
> -	context->hog = bt_hog_new(fd, name, vendor, product, version, 0);
> +	context->hog = bt_hog_new(fd, name, vendor, product, version,
> +						device_addr, adapter_addr, 0);
>  	g_assert(context->hog);
> 
>  	channel = g_io_channel_unix_new(sv[1]);

-- 
BR
Szymon Janc

  reply	other threads:[~2015-04-02 15:39 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
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 [this message]
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=3672682.rUp6PO2B6O@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.