summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_android.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2014-11-10 15:07:20 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2014-11-12 09:19:29 +0100
commitd2c2e502dcee44d06eb0b0ad392571d7bc3021bf (patch)
tree7e05f7d978664b363e856ccfdc88619266a882fe /src/bluetooth/qlowenergycontroller_android.cpp
parentb299a75a1d90dfd44c0f11ad75665c087c9ea120 (diff)
Improve reliability of QLEController connect()/disconnect()/connect()
Quick disconnecting and reconnecting caused some bugs and revealed some unreliabe API behavior on Android. The internal data structures were never cleaned up when disconnecting from the remote device. If multiple QLEService objects of the same QLEController instance requested a service discovery, every request but the first failed. This was fixed by queueing up the service discovery requests. Last but not least, reusing the same BluetoothGatt instance for the reconnect is very error prone. It may well be caused by Android API bugs. The reconnect would sometimes fail or toggle the connect/disconnect flag a couple of times which is not a problem for the Qt API itself but the stability of the related unit test (see tst_QLowEnergyController::tst_concurrentDiscovery()). Therefore we won't reuse the same BluetoothGatt instance but rather request a new one. Change-Id: I314f2a30960284b9bcd4926f4944c415a6d75788 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_android.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller_android.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp
index f832d868..4801d9bf 100644
--- a/src/bluetooth/qlowenergycontroller_android.cpp
+++ b/src/bluetooth/qlowenergycontroller_android.cpp
@@ -167,7 +167,10 @@ void QLowEnergyControllerPrivate::connectionUpdated(
Q_Q(QLowEnergyController);
const QLowEnergyController::ControllerState oldState = state;
- qCDebug(QT_BT_ANDROID) << "Connection updated" << errorCode << oldState << newState;
+ qCDebug(QT_BT_ANDROID) << "Connection updated:"
+ << "error:" << errorCode
+ << "oldState:" << oldState
+ << "newState:" << newState;
if (errorCode != QLowEnergyController::NoError) {
// ConnectionError if transition from Connecting to Connected