1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qtbluetooth-index.html
7\brief Qt Bluetooth enables connectivity between Bluetooth enabled devices.
8\ingroup technology-apis
10The Bluetooth API provides connectivity between Bluetooth enabled devices.
12Currently, the API is supported on the following platforms:
17 \li \l {Qt for Android}{Android}
18 \li \l {Qt for iOS}{iOS}
19 \li \l {Qt for Linux/X11}{Linux (BlueZ 5.x)}
21 \li \l {Qt for Windows}{Windows}
30 \li Bluetooth LE Central
37 \li Bluetooth LE Peripheral
47Bluetooth is a short-range (less than 100 meters) wireless technology. It
48has a data transfer rate of 2.1 Mbps, which makes it ideal
49for transferring data between devices. Bluetooth connectivity is based on
50basic device management, such as scanning for devices, gathering information
51about them, and exchanging data between them.
53Qt Bluetooth supports Bluetooth Low Energy development for client/central role
54use cases. Further details can be found in the
55\l {Bluetooth Low Energy Overview}{Bluetooth Low Energy Overview} section.
57\section1 Using the Module
59\include {module-use.qdocinc} {using the c++ api}
61\section2 Building with CMake
63\include {module-use.qdocinc} {building with cmake} {Bluetooth}
65\section2 Building with qmake
67\include {module-use.qdocinc} {building_with_qmake} {bluetooth}
71Starting from Qt 6.6, the Qt Bluetooth module uses new \l QPermission API
72to handle \l {QBluetoothPermission}{Bluetooth} permissions. This means that Qt
73itself no longer queries for these permissions, so this needs to be done
74directly from the client application.
76Please refer to the \l {Application Permissions} page for an example of how
77to integrate the new \l QPermission API into the application.
79\section1 Related Information
81\section2 Building Qt Bluetooth
83Even though the module can be built for all Qt platforms, the module is not
84ported to all of them. Non-supported platforms employ a dummy backend that is
85automatically selected when the platform is not supported. The dummy backend
86reports appropriate error messages and values, which enables you to detect at
87runtime that the current platform is not supported. The dummy backend is also
88selected on Linux if BlueZ development headers are not found during build time
89or Qt was built without Qt D-Bus support.
91The usage of the dummy backend is highlighted via an appropriate warning while building and running.
93\section3 Linux Specific
95Since Qt 6.5 the Linux peripheral support has two backend alternatives:
96BlueZ DBus and Bluetooth kernel API. The Bluez DBus backend introduced in Qt 6.5 is
97intended as the eventual successor of the lower abstraction level kernel backend.
99The BlueZ DBus API is more limited in terms of features and is therefore not
100the default backend for compatibility reasons.
102The BlueZ DBus backend can be configured to use by setting
103the \e QT_BLUETOOTH_USE_DBUS_PERIPHERAL environment variable. The QLowEnergyController
104peripheral instantiation then introspects the presence of BlueZ DBus peripheral APIs
105on the local bluetooth adapter. The minimum version requirement for BlueZ is 5.56.
107One noteworthy difference is that with BlueZ DBus peripheral backend the user process no longer
108needs to have the \e CAP_NET_ADMIN capability (eg. run as root).
110\section3 \macos Specific
111The Bluetooth API on \macos requires a certain type of event dispatcher
112that in Qt causes a dependency to \l QGuiApplication. However, you can set the
113environment variable \c {QT_EVENT_DISPATCHER_CORE_FOUNDATION=1} to circumvent
116Applications that don't use Classic Bluetooth will find a subset of QtBluetooth
117is available, as CoreBluetooth (Bluetooth LE) don't require \l QApplication or
120\section2 Articles and Guides
122 \li \l {Qt Bluetooth Overview}{Classic Bluetooth Overview}
123 \li \l {Bluetooth Low Energy Overview}
128 \li \l {Qt Bluetooth C++ Classes}{C++ Classes}
131\section2 Logging Categories
133The \l QtBluetooth module exports the following
134\l {Configuring Categories}{logging categories}:
142 \li Enables logging of cross platform code path in QtBluetooth
144 \li qt.bluetooth.android
145 \li Enables logging of the \l {Qt for Android} {Android} implementation
147 \li qt.bluetooth.bluez
148 \li Enables logging of the BLuez/Linux implementation
151 \li Enables logging of the \l {Qt for iOS} {iOS} implementation
154 \li Enables logging of the \l {Qt for macOS} {macOS} implementation
156 \li qt.bluetooth.windows
157 \li Enables logging of the \l {Qt for Windows} {Windows} implementation
160Logging categories enable additional warning and debug output for QtBluetooth.
161More detailed information about logging is found in \l QLoggingCategory. A
162quick way to enable all QtBluetooth logging is to add the following line to the
166 QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
173 \li \l {heartrate-game}{Bluetooth Low Energy Heart Rate Game}
174 \li \l {heartrate-server}{Bluetooth Low Energy Heart Rate Server}
175 \li \l {lowenergyscanner}{Bluetooth Low Energy Scanner}
179 \li \l {btchat}{Bluetooth Chat}
183\section1 Module Evolution
185\l{Changes to Qt Bluetooth} lists important changes in the module
186API and functionality that were done for the Qt 6 series of Qt.
188\section1 Licenses and Attributions
190Qt Bluetooth is available under commercial licenses from \l{The Qt Company}.
191In addition, it is available under the
192\l{GNU Lesser General Public License, version 3}, or
193the \l{GNU General Public License, version 2}.
194See \l{Qt Licensing} for further details.
196On Linux, Qt Bluetooth uses a separate executable, \c sdpscanner,
197to integrate with the official Linux bluetooth protocol stack
198BlueZ. BlueZ is available under the \l{GNU General Public License,
201\generatelist{groupsbymodule attributions-qtbluetooth}