summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth
Commit message (Collapse)AuthorAgeFilesLines
* Examples: Use versioned CMake targets for Qt modulesKai Köhne2024-01-175-17/+17
| | | | | | | | | | Task-number: QTBUG-113277 Change-Id: I4885e6df894e24c2fdacccc4e58530ee9b190968 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 91c3e3dceaaaf27e7e92425e99f42898871fb6c1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit f87eb7401c50cf8fca61e49f06e1bfbb52964639)
* Doc: Tweak Qt Bluetooth example documentationKai Köhne2024-01-103-6/+10
| | | | | | | | | | | | Linkify Qt Bluetooth, and add tags. QtBluetooth will create a link to https://doc.qt.io/qt-6/qtbluetooth-module.html Change-Id: I9da8bda1591fae26fbe0bde7ac86371af4b9e71c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 619c20be1274778ff3a9344cd7f5b13f085bc956) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 7d458f96c45474ee20ca3c2f7aaf91a07427aeee)
* Update BTLE Heartrate Game example UIIvan Solovev2023-12-2132-177/+460
| | | | | | | | | | | | | | | | | | | | Improve the example according to the new design: * Apply new colors * Rework layouts to match the updated design * Use icons in the notification/error box * Apply new font sizes * Update screenshots in the docs, convert them to webp so that they do not take too much space. * Disable the Start button on the Measure tab if the device is not connected, or if the proper service is not discovered. * As a drive-by - fix the wording in the docs. Fixes: QTBUG-118905 Change-Id: I90669ea05c5c6b76eb711862c494f1180dbd8dd7 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 375e0e2c74adad9b609f5e48dffb88b07158bbfe) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit c3f69a2da4ee563f056eb0da52f0e8ae75a858db)
* Bluetooth Chat example: update UIIvan Solovev2023-11-2727-25/+160
| | | | | | | | | | | | | | | | | | | | | | | * Add some icons for Light and Dark themes. Implement switching between themes by listening to QStyleHints::colorSchemeChanged() signal and manually picking the proper icon. * Rework the desing to get rid of the unnecessary "Quit" button, and also change the layout of buttons in the connection dialog. * Update the screenshot in the documentation. As a drive-by fix, make sure that the cursor is always at the end of QTextEdit before showing a new message. The user can change the cursor position by clicking/selecting the text, and this could previously lead to some bugs in message visualization. Fixes: QTBUG-118875 Pick-to: 6.5 Change-Id: Ia3a9dec3dae0d1411643ed851eba0ab4dc96a47f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 6eb66322f0933de004baf35a96c5dd06d5d62ff6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* LowEnergyScanner example: migrate to QML Permission APIIvan Solovev2023-06-233-29/+46
| | | | | | | | | | | | | | | | | Update the example to use QML Permission API. This is not strictly necessary, because the example provides custom C++ wrappers around Qt Bluetooth classes, and the permission request was already conveniently implemented there. However, this example is a good candidate to show QML Permission API usage with Qt Bluetooth. That's the reason for the code update, as well as a documentation improvement. Fixes: QTBUG-114640 Change-Id: I3ffeb61a83c205724da8b462f930604e1adb26c0 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 92e095a4ff780145d91feae2be33184be4503b40) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QtBluetooth: use public QPermission API to check for permissions on AndroidIvan Solovev2023-05-033-2/+6
| | | | | | | | | | | | | | Now when we have the fine-grained public QBluetoothPermission API, we can use it to check for permissions in the Android implementation. Adapt QtBluetooth examples to use only the minimal required set of permissions. As a drive-by: fix a couple of qCWarning() strings. Task-number: QTBUG-109964 Change-Id: I55c67bcae27926e76bf9c1a8a9367af2b58883ff Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: Use the \examplecategory macro to tag examplesTopi Reinio2023-04-114-4/+4
| | | | | | | | | | | | | | | | The '\meta category' command was used for tagging examples with a specific category, used in Qt Creators Welcome mode. As we want to also generate lists of examples belonging to a category elsewhere in the documentation, replace the command with a macro that expands to the original \meta command and also adds the example to a group using the \ingroup command. This way, the category names can be used as arguments to the \generatelist or \annotatedlist commands. Pick-to: 6.5 Task-number: QTBUG-112731 Change-Id: I1df2d3bd6f2ef904ac7bac4d606b93d3824a802a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* BtChat: adapt to using new QBluetoothPermissionIvan Solovev2023-04-054-6/+54
| | | | | | | | Also add missing Info.plist files Task-number: QTBUG-109964 Change-Id: Icf1fdf1353898538ce42a27cb0b0cb01c0823e26 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* BtChat: fix a potential crash when deleting uninitialized pointerIvan Solovev2023-04-052-2/+1
| | | | | | | | | | Initialize ChatServer pointer to nullptr, and also remove an explicit delete call, because the pointer will be managed by Qt. Pick-to: 6.5 Change-Id: If1650a927e094a0b5349ecb6a8288531479ae1a5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* heartrate-game: use permission API to grant Bluetooth permissionTimur Pocheptsov2023-04-036-9/+77
| | | | | | Task-number: QTBUG-109964 Change-Id: Ic667c922f1d01d25a4eac8508481108d83f7a0af Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Fix .plist when building an example for iOS with CMakeJuha Vuolle2023-03-3011-137/+90
| | | | | | | | | | | | | | | | | | | | When building an example for iOS with qmake (qt-cmake -GXcode) the local Info.plists of three of the examples don't work, because they were using qmake substitutions (${EXECUTABLE_NAME} instead of ${MACOSX_BUNDLE_EXECUTABLE_NAME}), which resulted in "CFBundleExecutable is not specified". Instead use shared plist files, each for CMake and qmake. One of the removed files contained NSBluetoothPeripheralUsageDescription key, which I think can be discarded now; it is intended for iOS < 13, and the minimum for Qt 6 is 13. Pick-to: 6.5 Change-Id: I901dc176c001e25ce88d42b9456b6e16d8f43c20 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* HeartRate Game example: do not show duplicated devicesIvan Solovev2023-03-292-2/+13
| | | | | | | | | | | | The deviceDiscovered() signal can be emitted more than once for the same device, so implement a check before adding a device. This commit amends a1f43b9dcd722527d52ceb0c7a138bd2994c1a7b Task-number: QTBUG-111972 Pick-to: 6.5 Change-Id: Iff0a2b301d6d05090745ef97cedf5fab4532da7e Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* LowEnergyScanner example: allow stopping device discoveryIvan Solovev2023-03-294-27/+53
| | | | | | | | | | | | | ... and also show the newly-discovered devices as soon as they are discovered. This requires a more complex logic for updating the device list, because the deviceDiscovered() signal can be emitted multiple times for the same device. Task-number: QTBUG-111972 Pick-to: 6.5 Change-Id: I8e5f839ffb679516819d8f6063393d5a9b0ec840 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* HeartRate Game: QML revampIvan Solovev2023-03-2826-361/+383
| | | | | | | | | | | | | | | | This patch implements proper QML module registration for both CMake and qmake. It also tries to address all qmllint warnings, which results in a major refactoring, because the current approach with Loaders provides a lot of unqualified access warnings. The new approach uses StackLayout to switch between different pages. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Icc0122deebe63af16dd53c47690f2dc9fb88c919 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* HeartRate Game example: general clean-upIvan Solovev2023-03-2812-64/+81
| | | | | | | | | | | | | | | | | | | | | | | C++ code cleanup: * Fix include headers * Minor code-style improvements * Silence the warning about an uncreatable type by explicitly using QML_UNCREATABLE. We do not create the type in QML anyway. * Do not limit Windows platform to simulator mode. The example works perfectly on Windows. Build-system improvements: * Use qt_standard_project_setup() and PRIVATE linking in CMake Docs: * Add Connectivity category * Link to the documentation page which gives a full example overview Task-number: QTBUG-111972 Fixes: QTBUG-112194 Pick-to: 6.5 6.5.0 Change-Id: I6e50d1a3e9219afbf010d6471e8f7eb802c2ef00 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* HeartRate Server: revamp the exampleIvan Solovev2023-03-284-29/+44
| | | | | | | | | | | | | | | | | Some code clean-ups: * Use qt_standard_project_setup() and PRIVATE linking in CMake * Port away from QScopedPointer and use std::unique_ptr instead Documentation updates: * Add Connectivity category * Mention the new BlueZ D-Bus backend in the documentation * Small wording improvements * Provide more links to Qt classes and enums Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Id2a0ef48d3ce82f1784dd4b51f94236731730432 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* LowEnergyScanner example: refactor QML codeIvan Solovev2023-03-2817-156/+233
| | | | | | | | | | | | | | | | | | | | | | | | | Adapt the QML code to modern guidelines: * properly create a QML module in CMake and qmake * use versionless imports * convert the Device class to QML_SINGLETON instead of injecting it into the root context * use QQmlApplicationEngine::loadFromModule() to start the app The last change actually requires that we use Window instead of a Rectangle for the Main.qml page. This, in turn, breaks the pre-existing Loader logic, because every time we load the Main.qml page, a new window is created. Apart from that, we get unqualified access warnings from qmllint, because loader is accessed from every QML element, while it is only defined in the Main.qml. To fix that, we introduce a new page for device scan, and convert Main.qml to use StackLayout instead of a Loader to avoid unqualified access warnings. While on it, also fix other qmllint warnings and re-format the QML files. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Ia83cda08bf9547f5c2e335cb090c15d776f1b6ad Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* LowEnergyScanner example: general clean-upIvan Solovev2023-03-2810-84/+102
| | | | | | | | | | | | | | | | This patch introduces non-QML clean-ups to the example: * add Connectivity category to the docs * fix includes * consistently use Qt::StringLiterals * split some too long lines QML part requires a huge refactoring, which is done in a follow-up commit. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: I053b1c564d9dc2e05dfdb8879821615391e4be35 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Remove PingPong exampleIvan Solovev2023-03-2215-976/+1
| | | | | | | | | | | | The example contains a lot of rather complicated code, which is not directly related to the demonstrated Bluetooth features. Remove it in favor of BtChat example, which demonstrates the same Bluetooth features in a much more compact and understandable way. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Iccb2598fa6e88816697286b2252858f35a635ee5 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* BtChat example: document service lookupIvan Solovev2023-03-222-1/+34
| | | | | | | | | | | | Extend the documentation for BtChat example with a section describing remote service discovery. This allows to completely remove the PingPong example, because it does not show any new APIs compared to the BtChat example. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: I9328205b21fe750562c3510815aaa6c8d47640b1 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* BtScanner example: move to manual testsIvan Solovev2023-03-2114-687/+1
| | | | | | | | | | | | | | | | | | | | | | | The example mostly shows the usage of QBluetooth{Device,Service}DiscoveryAgent classes, which is also illustrated by other examples. Move it, because it's not fully functional on mobile platforms (because it's widget based). Do not remove it completely, because it might still be useful for doing Classic device scan. Also implement some improvements while on it: * fix CMakeLists.txt by using qt_standard_project_setup() and PRIVATE linking * fix memory leak in DeviceDiscoveryDialog * rework the code to use Qt parent-child model instead of manually deleting objects where possible * fix includes * fix forward declarations Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Ie4bc9e25ccdda6d5f5de2f57528df349c71cdc12 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* BtChat example: revamp documentationIvan Solovev2023-03-201-52/+67
| | | | | | | | | | | | | | | | * Remove 'Example' from the name * Add 'Connectivity' category * Consistently use \c for class and method names * Add some link to QBluetoothSocket's methods * Fix some typos As a drive-by: wrap lines at 80 characters in places where other changes were made to the docs. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Idbe34bde04510f7319d58e33ce52fd8324ddf868 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* BtChat example: improve codeIvan Solovev2023-03-2010-47/+54
| | | | | | | | | | | | | | | | | Improve the example code according to guidelines: * fix CMakeLists.txt by using qt_standard_project_setup() and PRIVATE linking * fix memory leak in Chat dialog * fix includes * fix forward declarations and do not use QT_USE_NAMESPACE * use Qt::StringLiterals * remove outdated warning for Windows platform * split too long lines Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: I81e472cfacf8c6adf97b31e97254797d40b01519 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Heartrate server: use permissions API to access BluetoothTimur Pocheptsov2023-03-034-9/+47
| | | | | | | | Add Bluetooth permission check/request to the heart-rate server's code. Task-number: QTBUG-109964 Change-Id: I7fc6a4cf6792e1aa223cc5dc4173963f995e305d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* btscanner sample - use permissions APITimur Pocheptsov2023-03-032-4/+34
| | | | | | | | Check and request a permission to use Bluetooth. Task-number: QTBUG-109964 Change-Id: I446f98fc15a2bd7bad97cff4a5937a43cc01e6dc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* lowenergyscanner: use permissions APITimur Pocheptsov2023-03-032-0/+26
| | | | | | | | | To explicitly handle Bluetooth permissions, not relying on QtBluetooth silently doing this under the hood. Task-number: QTBUG-109964 Change-Id: If8851e764bd0d06bddac815e8c8d1a88eb749438 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove empty black space from AndroidJani Korteniemi2023-01-091-0/+3
| | | | | | | | | Removed black space from example by puting example in fullscreen if using Android. Task-number: QTBUG-106408 Change-Id: I51204de38b5d7528fcc88e1c9944b45c891926d4 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* examples: port bluetooth examples to new connection styleSamuel Gaist2022-11-252-7/+9
| | | | | | Fixes: QTBUG-108846 Change-Id: I09bd69625a0841cea6a642a8195369bbe566aee8 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-064-5/+5
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I9ace956ba9ee596ddf820623957f2d476036c5ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-237-7/+7
| | | | | | | Task-number: QTBUG-105718 Change-Id: I8df2954bb61e0dc2a89f48c056b10a4bab395e0b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Doc: Wrap command line argument in \c{}Paul Wicking2022-08-181-1/+1
| | | | | | | | | Use correct text formatting; this also ensures the '--' part of the command line argument isn't converted to an en dash. Task-number: QTBUG-105729 Change-Id: I7df82e60e291b2bd28eb29b784110e0250bc12c0 Reviewed-by: Luca Di Sera <luca.disera@qt.io>
* Bluetooth heartrate-server: Handle errorsFriedemann Kleint2022-08-173-3/+18
| | | | | | | | | | | | Make it a console application and terminate on errors, printing a message. This prevents it from silently hanging, locking up the libraries, on Windows. Pick-to: 6.4 6.3 Change-Id: Ie7d022a2b193cf2c320cb918d35ce2ad52b2ac48 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* Bluetooth heartrate example: increase scan time and remove QML warningsJuha Vuolle2022-08-172-3/+3
| | | | | | | | | | | | Increase the time for device discovery as it often takes more than 5 seconds to find the devices. Introduce formal function parameters to QML signal handler functions to remove the related warnings. Pick-to: 6.3 6.4 Change-Id: I79589803a1c6082f02fa13a9e0044a7c03ef0daa Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Bluetooth heartrate-game example: Use modern QML registrationFriedemann Kleint2022-08-167-5/+32
| | | | | | | | | Use the modern macros and replace setContextProperty(). Pick-to: 6.4 6.3 Change-Id: If83f8a2dfab13e7c1b3dd18048f633c47709a7b3 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Bluetooth heartrate-game example: Make simulation switcheable by command ↵Friedemann Kleint2022-08-159-61/+74
| | | | | | | | | | line arguments Introduce QCommandLineParser for simulation and verbosity settings. Pick-to: 6.4 6.3 Change-Id: I00d01d2fa73db311944a2df68c6b116f0a31811b Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Bluetooth heartrate-game example: Basic polishFriedemann Kleint2022-08-1524-62/+67
| | | | | | | | | | | | - Reorder includes by module - Reorder Q_OBJECT macros - Use member initialization - Update copyright year - Remove QML import versions Pick-to: 6.4 6.3 Change-Id: I00a817c07bf50efcb9fed60372c374d34d138640 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-087-0/+21
| | | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: Ic31d264037cb00d72436d585820e45e4ccac5c60 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1069-3257/+152
| | | | | | | | | | | 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>
* Remove unsupported Android bluetooth codepathsJuha Vuolle2022-05-122-9/+6
| | | | | | | | | | | | | | | Minimum Android level supported on Qt 6 is Android 6 / API Level 23. This commit removes older unsupported code in order to simplify. This concerns primarily: - sdkVersion() checks - Java reflections (API availability was uncertain) Task-number: QTBUG-102497 Pick-to: 6.2 6.3 Change-Id: Ia90248a0a8f8e32130b8394998c2676c97a02eb5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Make bluetooth errors visible on pingpong example applicationJuha Vuolle2022-04-121-5/+10
| | | | | | | | | | | | | It's a bit misleading that the UI reports either that the scan is ongoing fine or that a service was simply not found when a discovery error has occurred. Similarly if the server fails to listen() it should be visible on the UI rather than the "server started, waiting" -message. Pick-to: 6.2 6.3 Change-Id: I455a253382f34c39d5cf4b8a45ff855983e3a6be Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Port simple cases of count() to size()Marc Mutz2022-04-111-1/+1
| | | | | | | | | | | | | | | The count() methods on QByteArray and QString are deprecated. The ones on other Qt containers will likely follow soon, so port them all to size(). The changes which also require int -> qsizetype will come in a follow-up patch. Pick-to: 6.3 Change-Id: I23e364019b9cfc457d93f4a3bb4660fe8d790da8 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add bluetooth example app Qt::Gui linkage on iOSJuha Vuolle2022-03-181-2/+2
| | | | | | | Fixes: QTBUG-101720 Pick-to: 6.3 Change-Id: I5d6e1e51ef73521390a3903b8ff1f225ea5dfa83 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Improve examples CMakeLists.txtKai Köhne2022-02-216-53/+26
| | | | | | | | | | | | | | | | - Remove automatic use of CMAKE_AUTORCC - Only opt into CMAKE_AUTOUIC if .ui files are involved - Remove explicit setting of CMAKE_INCLUDE_CURRENT_DIR - Combine multiple find_package(Qt6 ... calls) - use REQUIRED COMPONENTS - sort components alphabetically - Fix wrong indentations - Use (only) one empty line after multi-line commands Pick-to: 6.3 Change-Id: If1935beb09edd873c45842ae06d0f41267a9b36a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Avoid multiple client sockets in pingpong bluetooth exampleJuha Vuolle2022-02-121-2/+6
| | | | | | | | | | | | This commit guards against creating multiple client sockets if multiple services are found. In addition the service scanning is stopped when a service has been found and we start connecting a bluetooth socket. Fixes: QTBUG-100289 Pick-to: 5.15 6.2 6.3 Change-Id: Iac2e7eaca17a186ac2d2f62e338be16911f08032 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* btscanner example: Add option to stop a running scanOliver Wolff2022-01-263-2/+20
| | | | | Change-Id: Id82f6c903938e289559a79b4a2383ad20944c61a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* PingPong example: let the parent QObject do the cleanupIvan Solovev2022-01-211-2/+1
| | | | | | | | | | | | The m_timer and m_serverInfo instances are created using 'this' as a parent, so we do not need to explicitly delete them in the destructor, but let the parent object deal with them. This also prevents a crash at application close. Pick-to: 6.3 6.2 5.15 Change-Id: If91f01e1ab6dc8e839a06773464eeb9858d2fd36 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Store the serviceinfo in pingpong exampleJuha Vuolle2022-01-211-1/+1
| | | | | | | | | | | | | | The service info returned by the QBluetoothServer::listen() overload that returns it needs to be stored or otherwise it will be destroyed. The consequence was that the SDP "advertisement" didn't properly include the added pingpong service record on Windows. Task-number: QTBUG-100042 Pick-to: 6.2 6.3 5.15 Change-Id: I79cbd0f574e35bbc1c9c3123ce8382f3aad296d4 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Switch examples to build as isolated sub-buildsAlexandru Croitor2021-12-151-6/+6
| | | | | | | Pick-to: 6.2 6.3 Task-number: QTBUG-90820 Change-Id: Ife7b112e7a800460740f21a69d2ac85133bf0827 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* BtChat: fix crash when no adapter is foundIvan Solovev2021-11-161-2/+12
| | | | | | | | | | | | | | | | | The example was assuming that QBluetoothLocalDevice::allDevices() always returns a non-empty list. This is not true for the cases when desktop has no bluetooth adapters, as well as for WinRT implementation (it always returns empty list for now). This patch fixes the crash and provides some information messages to the console. Note that WinRT implementation has an extended warning, because it returns an empty list even if the adapter actually exists. Fixes: QTBUG-98323 Pick-to: 6.2 Change-Id: Iaa81465cf6be2febf20526c11909667fd60728b3 Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* macOS specific Info.plist file for Bluetooth ExamplesJuha Vuolle2021-11-1110-18/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | The default generated Info.plist is not enough as the Bluetooth examples require NSBluetoothAlwaysUsageDescription key to work. Without this patch on macOS 12 there are two possible outcomes: 1) If the example is built with qmake, the application will crash and the crash report will indicate that the key is missing 2) If the example is built with CMake, the application will not start as it tries to use iOS specific .plist file The patch uses absolute paths in the example CMakeLists.txt files to work around a Ninja bug: https://gitlab.kitware.com/cmake/cmake/-/issues/20181 Using relative paths resulted in "multiple rules generate" errors if the QtConnectivity module is built with examples. Note that the plist files are only effective if the application is started as an app bundle, ie. not if launching the contained binary directly. Pick-to: 6.2 Task-number: QTBUG-98090 Change-Id: Iedb7eabbb8fde6ad1ba14ada1a7ee87ec1d708ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>