All of lore.kernel.org
 help / color / mirror / Atom feed
* WriteValue succeeds without error when the connection breaks
@ 2017-11-27 20:13 Ayke van Laethem
  0 siblings, 0 replies; only message in thread
From: Ayke van Laethem @ 2017-11-27 20:13 UTC (permalink / raw)
  To: linux-bluetooth

Hi all,

I have an application (acting as BLE central device) which connects to
a peripheral. The application does a write (using WriteValue) which
causes a reset in the peripheral, thus breaking the connection.
Strangely, the WriteValue command returns without exception, even
though it takes a few seconds until it hits a timeout. A second
WriteValue will return an error ("Not connected").

The sequence:

(connection is set up)
central: sends a message to the peripheral (WriteValue)
peripheral: receives message
peripheral: resets, starts to advertise again
central: waits a few seconds for a response which it never gets
central: timeout, WriteValue returns without error

I would expect it to generate some sort of error, something like "lost
connection".
A workaround is checking whether the device is still connected after a
WriteValue command, which I've implemented in [1].

I have tested this on BlueZ 5.43 (Debian). I have checked all commits
to src/gatt-client.c but could not find any commit that could fix this
issue, so I believe it is still present. If necessary, I can try
compiling the latest release from source but haven't done this before.

What I'm testing is a BLE NUS console [2] running on a
Bluetooth-enabled laptop which communicates with a Nordic chip running
MicroPython [3]. Pressing Ctrl-D in the console will cause the device
to reset, and the WriteValue is never acknowledged by the Nordic chip.
The result (without workaround) is that the connection appears to
still exist while it is actually broken, until the next char is sent
(which returns a "not connected" error).

I can provide logs (how?) and minimal sample code if needed.

[1]: https://github.com/aykevl/pynus/blob/master/tealblue.py#L224
[2]: https://github.com/aykevl/pynus/blob/master/pynus.py
[3]: https://github.com/tralamazza/micropython

Ayke van Laethem

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-11-27 20:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 20:13 WriteValue succeeds without error when the connection breaks Ayke van Laethem

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.