summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller.cpp
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-10-21 14:19:00 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-10-29 16:49:02 +0300
commit0879874ca49042e5a4aeb1a3ec158d04b7578bbe (patch)
tree0b7746b6621b9e208aea101a5f47a34f7530e883 /src/bluetooth/qlowenergycontroller.cpp
parentb43a85f6d7c134080a7dd30d162a59198d5c3f22 (diff)
Android BT LE server connectivity detection with multiple devices
A BT LE server can serve multiple remote devices concurrently. The original problem was that if any of the remote devices disconnected, the BT LE server would also report itself as disconnected even if there were still connected devices. This disconnection can happen even if the remote device was not in any way interested in the Qt BT LE server (eg. LE headphones disconnecting during pairing). This commit checks if there are still connected devices and reports disconnection when the last device has disconnected. Additionally the remoteAddress and remoteName are updated to reflect these events: - if a device is connected, that device's address will be used - if a device is disconnected and it was the most recent device, the address is set to that of another still connected device Pick-to: 6.2 Fixes: QTBUG-97576 Change-Id: I785e51574aea5e0d0a806a26f07a497101d9bab5 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp
index e4aff61c..f58bd42e 100644
--- a/src/bluetooth/qlowenergycontroller.cpp
+++ b/src/bluetooth/qlowenergycontroller.cpp
@@ -219,9 +219,11 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
This signal is emitted when the controller successfully connects to the remote
Low Energy device (if the controller is in the \l CentralRole) or if a remote Low Energy
device connected to the controller (if the controller is in the \l PeripheralRole).
- On iOS and OS X this signal is not reliable if the controller is in the \l PeripheralRole
- - the controller only guesses that some central connected to our peripheral as
- soon as this central tries to write/read a characteristic/descriptor.
+ On iOS, macOS, and Android this signal is not reliable if the controller is in the
+ \l PeripheralRole. On iOS and macOS the controller only guesses that some central
+ connected to our peripheral as soon as this central tries to write/read a
+ characteristic/descriptor. On Android the controller monitors all connected GATT
+ devices.
*/
/*!
@@ -241,8 +243,9 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
\fn void QLowEnergyController::disconnected()
This signal is emitted when the controller disconnects from the remote
- Low Energy device or vice versa. On iOS and OS X this signal is unreliable
- if the controller is in the \l PeripheralRole.
+ Low Energy device or vice versa. On iOS and macOS this signal is unreliable
+ if the controller is in the \l PeripheralRole. On Android the signal is emitted
+ when the last connected device is disconnected.
*/
/*!
@@ -505,7 +508,7 @@ QBluetoothAddress QLowEnergyController::localAddress() const
For a controller in the \l CentralRole, this value will always be the one passed in when
the controller object was created. For a controller in the \l PeripheralRole, this value
- is the address of the currently connected client device. In particular, this address will
+ is one of the currently connected client device addresses. This address will
be invalid if the controller is not currently in the \l ConnectedState.
*/
QBluetoothAddress QLowEnergyController::remoteAddress() const