From 3c25c78bae67ba2a30f6cfcf2764cfde18ba4d21 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 28 Dec 2019 11:35:58 -0800 Subject: [PATCH] Mares: increase timeout to 3 seconds The Mares Bluetooth dongle is some seriously messed up stuff, and takes forever to answer anything. I'm not sure what we do wrong, because the Mares mobile App seems to be able to work with it without the excessive delays, but it is really incredibly slow when we talk to it. I suspect the dongle has has some "wait until buffer is half full" timeout, and it then triggers for every command and short reply in both directions, and there's likely some way to flush it, but I didn't see anything back when I had one for testing. Anyway, as a result, one second is just about the latency that the dongle itself adds regardless of anything else, so when the dive computer itself needs a timeout to think about things, the overall timeout needs to be noticeably more than one second. Three seconds seems to be a somewhat reasonable compromise, and we do have documentation for it being the right value: "Then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out." because we do have strong reasons to believe that the Mares Bluetooth dongle is a beast from hell. Everybody who has ecver met it has certainly gone "Arrrghhh" at some point. Signed-off-by: Linus Torvalds --- src/mares_iconhd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 2a714a4..175ee4a 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -482,8 +482,8 @@ mares_iconhd_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_ goto error_free; } - // Set the timeout for receiving data (1000 ms). - status = dc_iostream_set_timeout (device->iostream, 1000); + // Set the timeout for receiving data (3s = 3000 ms, the BLE dongle can be slow). + status = dc_iostream_set_timeout (device->iostream, 3000); if (status != DC_STATUS_SUCCESS) { ERROR (context, "Failed to set the timeout."); goto error_free;