Commit Graph

1916 Commits

Author SHA1 Message Date
Alex Blasche c2b510909d Ensure QObject context is retained to avoid crashes
If the public class is deleted pending lambda invocation can cause
crashes unless QObject context is provided. This fixes a regression
introduced by 819bb06c2c.

This was discovered while investigating QTBUG-71479.

Change-Id: I3a49916ce6d9425c684863bb0b04a10bd3e652b9
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-10-31 08:19:38 +00:00
Alex Blasche 8d279a05f2 Fix regression not updating the device info during BTLE discovery
This is a regression introduced by
819bb06c2c.

The object context was missing and subsequent calls to QObject::sender()
failed. As a consequence the signalling for the device updates never
happened.

Fixes: QTBUG-71479
Change-Id: I6f057912a9321969b59ded8b0a3e5602653e5f2e
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-10-31 08:19:35 +00:00
Alex Blasche 26840646bb Improve QBluetoothDeviceDiscoveryAgent::deviceDiscovered() docs
The previous definition was not aware of the new deviceUpdated() signal.
This patch better outlines the connection.

Change-Id: I8beee9b43c5c0b782676de61b27b219b32c245f5
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-10-19 14:05:08 +00:00
Thiago Macieira a3aa995332 QBluetoothUuid: add QDataStream operator<<,>>
Don't depend on QUuid's.

Change-Id: I495bc19409f348069f5bfffd15516db994a430e4
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-10-19 03:28:54 +00:00
Alex Blasche 97dc04e0d7 Fix SDP BrowseGroupList entry
A BrowseGroupList is defined as sequence in which each element is a UUID
that represents a browse group to which the service record belongs.
Except for the QBluetoothServer::listen() implementation every other
implementation did not use the sequence pattern. This patch unifies
all BrowseGroupList entries through QtBluetooth and its examples/tests.

Change-Id: I37640ae0500c557d79350359883abc6a66a46346
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-10-16 07:47:34 +00:00
Alex Blasche dfee9aa22f Fix the BluetoothProfileDescriptorStructure
As per spec this is meant to be a list/sequence within a sequence and
the version was missing too. For simplicity version 1.0 is used.

Fixes: QTBUG-58529
Change-Id: I57090148aadf60ea1fbbb207ff0a4ae61e06caf2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-10-15 12:48:51 +00:00
Alex Blasche b09f5e493d Remove unused snippet section markers
This section is not used by any part of the documentation.

Change-Id: I3cfc5ff187bfe43bbd75302b45b7dcc6eddb113c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-10-15 12:48:47 +00:00
Timur Pocheptsov c9ed3c49e3 SDP records: handle ServiceID and ServiceClassIDList correctly (IOBluetooth)
We previously failed to correctly extract service ID and service
class ID list. As a result, service discovery agent working with
uuid filter and in MinimalDiscovery mode would fail to find anything,
without filtering - would probably end up in services not having
any valid service ID or ID list.

Task-number: QTBUG-71052
Change-Id: I6b5a36399abfaf66297abe4a38efa7659cbb2aa0
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-10-11 07:44:07 +00:00
Alex Blasche db8c876c74 Suppress "We mean it" warning due to battery1_p.h
QtBluetooth WARNING: /../qt512/qtconnectivity/src/bluetooth/bluez/battery1_p.h
does not have the "We mean it." warning.

Change-Id: Iddd792243690a1cf6ceab5d3d01de322d2c5d92e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-10-10 05:38:30 +00:00
Alex Blasche b65d9a863d Fix QObject::connect warnings due to removed Q_PRIVATE_SLOT instances
This fixes a regression introduced by 819bb06c2c
on macOS.

Fixes: QTBUG-71032
Change-Id: I34a0325f89049bce86b5137ee722f6f063a4b882
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-10-09 13:02:29 +00:00
Alex Blasche 35a97ca4b4 Permit adjusting of advertisement data
Prior to this change subsequent calls to
QLowEnergyController::startAdvertising() failed to update the
to-be-advertised information.

Fixes: QTBUG-70754
Change-Id: I594f4f916307e12be6be17d50497aea324520620
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-10-08 06:23:03 +00:00
Alex Blasche 54f9fe2c23 Don't report S_OK as error when calling GetAddressOf()
Fixes: QTBUG-70799
Change-Id: Iebbfbc2e00d83a6c08bb8a376c01734188e69388
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-28 10:45:12 +00:00
Alex Blasche 69e3e63ed9 Fix qtconnectivity build
This patch fixes the error introduced by
7d7651fb3b.

