summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2019-12-06 13:40:20 +0100
committerAlex Blasche <alexander.blasche@qt.io>2019-12-10 23:10:25 +0100
commit0313535fd9ccb05b60c5e421c1c986e48564e254 (patch)
treea148eec84abcac4104bc93044669fff0c8381863 /src
parentf7075bc4536c9f72663378b94df55e6beb5a86fb (diff)
Android: Fix failing re-addvertisement of BTLE service after disconnect
The BTLE server can disconnect by own choice and by remotely initiated disconnect. Often the app might want to readvertise the same service right after the disconnect. Such a readvertisement fails when the BluetoothGattServer instance is not recreated, before calling BluetoothGattServer.addService(). In the case of remote disconnects we never recreated the BluetoothGattServer instance therefore the readvertisement always failed. This patch fixes the issue by ensureing the previous instance is properly discarded. Change-Id: I39380ee6f1f39bd71a5b73ec82bb786b3e199665 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java
index cdd16686..9ef254f5 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer.java
@@ -237,6 +237,7 @@ public class QtBluetoothLEServer {
qtControllerState = 0; // QLowEnergyController::UnconnectedState
clientCharacteristicManager.markDeviceConnectivity(device, false);
mGattServer.close();
+ mGattServer = null;
break;
case BluetoothProfile.STATE_CONNECTED:
clientCharacteristicManager.markDeviceConnectivity(device, true);
@@ -461,7 +462,8 @@ public class QtBluetoothLEServer {
return;
}
- mGattServer.addService(service);
+ boolean success = mGattServer.addService(service);
+ Log.w(TAG, "Services successfully added: " + success);
}
/*