aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtBluetooth.rst
blob: 96589675299fe2022099136041de33a725252ffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Qt Bluetooth enables connectivity between Bluetooth enabled devices.

The Bluetooth API provides connectivity between Bluetooth enabled devices.

Currently, the API is supported on the following platforms:

    +-------------------------------------+-------+---+-----------------+-----------------------------------------+--------------+
    |API Feature                          |Android|iOS|Linux (BlueZ 5.x)|:ref:`macOS<Qt-WebEngine-Platform-Notes>`|Qt for Windows|
    +-------------------------------------+-------+---+-----------------+-----------------------------------------+--------------+
    |Classic Bluetooth                    |x      |   |x                |x                                        |x             |
    +-------------------------------------+-------+---+-----------------+-----------------------------------------+--------------+
    |Bluetooth LE Central                 |x      |x  |x                |x                                        |x             |
    +-------------------------------------+-------+---+-----------------+-----------------------------------------+--------------+
    |Bluetooth LE Peripheral              |x      |x  |x                |x                                        |              |
    +-------------------------------------+-------+---+-----------------+-----------------------------------------+--------------+
    |Bluetooth LE Advertisement & Scanning|       |   |                 |                                         |              |
    +-------------------------------------+-------+---+-----------------+-----------------------------------------+--------------+

Qt 5.14 adds a native Win32 port supporting Classic Bluetooth on Windows 7 or
newer, and Bluetooth LE on Windows 8 or newer. It must be enabled at build time
by configuration option -native-win32-bluetooth. The UWP backend is used by
default if this option is not set and the Win32 target platform supports the
required UWP APIs (minimal requirement is Windows 10 version 1507, with
slightly improved service discovery since Windows 10 version 1607).

Overview
^^^^^^^^

Bluetooth is a short-range (less than 100 meters) wireless technology. It has a
reasonably high data transfer rate of 2.1 Mbit/s, which makes it ideal for
transferring data between devices. Bluetooth connectivity is based on basic
device management, such as scanning for devices, gathering information about
them, and exchanging data between them.

Qt Bluetooth supports Bluetooth Low Energy development for client/central role
use cases. Further details can be found in the :ref:`Bluetooth Low Energy
Overview<Bluetooth-Low-Energy-Overview>` section.

Using the Module
^^^^^^^^^^^^^^^^

To include the definitions of modules classes, use the following
directive:

::

    import PySide6.QtBluetooth

macOS Specific
^^^^^^^^^^^^^^

The Bluetooth API on macOS requires a certain type of event dispatcher that in
Qt causes a dependency to
:class:`QGuiApplication<PySide6.QtGui.QGuiApplication>` . However, you can set
the environment variable ``QT_EVENT_DISPATCHER_CORE_FOUNDATION=1`` to
circumvent this issue.

Applications that don't use Classic Bluetooth will find a subset of
`QtBluetooth`_ is available,
as CoreBluetooth (Bluetooth LE) do not require either of
:class:`QApplication<PySide6.QtWidgets.QApplication>` or
:class:`QGuiApplication<PySide6.QtGui.QGuiApplication>` .

Guides
^^^^^^

    * :ref:`Classic Bluetooth Overview<Qt-Bluetooth-Overview>`
    * :ref:`Bluetooth Low Energy Overview<Bluetooth-Low-Energy-Overview>`


Logging Categories
^^^^^^^^^^^^^^^^^^

The `QtBluetooth`_ module
exports the following :class:`logging categories<~.Configuring Categories>` :

    +--------------------+-------------------------------------------------------------+
    |Logging Category    |Description                                                  |
    +--------------------+-------------------------------------------------------------+
    |qt.bluetooth        |Enables logging of cross platform code path in `QtBluetooth`_|
    +--------------------+-------------------------------------------------------------+
    |qt.bluetooth.android|Enables logging of the Android implementation                |
    +--------------------+-------------------------------------------------------------+
    |qt.bluetooth.bluez  |Enables logging of the BLuez/Linux implementation            |
    +--------------------+-------------------------------------------------------------+
    |qt.bluetooth.ios    |Enables logging of the iOS implementation                    |
    +--------------------+-------------------------------------------------------------+
    |qt.bluetooth.osx    |Enables logging of the macOS implementation                  |
    +--------------------+-------------------------------------------------------------+
    |qt.bluetooth.windows|Enables logging of the Qt for Windows implementation         |
    +--------------------+-------------------------------------------------------------+

Logging categories can be used to enable additional warning and debug output
for `QtBluetooth`_ . More detailed information about logging can be found in
:class:`QLoggingCategory<~.QLoggingCategory>` . A quick way to enable all
`QtBluetooth`_ logging is to add the following line to the ``main()``
function::

    QLoggingCategory.setFilterRules("qt.bluetooth* = true")


.. _QtBluetooth: https://doc.qt.io/qt-6/qtbluetooth-module.html