qt-ble: add support for libdivecomputer 'set_timeout()' function

Because some BLE operations can be very slow (device and service
discovery etc), we have some rather excessive default timeout for BLE
(currently set to 12 seconds).

But once we actually have started doing IO, that long timeout can be a
big performance problem, when the libdivecomputer backend has support
for retry and packet loss.

For that reason, libdivecomputer has a 'set_timeout()' function that
allows the divecomputer backend to say how quickly it expects the dive
computer to answer before the backend will start resending packets.

Let's just implement that for the actual IO side of BLE too.  The
default timeout value remains the general BLE timeout, and this only
affects the actual IO phase, but it improves things enormously for the
case where there is packet loss at that point.

For example, on the Aqualung i770R, the timeout for packet loss ends up
now being just one second rather than the full 12 seconds of default BLE
timeout.  Which gets the retry going much faster.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2018-10-06 11:43:48 -07:00 committed by Dirk Hohndel
parent 88f4c06b99
commit cd55344410
3 changed files with 17 additions and 2 deletions

View file

@ -410,7 +410,7 @@ ble_packet_open(dc_iostream_t **iostream, dc_context_t *context, const char* dev
void *io = NULL;
static const dc_custom_cbs_t callbacks = {
NULL, /* set_timeout */
qt_ble_set_timeout, /* set_timeout */
NULL, /* set_latency */
NULL, /* set_break */
NULL, /* set_dtr */