diff options
author | Juha Vuolle <juha.vuolle@qt.io> | 2023-09-19 15:26:34 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-09-21 08:16:17 +0000 |
commit | da88795e007de97b5545cae9106d2041712eb33c (patch) | |
tree | 91e8137e9cc9d172f03ac386655537ea1950ce8a | |
parent | 750eceae469df96e37b146d82d8d287c643b8b71 (diff) |
Clear any pendingJob of BT LE controller in case of disconnect
When using QLowEnergyController in Client role and the remote
peripheral disconnects, we clear any current resources. However
it seems we didn't clear the pendingJob variable.
If the pendingJob variable remains non-null, then the next time
we use the controller, the "performNextIO()" function will return
early as it waits for the previous job to complete. However in this
case, as it is a remnant from a previous run, it never completes,
and the application's QLowEnergyService::discoverServiceDetails()
will silently do nothing (the new job is put into job queue, but
never attended, because of this pendingJob not completing).
Pick-to: 6.5
Fixes: QTBUG-115370
Change-Id: Idd14efcc1469c155ac46c6a35336e04fc5bd6aa9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit cc337336fd51a13afc4ea09acf52c746fc747dbf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java index 08527385..0e612add 100644 --- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java +++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java @@ -257,6 +257,9 @@ public class QtBluetoothLE { private synchronized void handleOnConnectionStateChange(BluetoothGatt gatt, int status, int newState) { + + Log.d(TAG, "Connection state changes to: " + newState + ", status: " + status + + ", qtObject: " + (qtObject != 0)); if (qtObject == 0) return; @@ -1077,11 +1080,14 @@ public class QtBluetoothLE { handleForTimeout.set(HANDLE_FOR_RESET); readWriteQueue.clear(); + pendingJob = null; } // This function is called from Qt thread public synchronized boolean discoverServiceDetails(String serviceUuid, boolean fullDiscovery) { + Log.d(TAG, "Discover service details for: " + serviceUuid + ", fullDiscovery: " + + fullDiscovery + ", BluetoothGatt: " + (mBluetoothGatt != null)); try { if (mBluetoothGatt == null) return false; @@ -1471,6 +1477,10 @@ public class QtBluetoothLE { */ private synchronized void performNextIO() { + Log.d(TAG, "Perform next BTLE IO, job queue size: " + readWriteQueue.size() + + ", a job is pending: " + (pendingJob != null) + ", BluetoothGatt: " + + (mBluetoothGatt != null)); + if (mBluetoothGatt == null) return; @@ -1534,7 +1544,7 @@ public class QtBluetoothLE { } if (nextJob.jobType != IoJobType.Mtu && nextJob.jobType != IoJobType.Rssi) { - Log.w(TAG, "Performing queued job, handle: " + handle + " " + nextJob.jobType + " (" + + Log.d(TAG, "Performing queued job, handle: " + handle + " " + nextJob.jobType + " (" + (nextJob.requestedWriteType == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE) + ") ValueKnown: " + nextJob.entry.valueKnown + " Skipping: " + skip + " " + nextJob.entry.type); |