Change-Id: Idaf9066190535dd521efed7ab78e9203b99aadef
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-28 10:24:17 +00:00
Topi Reinio 57b0b8b03a Doc: Use a macro to resolve QML import versions
QDoc now supports macros for its command parameters, as well as passing
parameters to \code and \qml commands. Use these together with the
new \QtMinorVersion macro to automate bumping the QML import versions
within documentation.

Also, update the hard-coded version numbers in snippet files where we
cannot use the macro.

Task-number: QTBUG-67818
Change-Id: I93d92770314580efa933c5bf85c618ad8331afb5
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-09-28 10:07:41 +00:00
Oliver Wolff b4e9cc6ab7 winrt: Avoid crash on device discovery when device has to be paired
If a device has to be paired during device discovery on winrt it is
possible that the pairing dialog is shown, while discovery hits its
timeout. We have to protect against a late callback which tries to access
a deleted object.

Change-Id: I9756f993b4a31080b1ef518953bee6e75a24e315
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-09-27 08:45:01 +00:00
Eskil Abrahamsen Blomfeldt 7d7651fb3b Don't build when there is no Qt Network
Qt Connectivity depends on QAbstractSocket, so it will not build if
Qt Network is not built.

Change-Id: I94f812f4b4c0c23a38b6c0fcdef0ee962f68e8b0
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-09-27 06:50:16 +00:00
Alex Blasche 266e8d9eca Add limited PinCode pairing support to bttestui app
This help quicker testing of the feature.

Change-Id: I2389b1126ac2ea0ffc9dea4bb7561c683cf97088
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-26 06:21:36 +00:00
Alex Blasche 343eea046c Minor code cleanup for QBluetoothLocalDevice implementation on Android
Change-Id: I22da03879c23f6b6842cb832cea0cfee6e016445
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-26 06:21:33 +00:00
Alex Blasche a48a19d9db Don't trigger passkey pairing notification if remote device is unknown
The device address is essential for proper processing of
pairingDisplayConfirmation() signal on Android. If it is not available
abort immediately. This brings the passkey pairing code in line with
pincode pairing.

Change-Id: I174a2478d48463c58ba937e71ced377d45892f1a
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-26 06:21:30 +00:00
Alex Blasche f8c0572ddc Properly handle pin code pairing on Android
Most likely this paring variant was forgotten when Android support
for QBluetoothLocalDevice was implemented. This variant is rather uncommon
and Android's default pairing handler are likely to automatically
handle such requests too.

Fixes: QTBUG-70295
Change-Id: I618242da415574245e5a213a6e34f190c685c8e9
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-26 06:21:28 +00:00
Alex Blasche 7b40de8fbb Catch SecurityException during pairing on Android
QBluetoothLocalDevice::pairingConfirmation(bool) requires
BLUETOOTH_PRIVILEGED permission which cannot be obtained by 3rdparty
apps. I believe this used to be different as suggested by

b1dc175707

This patch ensures that the thrown SecurityException is caught and displays
an appropriate warning.

Change-Id: Ib5a0e0fc0c9f3b4f33690493ed74aa4b7cb8864b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-26 06:21:25 +00:00
Kai Koehne 77f5510fd6 Update plugins.qmltypes
Task-number: QTBUG-70264
Change-Id: I23d3be2fa247a7c12ead7f7a8e599a3869b44e09
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-09-19 06:23:14 +00:00
Alex Blasche 09e582d1c1 Fix various qdoc warnings in QtBluetooth
Change-Id: I49653a6ac6fa004987d32365f96a6407f50e207c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-09-18 10:40:26 +00:00
Qt Forward Merge Bot 66829dd143 Merge remote-tracking branch 'origin/5.11' into 5.12
Change-Id: I7c24df8729794b8241572bddd8d8cd0465993b42
2018-09-15 03:03:46 +02:00
Alex Blasche 7e4166a6ab Fix wrong logging message
This was caused by mindless copy & paste.

