Commit Graph

9 Commits

Author SHA1 Message Date
Juha Vuolle a79a8de708 Improve bluetooth manual test support
This is a preparatory commit for adding the Bluez DBus peripheral
role support.

Aim is to improve the manual test coverage: add large descriptor
writes, ability to set advertising data multiple times, add more
services, characteristics etc. Also adjust the large attribute
size so that it works with bluez dbus.

Task-number: QTBUG-107510
Change-Id: I5f22880349606feb4f61032b78c62b990329eb69
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2022-12-07 11:47:43 +02:00
Ivan Solovev 5a5abc2d73 Add tst_qlowenergycontroller_device::testRepeatedCharacteristicsWrite()
... and its counterpart in bluetoothtestdevice.

The client side generates multiple writes to the same characteristics.
The server side, when receiving each new value, copies it to the
notifying characteristic, which sends notification back to the clien.
In this way the client can verify that all writes were completed
successfully and in the right order.

Fixes: QTBUG-105556
Pick-to: 6.4 6.3 6.2
Change-Id: Id5ba5b00527a01903b3730733188065c1cc6a94e
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
2022-08-26 12:50:02 +02:00
Lucie Gérard 664d2a1cf0 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: Ifc22d8ae24532e9a1093ca613ed6590a1992bc39
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-10 15:13:12 +02:00
Juha Vuolle e24f99cc1d Use the new "permissions error" code on macOS
Qt 6.4 introduces new error code for permission errors (QTBUG-102373).
This commit makes use of the new error code. This consists of two
parts:
1) If the bluetooth permission key is missing from the application's
   Info.plist and we know it's needed => permission error. This is
   limited to Low Energy because classic bluetooth does not need it
   on macOS, and iOS does not support classic bluetooth.
   If the key is missing, it is an application development/deployment
   error and we should not make too many of these checks - few places
   is enough.
2) At runtime the platform prompts for bluetooth permission and the user
   may disallow it => permission error.

Amends: d58d134d25

Fixes: QTBUG-103388
Change-Id: I96de202e9ac8c33e51bc126389f62091d03eab70
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-05-30 17:29:15 +03:00
Juha Vuolle 2609a13d61 Fix bluetooth manual test application crash when no adapter
If there is no adapter available, the bluetoothtestdevice manual
test application crashes as it accesses empty adapter list.

Pick-to: 6.2 6.3
Change-Id: I2126cad73713976e453775b573518c041d369b52
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-12 11:11:42 +03:00
Marc Mutz b3713b3ba8 Port indexed for-loops from int to qsizetype
... and port (already or soon-expected-to-be) count() to size().

These changes are considered trivial, in that nothing but the loop
variable needs adjustment.

The alternative, a port to ranged for-loops, I dismissed for these
loops, either because the loop index was used for something else
(first/last check, zip iteration) or I was just too lazy to prove that
the container under iteration isn't changed.

In some cases, I may have forgotten to port to ranged loops, even
though it would be trivially safe. This was already much more complex
than anticipated :)

Also fix post-increment to pre-increment. It doesn't matter for
integral types, but developers that regularly read and write
post-increment for integral types will likely fail to switch to
pre-increment for iterators types, where the difference does matter,
so increase the exposure of code readers to the idiomatic form.

Pick-to: 6.3
Task-number: QTBUG-102463
Change-Id: Ia6f2960dc52d46ffbd48f12446e9b0f7c70df162
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-11 19:44:41 +00:00
Juha Vuolle ba867f63b6 Add server platform identification support for BT LE manual test
The BT LE support differs slightly on different platforms on the server
side. This commit adds the means to adjust the BT LE client-side
expectations depending on which platform the counterpart server is
running on.

Task-number: QTBUG-98781
Pick-to: 6.2
Change-Id: Ia30afb2ba2256595cd5556bb417f9542ecb0b06c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-12-06 17:01:03 +02:00
Juha Vuolle 4deb789fe6 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
Pick-to: 6.2 5.15
Change-Id: I42c980600419787d4490d1a1059e3893597cb7cf
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-11-18 15:28:16 +02:00
Andreas Buhr f3fcf88a0d Add bluetoothtestdevice tool
This patch adds a tool "bluetoothtestdevice" which
acts as a partner device in QtBluetooth unit tests.

Pick-to: 6.2
Change-Id: I5be89cf555a94a209de093d328fb29f91c2fea9a
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-26 13:23:19 +02:00