diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2018-04-13 17:17:19 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2018-04-17 12:21:31 +0000 |
commit | e68b5e17b071ca11974474546be04c7d564eae3a (patch) | |
tree | 3f330a19d0a5d53e8c0658ad138430788664382b /src/bluetooth/qlowenergycontroller_android.cpp | |
parent | 184307884f560653421286cc9e5e6f0e86a4cef4 (diff) |
Android: Fix start/stop behavior of QLowEnergyController (peripheral)
This patch addresses two bugs. Firstly it ensures that the correct Java
function is executed when disconectFromDevice() is called on Android
peripheral.
Secondly, it turned out that calling disconnectFromDevice() while a
connection to a central exists and restarting the advertisement
resulted in a non-functional QLEController instance because
BluetoothGattServer was not properly restarted. As a side effects
the controller's state tracking stopped as well.
Change-Id: I98851fc974ceff2a1fcb03fe754dbda9c4aba271
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_android.cpp')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_android.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp index c5c9ba56..54665f7b 100644 --- a/src/bluetooth/qlowenergycontroller_android.cpp +++ b/src/bluetooth/qlowenergycontroller_android.cpp @@ -180,8 +180,12 @@ void QLowEnergyControllerPrivateAndroid::disconnectFromDevice() QLowEnergyController::ControllerState oldState = state; setState(QLowEnergyController::ClosingState); - if (hub) - hub->javaObject().callMethod<void>("disconnect"); + if (hub) { + if (role == QLowEnergyController::PeripheralRole) + hub->javaObject().callMethod<void>("disconnectServer"); + else + hub->javaObject().callMethod<void>("disconnect"); + } if (oldState == QLowEnergyController::ConnectingState) setState(QLowEnergyController::UnconnectedState); |