Change-Id: I129a5f52753e7aa825cf7f6337b5f24644d9b9a0
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-09-14 12:15:13 +00:00
Alex Blasche c4efc2638a Remove duplicated closure code and add missing cases of it
Change-Id: I4f33ec95b2af858b8d0c3ff60882b550a91563df
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-09-14 12:15:08 +00:00
Alex Blasche ba0988639b Implement handling of BTLE Battery services
Since BlueZ 5.48 battery services are no longer
exposed via the generic GATT interface but have their own
dedicated Battery1 interface. This patch transforms the
dedicated interface back into the previous behavior.
Essentially we are emulating the old interface to
ensure that the QLowEnergyService user does not have to
distinguish.

Fixes: QTBUG-70222
Change-Id: Ib9fef41cf16f7562f169f51ee45b19f52de6a0c0
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-09-14 12:15:04 +00:00
Alex Blasche af07a801cb Remove dead/unused member variable
Change-Id: I8a30d5d12fad73a714159ebe3e1d54e8c0b3e407
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-09-11 10:22:32 +00:00
Qt Forward Merge Bot 5f30c77484 Merge remote-tracking branch 'origin/5.11.2' into 5.11
Change-Id: I7ea913083777358265f62b4bf6beed3f2db0ebe1
2018-09-09 12:15:45 +02:00
Qt Forward Merge Bot fa9aa433f8 Merge remote-tracking branch 'origin/5.11' into 5.12
Change-Id: I576079e30f4075117ca764f45198bc1e5269d887
2018-09-08 03:01:31 +02:00
Paul Wicking c77d7bb17e Doc: Remove empty section in Qt NFC example overview page
Remove unused section "C++ Tutorial".

Change-Id: I55ba7286c00ae4573d97f6244dff1f589634b949
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-09-07 08:42:37 +00:00
Alex Blasche a1e00ab195 Fix a few clazy/clang warnings in HeartRate Game example
Change-Id: I2a7b8c403ca466998ddcbd8496c31feb9856f0ad
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-09-05 06:53:19 +00:00
Alex Blasche 68475e563d Fix QNearFieldManager related override warnings
Change-Id: If7adc165e063445ee0c34291a3e3840ddae0f570
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-09-03 13:25:58 +00:00
Oliver Wolff 771867113c winrt: Do proper error handling if connecting to a LE device fails
Task-number: QTBUG-70162
Change-Id: I4556cbf1965121b042a55e3e36e24383f8fa8dc9
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-08-31 12:48:57 +00:00
Alex Blasche 2a52a400d6 Fix bluez config test failure on clang
This compile failure used to be a warning only but these days is a failure
for clang:

> /home/ablasche/dev/qt/qt512/qtconnectivity/config.tests/bluez/main.cpp:36:11: error: taking the address of a temporary object of type 'bdaddr_t' [-Waddress-of-temporary]
>     bacmp(BDADDR_ANY, BDADDR_LOCAL);
>           ^~~~~~~~~~
> /usr/include/bluetooth/bluetooth.h:310:23: note: expanded from macro 'BDADDR_ANY'
> #define BDADDR_ANY   (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
>                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/ablasche/dev/qt/qt512/qtconnectivity/config.tests/bluez/main.cpp:36:23: error: taking the address of a temporary object of type 'bdaddr_t' [-Waddress-of-temporary]
>     bacmp(BDADDR_ANY, BDADDR_LOCAL);
>                       ^~~~~~~~~~~~
> /usr/include/bluetooth/bluetooth.h:312:23: note: expanded from macro 'BDADDR_LOCAL'
> #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
>                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 2 errors generated.

The need for BDADDR_NONE is obsolete now since the test does not rely on
those defines anymore. The main purpose is to check that bluetooth.h
is available which is already tested by using bacmp and bdaddr_t.

Change-Id: I09da4dc5cd3945ffae7819628b45477a52789006
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2018-08-31 07:11:31 +00:00
Alex Blasche 8b70dcb210 Add changelog for 5.11.2 release
Change-Id: Ie610cc0935594bda8c05cfad41dd49218e1930f1
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-08-31 07:09:37 +00:00
Alex Blasche 90ae576699 Fix failing restart of HeartRateServer example
Disconnecting from central devices invalidates the peripheral's service.
The change ensures that the service is recreated upon disconnection.

Change-Id: I2defc6ffb4c9f23d70b6f181c25f47746b3859a4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-31 07:09:23 +00:00
Alex Blasche 9004e89bb9 Ensure that local services have state LocalService
and invalidate the state once they have been disconnected. This affects
Android, Bluez and Apple code lines.

