From: Johan Hedberg <johan.hedberg@gmail.com>
To: Claudio Takahasi <claudio.takahasi@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org,
Sheldon Demario <sheldon.demario@openbossa.org>
Subject: Re: [PATCH 2/5] Change CreatePairedDevice to support LE devices
Date: Thu, 16 Dec 2010 11:24:32 +0200 [thread overview]
Message-ID: <20101216092432.GB4322@jh-x301> (raw)
In-Reply-To: <1292442852-26457-2-git-send-email-claudio.takahasi@openbossa.org>
Hi,
On Wed, Dec 15, 2010, Claudio Takahasi wrote:
> CreatePairedDevice implements now the same behaviour of CreateDevice,
> triggering Discover All Primary Services when needed. SMP negotiation
> starts when the link is established. LE capable kernel is required to
> test this method properly.
>
> Limitation: For dual mode devices, Discover All Primary Services is not
> being executed after SDP search if GATT record is found.
> ---
> src/adapter.c | 46 ++++++++++++++++++++++++---
> src/device.c | 89 +++++++++++++++++++++++++++-------------------------
> src/device.h | 7 +++-
> src/glib-helper.c | 5 ++-
> src/glib-helper.h | 3 ++
> 5 files changed, 98 insertions(+), 52 deletions(-)
Couple of issue here:
> @@ -1642,6 +1646,8 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
> struct btd_device *device;
> const gchar *address, *agent_path, *capability, *sender;
> uint8_t cap;
> + device_type_t type;
> + int err;
>
> if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
> DBUS_TYPE_OBJECT_PATH, &agent_path,
> @@ -1666,12 +1672,40 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
> if (cap == IO_CAPABILITY_INVALID)
> return btd_error_invalid_args(msg);
>
> - device = adapter_get_device(conn, adapter, address);
> - if (!device)
> - return btd_error_failed(msg,
> - "Unable to create a new device object");
> + device = adapter_find_device(adapter, address);
> + if (!device) {
> + struct remote_dev_info *dev, match;
> +
> + memset(&match, 0, sizeof(struct remote_dev_info));
> + str2ba(address, &match.bdaddr);
> + match.name_status = NAME_ANY;
> +
> + dev = adapter_search_found_devices(adapter, &match);
> + if (dev && dev->flags)
> + type = flags2type(dev->flags);
> + else
> + type = DEVICE_TYPE_BREDR;
> +
> + if (type == DEVICE_TYPE_LE &&
> + !event_is_connectable(dev->evt_type))
> + return btd_error_failed(msg,
> + "Device is not connectable");
> +
> + device = adapter_create_device(conn, adapter, address, type);
> + if (!device)
> + return NULL;
> + } else
> + type = device_get_type(device);
> +
> + if (type != DEVICE_TYPE_LE)
> + return device_create_bonding(device, conn, msg,
> + agent_path, cap);
>
> - return device_create_bonding(device, conn, msg, agent_path, cap);
> + err = device_browse_primary(device, conn, msg, BT_IO_SEC_HIGH);
> + if (err < 0)
> + return btd_error_failed(msg, strerror(-err));
> +
> + return NULL;
> }
I don't really like the way this makes the create_paired_device function
quite long. Could you maybe refactor the if (!device) branch into a
separate function?
> diff --git a/src/device.h b/src/device.h
> index 784e931..cafa529 100644
> --- a/src/device.h
> +++ b/src/device.h
> @@ -24,6 +24,8 @@
>
> #define DEVICE_INTERFACE "org.bluez.Device"
>
> +#include "btio.h"
> +
Includes should be the first thing after the copyright/license comments
in the file. However, to keep a clear visibility of potential circular
dependencies Marcel has requested this kind of inclusion of an internal
header file from within an internal header file to be avoided. Instead
make sure you include btio.h from early enough in the respective .c
file. You could also reconsider if you really need BtIOSecLevel here.
Maybe a "gboolean secure" flag would be enough?
> --- a/src/glib-helper.h
> +++ b/src/glib-helper.h
> @@ -21,6 +21,8 @@
> *
> */
>
> +#include "btio.h"
> +
Same here.
I'm feeling a little bit ambivalent about your additions to
glib-helper.c. It never had a clearly defined scope and I had been
hoping to get rid of it completely. However now it seems you guys are
constantly adding new stuff there. Is it really so that you can't find a
more specific location for these functions? Could you describe in one or
two sentences the purpose and scope that you think the glib-helper.c
functions have?
Johan
next prev parent reply other threads:[~2010-12-16 9:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 19:54 [PATCH 1/5] Implement cancel primary discovery session Claudio Takahasi
2010-12-15 19:54 ` [PATCH 2/5] Change CreatePairedDevice to support LE devices Claudio Takahasi
2010-12-16 9:24 ` Johan Hedberg [this message]
2010-12-16 17:16 ` Claudio Takahasi
2010-12-16 21:01 ` Johan Hedberg
2010-12-20 22:43 ` [PATCH v2 " Claudio Takahasi
2010-12-20 22:59 ` Johan Hedberg
2010-12-20 23:57 ` [PATCH v3 " Sheldon Demario
2010-12-21 8:42 ` Johan Hedberg
2010-12-21 14:34 ` [PATCH v4 " Sheldon Demario
2010-12-23 21:29 ` [PATCH v5 " Sheldon Demario
2010-12-23 22:37 ` Johan Hedberg
2010-12-16 22:42 ` [PATCH " Brian Gix
2010-12-20 14:03 ` Claudio Takahasi
2010-12-15 19:54 ` [PATCH 3/5] Return an error if adapter_create_device fails Claudio Takahasi
2010-12-20 22:45 ` Claudio Takahasi
2010-12-15 19:54 ` [PATCH 4/5] Fix missing reply when create device is cancelled Claudio Takahasi
2010-12-20 22:47 ` [PATCH v2 " Claudio Takahasi
2010-12-20 23:00 ` Johan Hedberg
2010-12-15 19:54 ` [PATCH 5/5] Remove unneeded variable Claudio Takahasi
2010-12-20 22:49 ` [PATCH v2 " Claudio Takahasi
2010-12-20 23:02 ` Johan Hedberg
2010-12-21 12:03 ` Anderson Lizardo
2010-12-21 12:02 ` [PATCH v3] " Anderson Lizardo
2010-12-21 12:47 ` Johan Hedberg
2010-12-16 9:15 ` [PATCH 1/5] Implement cancel primary discovery session Johan Hedberg
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=20101216092432.GB4322@jh-x301 \
--to=johan.hedberg@gmail.com \
--cc=claudio.takahasi@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=sheldon.demario@openbossa.org \
/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