diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-11-02 12:20:45 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-11-18 17:56:50 +0000 |
commit | 716bdac1e84874245cfceec5ada17c3525bc1606 (patch) | |
tree | 36365fe5581b7d2cc05ce084e6548bc687cb0958 /tests | |
parent | e5aae9a95499a64c8da1bd2601bb05ff5c27d78a (diff) | |
download | qtconnectivity-716bdac1e84874245cfceec5ada17c3525bc1606.tar.gz |
Fix BT LE service addition timing issue on Android
If services were added in a tight loop sometimes the services are
created wrong. In practice this results in a situation where a client
reads a characteristic value from "Service A", but gets the value from
"Service B" - even if the client had no knowledge of "Service B".
The problem is that according to Android documentation, the
BluetoothGattServer::addService() must not be called before the prior
added service has received a
BluetoothGattServerCallback::onServiceAdded() -callback.
This commit serializes/queues the service additions.
Fixes: QTBUG-96742
Change-Id: I42c980600419787d4490d1a1059e3893597cb7cf
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit 4deb789fe67615ebfa99af6f1071d20b0265a2e9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bluetoothtestdevice/bluetoothtestdevice.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/tests/bluetoothtestdevice/bluetoothtestdevice.cpp b/tests/bluetoothtestdevice/bluetoothtestdevice.cpp index ef3a15fc..4fe504b5 100644 --- a/tests/bluetoothtestdevice/bluetoothtestdevice.cpp +++ b/tests/bluetoothtestdevice/bluetoothtestdevice.cpp @@ -279,7 +279,6 @@ int main(int argc, char *argv[]) for (const auto &serviceData : serviceDefinitions) { services.emplaceBack(leController->addService(serviceData)); - std::this_thread::sleep_for (std::chrono::seconds(1)); } leController->startAdvertising(QLowEnergyAdvertisingParameters(), advertisingData, @@ -290,7 +289,6 @@ int main(int argc, char *argv[]) connectioncount++; for (int i = 0; i < services.size(); ++i) { services[i].reset(leController->addService(serviceDefinitions[i])); - std::this_thread::sleep_for (std::chrono::seconds(1)); } |