Change-Id: I2b87577930b6ae78e7ef7ef061e597beba946594
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-30 08:29:17 +00:00
Qt Forward Merge Bot bd7a3e23f6 Merge remote-tracking branch 'origin/5.11' into 5.12
Change-Id: I20db491b185972148ad3fbe6953e5d6ce2889a7f
2018-08-30 10:21:34 +02:00
Alex Blasche 96ce6cee40 Fix LEController peripheral mode on BlueZ
LEController in peripheral mode uses QBluetoothSocket::setSocketDescriptor().
Since QBluetoothsocket was ported to DBus (enabled when Bluez is 5.46 or later)
setSocketDescriptor()/server mode does not work. That's why
f602d7fef2 made sure that QBluetoothServer
uses the old raw socket implementation. Unfortunately QLowEnergyController
was forgotten and needs the same workaround.

Change-Id: I6ba3654ee199d0ffcf4b69f16dfbc5508d6b13d4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-30 07:12:59 +00:00
Alex Blasche 819bb06c2c Normalize QObject::connect() statements
Some cases use the Q_PRIVATE_SLOT logic which does not require QObject
inheritance. Those cases were converted to lambda logic to avoid need for
QObject inheritance.

The Q_PRIVATE_SLOT macro was removed from qbluetoothdevicediscoveryagent.h.
This is not a BC problem because the macro expands to nothing. Only
moc recognizes the pattern.

Change-Id: Ic7cb4cde397f9b230b6fd0b4046e59e504583e58
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2018-08-29 06:01:51 +00:00
Alex Blasche 77c3c1427d qRegisterMetaType for QBluetoothServiceInfo
Android internals seem to require it. All other existing test related
registrations are removed as they are obsolete after this patch.

Change-Id: I49aa3b79bdc8ca5f463f4f7a88cbb612db39d15e
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-28 10:53:47 +00:00
Alex Blasche fcf1f30d5f Code cleanup: Use nullptr wherever possible
Change-Id: I7dd2d055c8d667f049d7cb2c371619137bf76030
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-24 05:44:21 +00:00
Alex Blasche 89e92af794 Cleanup lowenergyscanner example with clang tidy and clazy help
Change-Id: Iaaf169b1ac9b3d4c348d9cabf737b395198a921f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-24 05:44:13 +00:00
Alex Blasche 4a20dda272 Add QBluetoothDeviceDiscoveryAgent::deviceUpdated signal
For iBeacons and such, it's normal to keep discovering indefinitely,
while the advertisement can sometimes carry changing payload data.
This signal helps keep the UI up-to-date.

Changed setManufacturerData to return a bool indicating whether the
data was really modified or not, to avoid sending deviceUpdated
in case it was not changed.

For convenience QBluetoothDeviceInfo::manufacturerData() was added.

WinRT and Apple platforms do not emit the new signal yet and relevant
TODO items were added.

Done-with: Shawn Rutledge <shawn.rutledge@qt.io>
Task-number: QTBUG-46008
Task-number: QTBUG-69747
Change-Id: I6d6b373f6cc5ee3dd6af2ad05d8640dbd25c5d6a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-08-23 07:44:35 +00:00
Shawn Rutledge b9e3ca7c32 Spell QBluetoothDeviceInfo::manufacturerIds correctly
Amends 0f930cddef

Change-Id: Ic3769d30198d3607a1fee218d9f2e90b9addf2d3
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-08-21 07:52:48 +00:00
Shawn Rutledge 0c2b6dc443 Provide more informative error messages in the BLE Scanner example
QMetaEnum helps us avoid writing separate strings for each error
description; it's not very verbose but it's way better than saying
that most of the errors are "unknown".

Change-Id: I61aaf3be6982a2987aabfa6be3192e1afb7df17a
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-08-21 07:52:19 +00:00
Alex Blasche 175dca8f8b Remove direct usage of QLowEnergyController::ctor
QLowEnergyController::createCentral() is the official API to do the same.

Change-Id: Idbd26d201b24add6697f6f9cdf1194511c160273
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-21 06:55:28 +00:00
Alex Blasche 322eb120c9 Add Qt 6 API todo
Change-Id: Ibc8a3e86b7671381c5a00f6421878961e8e2f4a6
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-21 06:53:42 +00:00
Qt Forward Merge Bot 05cad85003 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I3ea075969f9a9b8e94a34b3c7cd92aaea72175af
2018-08-18 03:00:07 +02:00