linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Emil Lenngren <emil.lenngren@gmail.com>
Cc: Bluez mailing list <linux-bluetooth@vger.kernel.org>
Subject: Re: Flag for specifying write type to WriteValue in gatt-api.
Date: Thu, 31 Jan 2019 19:03:07 +0200	[thread overview]
Message-ID: <CABBYNZJ8hqJph3DgFBdTPBpD5eqSvMHCsrwvNZx3z5v9Fbu3Vg@mail.gmail.com> (raw)
In-Reply-To: <CAO1O6scUuK1K+zLjyQA12HtY9nNdR=Q8MeuruC2GKvaJPH0knA@mail.gmail.com>

Hi Emil,

On Thu, Jan 31, 2019 at 6:19 PM Emil Lenngren <emil.lenngren@gmail.com> wrote:
>
> Hi,
>
> I was looking through the quite lengthy discussion at
> https://github.com/WebBluetoothCG/web-bluetooth/issues/238 on the
> issue that in Web-Bluetooth, only a single "write value" API is
> available, causing Web-Bluetooth to decide on its own if Write With
> Response or Write Without Response should be used, in case both are
> supported by the characteristic.
>
> But in the Bluetooth spec about Write Without Response:
>
> "This sub-procedure is used to write a Characteristic Value to a
> server when the client knows the Characteristic Value Handle and the
> client does not need an acknowledgement that the write was
> successfully performed."
>
> Basically, it says it's up to the client/application to decide if an
> acknowledgement is needed or not, and hence it's the app that should
> decide if Write With or Without Response should be used. The "client"
> can't mean a bluetooth stack here since it can of course not know if
> an acknowledgement is needed or not.

There is a property indicating if write without response is supported
though, but you are right regarding that not excluding regular write
so at that point the client would have a choice whether to use it or
not.

> I noticed that according to gatt-api.txt, BlueZ has the same
> limitation in the WriteValue method, in that the stack chooses the
> write type "arbitrarily" if both write types are supported (or really
> the Write With Response is chosen, which might cause unwanted
> latency). Therefore I suggest that an option should be added to the
> WriteValue method, for example "write-without-response" (bool) to
> force Write Without Response.

It gets a bit trickier if the attribute is in fact a control point in
which case perhaps only write-without-response really works, anyway
control points are better off using AcquireWrite.

> Note how iOS has a write type parameter to the write method, and
> Android has a write type property you set before you execute the
> write.
>
> I see that it might be possible to achieve the same result with
> AcquireWrite -> write to socket -> release but that wouldn't be a good
> solution for bluetooth stacks built on top of BlueZ that would like to
> differentiate between the two write types (such as Web-Bluetooth)
> since AcquireWrite can fail, for example if two apps write the value
> at the same time (I guess the lock is exclusive?). It also seems like
> unnecessary overhead to open and close sockets.

AcquireWrite is to be used when the app needs exclusive access, like
control points such as those commonly used for things like DFU, I
don't think that is your intent here (or is it?) so I guess adding an
option for WriteValue is probably better. Note though that obviously
one cannot use such a flag with things like e.g. offset as that is not
supported which makes the API a little trickier to use but I guess
that ok given that setting flags is optional.

-- 
Luiz Augusto von Dentz

  reply	other threads:[~2019-01-31 17:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 16:15 Flag for specifying write type to WriteValue in gatt-api Emil Lenngren
2019-01-31 17:03 ` Luiz Augusto von Dentz [this message]
2019-01-31 17:46   ` Emil Lenngren
2019-01-31 17:55     ` Luiz Augusto von Dentz
2019-01-31 18:09       ` Emil Lenngren

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=CABBYNZJ8hqJph3DgFBdTPBpD5eqSvMHCsrwvNZx3z5v9Fbu3Vg@mail.gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=emil.lenngren@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).