From bc1a313c9f130640b21e13663d3ff6c447cd1de2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 3 Jul 2017 17:46:22 -0700 Subject: Increase the BLE timeout to 12 seconds This seems really long, but one user appeared to get a response after almost 10 seconds. So going with 12 for some margin of error. Signed-off-by: Dirk Hohndel --- core/qt-ble.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index d6a716652..5cf7f1f5d 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -19,6 +19,8 @@ #include +#define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait + extern "C" { void waitFor(int ms) { @@ -137,7 +139,7 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual) return DC_STATUS_IO; QTimer timer; - int msec = 5000; + int msec = BLE_TIMEOUT; timer.setSingleShot(true); waitForPacket.connect(&timer, SIGNAL(timeout()), SLOT(quit())); @@ -190,7 +192,7 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d controller->connectToDevice(); // Create a timer. If the connection doesn't succeed after five seconds or no error occurs then stop the opening step - int msec = 5000; + int msec = BLE_TIMEOUT; while (msec > 0 && controller->state() == QLowEnergyController::ConnectingState) { waitFor(100); msec -= 100; @@ -216,7 +218,7 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d controller->discoverServices(); - msec = 5000; + msec = BLE_TIMEOUT; while (msec > 0 && controller->state() == QLowEnergyController::DiscoveringState) { waitFor(100); msec -= 100; @@ -232,7 +234,7 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d } qDebug() << " .. discovering details"; - msec = 5000; + msec = BLE_TIMEOUT; while (msec > 0 && ble->preferredService()->state() == QLowEnergyService::DiscoveringServices) { waitFor(100); msec -= 100; -- cgit v1.2.3-70-g09d2