summaryrefslogtreecommitdiffstats
path: root/core/qt-ble.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-11-13 23:41:11 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-13 20:44:26 -0800
commit38b1b7d951d3586f16761964aee6f2876e80b117 (patch)
tree31c5104edd5093b8c9a2c4f954ffdffadccefe9e /core/qt-ble.cpp
parent8adcc826560a7163777066540513cbdf622e3add (diff)
downloadsubsurface-38b1b7d951d3586f16761964aee6f2876e80b117.tar.gz
Better error message on BLE connection timeout
On BLE connection timeout a weird error-message was shown, because the controller was still in connecting state and no error string was set. Therefore, handle the timeout case with a special case label. Moreover, remove three unnecessary calls to disconnectFromDevice(), which is called in the destructor of the controller anyway (verified by looking at Qt source). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/qt-ble.cpp')
-rw-r--r--core/qt-ble.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index 678296b29..2e92345dc 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -326,10 +326,14 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d
case QLowEnergyController::ConnectedState:
qDebug() << "connected to the controller for device" << devaddr;
break;
+ case QLowEnergyController::ConnectingState:
+ qDebug() << "timeout while trying to connect to the controller " << devaddr;
+ report_error("Timeout while trying to connect to %s", devaddr);
+ delete controller;
+ return DC_STATUS_IO;
default:
qDebug() << "failed to connect to the controller " << devaddr << "with error" << controller->errorString();
report_error("Failed to connect to %s: '%s'", devaddr, controller->errorString().toUtf8().data());
- controller->disconnectFromDevice();
delete controller;
return DC_STATUS_IO;
}
@@ -354,7 +358,6 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d
if (ble->preferredService() == nullptr) {
qDebug() << "failed to find suitable service on" << devaddr;
report_error("Failed to find suitable service on '%s'", devaddr);
- controller->disconnectFromDevice();
delete ble;
return DC_STATUS_IO;
}
@@ -369,7 +372,6 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d
if (ble->preferredService()->state() != QLowEnergyService::ServiceDiscovered) {
qDebug() << "failed to find suitable service on" << devaddr;
report_error("Failed to find suitable service on '%s'", devaddr);
- controller->disconnectFromDevice();
delete ble;
return DC_STATUS_IO;
}