From d2c2e502dcee44d06eb0b0ad392571d7bc3021bf Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 10 Nov 2014 15:07:20 +0100 Subject: 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 Reviewed-by: Alex Blasche --- src/bluetooth/qlowenergycontroller_android.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/bluetooth/qlowenergycontroller_android.cpp') 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 -- cgit v1.2.1