Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
bluetooth-overview.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\ingroup technology-apis
6\title Qt Bluetooth Overview
7\page qtbluetooth-overview.html
8\brief The Qt Bluetooth API enables connectivity with other regular Bluetooth
9 and Bluetooth Low Energy enabled devices.
10
11\tableofcontents
12
13 With the Qt Bluetooth API typical use cases are:
14
15 \list
16 \li Retrieve information about the local Bluetooth device.
17 \li Scan for other Bluetooth devices in range and retrieve information about them.
18 \li Push files to remote devices using the OBEX Object Push Profile (OPP)
19 \li Connect to remote devices through a RFCOMM channel using the Serial Port Profile (SPP).
20 \li Create a RFCOMM server that allows incoming connections using SPP.
21 \li Retrieve specification about Bluetooth Low Energy device.
22 \li Connect to Bluetooth Low Energy device.
23 \li Receive advertisement from Bluetooth Low Energy device.
24 \endlist
25
26 Note that the Object Push Profile is not supported on Android and Windows.
27
28 \note Parts of RFCOMM functionality cannot be configured by Qt on
29 Windows. A service's \l {QBluetoothServiceInfo::}{ServiceClassIds} and
30 \l {QBluetoothServiceInfo::}{ProtocolDescriptorList} are filled
31 automatically. Therefore, registering a service with custom values for
32 these fields might not yield the expected result on Windows.
33
34 \note The Received Signal Strength Indicator (RSSI), as well as
35 the Manufacturer Specific Data advertised by Bluetooth LE devices are
36 not supported by the Win32 backend. Also, it is only possible to find
37 devices that have been previously paired through Windows Settings.
38
39 The following sections describe how to use the Qt Bluetooth C++ API classes
40 for the above use cases.
41
42 \section1 Retrieving Local Device Information
43
44 The Qt Bluetooth API has three main purposes. The first one is to
45 obtain local and remote device information. The first steps in retrieving device information are
46 to check if Bluetooth is available on the device and read the local device address and name.
47 QBluetoothLocalDevice is the class that provides all of this information. Additionally you can use it
48 to turn Bluetooth on/off, set the visibility of the device and determine the current connections.
49
50 \snippet doc_src_qtbluetooth.cpp turningon
51
52 \section1 Scanning for Bluetooth Devices
53
54 Similar to the QBluetoothLocalDevice, the API offers QBluetoothDeviceInfo which provides
55 similar information for remote devices. Although you can just create QBluetoothDeviceInfo objects on
56 your own and fill them with data, the easier way is to use the QBluetoothDeviceDiscoveryAgent to
57 start an automated search for visible Bluetooth devices within the connectable range.
58
59 \snippet doc_src_qtbluetooth.cpp device_discovery
60
61 \section1 Exchanging Data Between Devices
62
63 The more flexible approach for communication between two Bluetooth enabled devices, is to
64 create a virtual serial port connection and freely exchange data over that connection. This can
65 be done by the Serial Port Profile (SPP). The Serial Port Profile emulates a serial connection
66 over the Bluetooth transport protocol RFCOMM.
67
68 To be able to receive incoming SPP connections, you need to listen to incoming connections using
69 \l QBluetoothServer.
70
71 \snippet btchat/chatserver.cpp Create the server
72
73 Connect to this server from another device playing the client role by using a
74 QBluetoothSocket:
75
76 \snippet btchat/chatclient.cpp startClient
77
78 Using such a connection allows to exchange any form of data in both directions.
79 It is perfectly suited for gaming or for syncing the state between two instances of
80 an application on two devices. For more detailed descriptions on how to configure the server
81 and client, please refer to the detailed description sections in the \l QBluetoothServer and
82 \l QBluetoothSocket classes. A good example to start with SPP is the \l{btchat}{Bluetooth Chat}
83 example.
84
85 \section1 Bluetooth Low Energy
86
87 Bluetooth Low Energy, also known as Bluetooth Smart, is a new technology enabling
88 devices with low energy consumption to communicate with each other. More details about
89 this technology and the related Qt APIs can be found in the \l {Bluetooth Low Energy Overview}.
90*/