summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-01-03 15:22:08 +0100
committerAlex Blasche <alexander.blasche@qt.io>2017-01-04 08:20:41 +0000
commitcef885088cc5ad4ec902b3b34358f017bea3d3d5 (patch)
tree801cdd4da9f0b9dcc1a020e4fc997c6ee3b07444
parent6a6e993fce9777077a39a42fd3dc29b31456a9ff (diff)
Bluez: Stop advertisement once Bluez Peripheral disconnectFromDevice()
Although this was not explicitly documented this is the behavior that the associated heartrate example exhibits. This change ensures that it is documented and enforced. [ChangeLog][QtBluetooth][BlueZ] Fixed continued advertisement of peripheral data once QLowEnergyController::disconnectFromDevice() was called. Public documentation was added to publically state the behavior. Change-Id: I3678c92fbb0d12cca17cd65ef7566a3ae4b55dc2 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/bluetooth/qlowenergycontroller.cpp4
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp
index 4df92a39..03278276 100644
--- a/src/bluetooth/qlowenergycontroller.cpp
+++ b/src/bluetooth/qlowenergycontroller.cpp
@@ -737,6 +737,10 @@ void QLowEnergyController::connectToDevice()
This function does nothing if the controller is in the \l UnconnectedState.
+ If the controller is in the peripheral role, it stops advertising too.
+ The application must restart the advertising mode by calling
+ \l startAdvertising().
+
\sa connectToDevice()
*/
void QLowEnergyController::disconnectFromDevice()
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index 03580ff6..f8d2ba2a 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -639,6 +639,10 @@ void QLowEnergyControllerPrivate::resetController()
receivedMtuExchangeRequest = false;
securityLevelValue = -1;
connectionHandle = 0;
+
+ // public API behavior requires stop of advertisement
+ if (role == QLowEnergyController::PeripheralRole && advertiser)
+ advertiser->stopAdvertising();
}
void QLowEnergyControllerPrivate::restartRequestTimer()