linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Martin Woolley <mwoolley@bluetooth.com>
Cc: "Linux-bluetooth@vger.kernel.org" <Linux-bluetooth@vger.kernel.org>
Subject: Re: Comments on the ConnectDevice API function
Date: Fri, 22 May 2020 10:48:44 -0700	[thread overview]
Message-ID: <CABBYNZKonvHxnabQsu84rVQEPpou45UgqVUECZ2HoTdd7pWT+A@mail.gmail.com> (raw)
In-Reply-To: <MWHPR17MB19671EAD4D74EA7BC5915CA7C5B40@MWHPR17MB1967.namprd17.prod.outlook.com>

Hi Martin,

On Fri, May 22, 2020 at 1:25 AM Martin Woolley <mwoolley@bluetooth.com> wrote:
>
> Hello
>
> I've recently been working with BlueZ via D-Bus and have a situation which requires me to be able to connect to a device whose Bluetooth device address is known, but without first scanning. This is a link layer state transition with the specification allows.
>
> BlueZ currently supports this via an API adapter function called ConnectDevice, whose status is currently "experimental". From my experience of using this function, it seems to behave like this:
>
> If the BlueZ instance has not scanned yet, so that the target device is not known to it, the ConnectDevice call results in scanning taking place and then if the target device is found, it is connected to. Success!
>
> But if scanning has previously been performed, regardless of the state of the actual device (e.g. advertising and ready to accept connections), an exception is thrown with a message whose text value is "Already Exists".
>
> I was wondering if I could influence the design of the API before the ConnectDevice experimental status is removed?
>
> I would like to suggest that there should be no need for a special API to connect directly to a device without first scanning. Why burden the application developer needing to call it just in case this condition applies, catching the BlueZ exception ("Already Exists") and responding by then calling the normal Connect API?

I guess the intention was to have the application use the intended API
for devices already present _before_ calling ConnectDevice, so before
entering the address manually the application would enumerate the
existing devices and figure out if that was already present.

> An alternative would be to accommodate this special case (not scanned before) in the implementation of the standard device Connect(bdaddr) function or if that makes no sense because Device objects must correspond to previously discovered, physical devices, then at least the adapter ConnectDevice function could take care of the two possible paths and simplify matters for the application developer.

I guess you probably know this but just in case someone look at the
archives it is better that we make some things clearer, while the core
spec allows connecting without scanning D-Bus are intend to be a
higher level API thus why ConnectDevice was not really necessary for a
long time and we just introduced it for qualification purpose or when
there are multiple adapter where one acts as scanner. Also ever since
the introduction of privacy (random addresses) APIs that takes
addresses becomes rather complicated to be used directly, and there
exists ways to scan for a specific address with pattern filtering:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt#n122

That said I don't oppose to remove Already Exists error, but we should
be very clear that the use of such API should only be recommended with
users input and does not substitute the likes of Device.Connect.

-- 
Luiz Augusto von Dentz

  reply	other threads:[~2020-05-22 17:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  8:22 Comments on the ConnectDevice API function Martin Woolley
2020-05-22 17:48 ` Luiz Augusto von Dentz [this message]
2020-05-27 13:41   ` Martin Woolley
2020-05-27 14:10     ` Szymon Janc
2020-05-27 15:38       ` Luiz Augusto von Dentz
2020-05-27 16:10         ` Martin Woolley
2020-05-27 16:32           ` Martin Woolley

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=CABBYNZKonvHxnabQsu84rVQEPpou45UgqVUECZ2HoTdd7pWT+A@mail.gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=Linux-bluetooth@vger.kernel.org \
    --cc=mwoolley@bluetooth.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).