diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-07-12 07:57:09 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-07-12 08:07:34 +0200 |
commit | 60e6d4946b50bfa1d0916bdd3780b3c756a2bd6f (patch) | |
tree | bb4d88b83b392de143d25cef3c9fe8dd90f35cbe /src | |
parent | 0c028edf23de0073ba14115b43488a928c6fa492 (diff) | |
parent | d20e2e84ec2edd770c830fe2c399b4c76321d187 (diff) |
Merge remote-tracking branch 'gerrit/5.7' into dev
Change-Id: Id86ae2d8b9f8ebd2a37e8e5fc279916bc92d9982
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/bluetooth.pro | 2 | ||||
-rw-r--r-- | src/bluetooth/doc/qtbluetooth.qdocconf | 1 | ||||
-rw-r--r-- | src/bluetooth/doc/src/bluetooth-index.qdoc | 7 | ||||
-rw-r--r-- | src/bluetooth/doc/src/bluetooth-le-overview.qdoc | 56 | ||||
-rw-r--r-- | src/bluetooth/lecmaccalculator.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetooth.cpp | 1 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp | 4 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller.cpp | 23 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyservice.cpp | 1 |
9 files changed, 75 insertions, 22 deletions
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro index 3bca5496..2d29eb40 100644 --- a/src/bluetooth/bluetooth.pro +++ b/src/bluetooth/bluetooth.pro @@ -109,6 +109,7 @@ config_bluez:qtHaveModule(dbus) { message("Bluez version is too old to support Bluetooth Low Energy.") message("Only classic Bluetooth will be available.") DEFINES += QT_BLUEZ_NO_BTLE + include(dummy/dummy.pri) SOURCES += \ qlowenergycontroller_p.cpp } @@ -181,7 +182,6 @@ config_bluez:qtHaveModule(dbus) { include(osx/osxbt.pri) SOURCES += \ - qbluetoothdevicediscoveryagent_p.cpp \ qbluetoothlocaldevice_p.cpp \ qbluetoothserviceinfo_p.cpp \ qbluetoothservicediscoveryagent_p.cpp \ diff --git a/src/bluetooth/doc/qtbluetooth.qdocconf b/src/bluetooth/doc/qtbluetooth.qdocconf index 52061d7e..aa485cdb 100644 --- a/src/bluetooth/doc/qtbluetooth.qdocconf +++ b/src/bluetooth/doc/qtbluetooth.qdocconf @@ -47,6 +47,7 @@ exampledirs += ../../../examples/bluetooth \ snippets/ \ ../ +manifestmeta.thumbnail.names = "QtBluetooth/Bluetooth Low Energy Heart Rate Server Example" imagedirs += images diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc index 51c79ca4..f110179f 100644 --- a/src/bluetooth/doc/src/bluetooth-index.qdoc +++ b/src/bluetooth/doc/src/bluetooth-index.qdoc @@ -45,10 +45,13 @@ 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 5.5 contains the first full release of the new Qt Bluetooth -Low Energy API. Further details can be found in the +Qt Bluetooth supports Bluetooth Low Energy development for client/central role use cases. +Further details can be found in the \l {Bluetooth Low Energy Overview}{Bluetooth Low Energy Overview} section. +A new addition in this Qt Bluetooth 5.7 release covers support for Bluetooth Low Energy +applications performing the peripheral/server role. This new API is a Technology Preview. + \section1 Getting Started To use the C++ library in your application, add the following configuration diff --git a/src/bluetooth/doc/src/bluetooth-le-overview.qdoc b/src/bluetooth/doc/src/bluetooth-le-overview.qdoc index a6b8defa..8e78c487 100644 --- a/src/bluetooth/doc/src/bluetooth-le-overview.qdoc +++ b/src/bluetooth/doc/src/bluetooth-le-overview.qdoc @@ -168,19 +168,6 @@ Low Energy devices. The example code below is taken from the \l {heartlistener}{Heart Listener} and \l {heartrate-server}{Heart Rate Server} examples. - \section2 Advertising Services - - If we are implementing a GATT server application on a peripheral device, we need to define the - services we want to offer to central devices and advertise them: - - \snippet heartrate-server/main.cpp Advertising Data - \snippet heartrate-server/main.cpp Start Advertising - \snippet heartrate-server/main.cpp Advertising Data - - Now potential clients can connect to our device, discover the provided service and - register themselves to get notified of changes to the characteristic value. - This part of the API is covered in the following sections. - \section2 Establishing a Connection To be able to read and write the characteristics of the Bluetooth Low Energy peripheral device, @@ -257,4 +244,47 @@ Low Energy devices. \l {https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx}{Bluetooth SIG} whereas others may follow a custom protocol. The above code snippet demonstrates how to the read the standardized HeartRate value. + + \section2 Advertising Services + + If we are implementing a GATT server application on a peripheral device, we need to define the + services we want to offer to central devices and advertise them: + + \snippet heartrate-server/main.cpp Advertising Data + \snippet heartrate-server/main.cpp Start Advertising + + Now potential clients can connect to our device, discover the provided service and + register themselves to get notified of changes to the characteristic value. + This part of the API was already covered by the above sections. + + \section2 Implementing a Service on the Peripheral Device + + The first step is to define the service, its characteristics and descriptors. This is achieved + using the \l QLowEnergyServiceData, \l QLowEnergyCharacteristicData and + \l QLowEnergyDescriptorData classes. These classes act as containers or building blocks for the + essential information that comprises the to-be-defined Bluetooth Low Energy service. + The code snippet below defines a simple HeartRate service which publishes + the measured beats per minute. An example where such a service could be used is a wrist watch. + + \snippet heartrate-server/main.cpp Service Data + + The resulting \c serviceData object can be published as described in the + \l {Advertising Services} section above. Despite the partial information overlap between the + information wrapped by \l QLowEnergyServiceData and \l QLowEnergyAdvertisingData the two classes + serve two very different tasks. The advertising data is published to nearby devices and often + limited in scope due to its size restriction of 29 bytes. Therefore they are not always 100% + complete. By comparison the service data contained inside of \l QLowEnergyServiceData provides + the complete set of service data and only becomes visible to the connecting client when a + connection with an active service discovery has been performed. + + The next section demonstrates how the service can update the heart rate value. Depending on the + nature of the service it may have to comply with the official service definition + as defined on \l {https://www.bluetooth.org}. Other services may be completely custom. The + heart rate service was adopted and its specification can be found under + \l {https://www.bluetooth.com/specifications/adopted-specifications}. + + \snippet heartrate-server/main.cpp Provide Heartbeat + + In general characteristic and descriptor value updates on the peripheral device use the same + methods as connecting Bluetooth Low Energy devices. */ diff --git a/src/bluetooth/lecmaccalculator.cpp b/src/bluetooth/lecmaccalculator.cpp index 1cda9576..47fef7df 100644 --- a/src/bluetooth/lecmaccalculator.cpp +++ b/src/bluetooth/lecmaccalculator.cpp @@ -72,7 +72,7 @@ LeCmacCalculator::LeCmacCalculator() sa.salg_family = AF_ALG; strcpy(reinterpret_cast<char *>(sa.salg_type), "hash"); strcpy(reinterpret_cast<char *>(sa.salg_name), "cmac(aes)"); - if (bind(m_baseSocket, reinterpret_cast<sockaddr *>(&sa), sizeof sa) == -1) { + if (::bind(m_baseSocket, reinterpret_cast<sockaddr *>(&sa), sizeof sa) == -1) { qCWarning(QT_BT_BLUEZ) << "bind() failed for crypto socket:" << strerror(errno); return; } diff --git a/src/bluetooth/qbluetooth.cpp b/src/bluetooth/qbluetooth.cpp index 5e8b812a..483fe65a 100644 --- a/src/bluetooth/qbluetooth.cpp +++ b/src/bluetooth/qbluetooth.cpp @@ -76,6 +76,7 @@ namespace QBluetooth { /*! \enum QBluetooth::AttAccessConstraint + \since 5.7 This enum describes the possible requirements for reading or writing an ATT attribute. diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp index 85be8233..4c7b5234 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp @@ -42,9 +42,7 @@ #include "qbluetoothaddress.h" #include "qbluetoothuuid.h" -#ifndef QT_IOS_BLUETOOTH #include "dummy/dummy_helper_p.h" -#endif #define QT_DEVICEDISCOVERY_DEBUG @@ -59,9 +57,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate( q_ptr(parent) { Q_UNUSED(deviceAdapter); -#ifndef QT_IOS_BLUETOOTH printDummyWarning(); -#endif } QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate() diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp index eeff4ab0..c6cac44b 100644 --- a/src/bluetooth/qlowenergycontroller.cpp +++ b/src/bluetooth/qlowenergycontroller.cpp @@ -154,6 +154,7 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT) remote device. \value ClosingState The controller is about to be disconnected from the remote device. \value AdvertisingState The controller is currently advertising data. + This value was introduced by Qt 5.7. */ /*! @@ -259,6 +260,7 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT) the other side of the connection requested new parameters. The new values can be retrieved from \a newParameters. + \since 5.7 \sa requestConnectionUpdate() */ @@ -554,9 +556,11 @@ QLowEnergyController::QLowEnergyController( Returns a new object of this class that is in the \l CentralRole and has the parent object \a parent. The \a remoteDevice refers to the device that a connection will be established to later. - * + The controller uses the local default Bluetooth adapter for the connection management. + \sa QLowEnergyController::CentralRole + \since 5.7 */ QLowEnergyController *QLowEnergyController::createCentral(const QBluetoothDeviceInfo &remoteDevice, QObject *parent) @@ -571,7 +575,9 @@ QLowEnergyController *QLowEnergyController::createCentral(const QBluetoothDevice Typically, the next step is to call \l startAdvertising() on the returned object. The controller uses the local default Bluetooth adapter for the connection management. + \sa QLowEnergyController::PeripheralRole + \since 5.7 */ QLowEnergyController *QLowEnergyController::createPeripheral(QObject *parent) { @@ -815,6 +821,9 @@ QLowEnergyService *QLowEnergyController::createServiceObject( If this object is currently not in the \l UnconnectedState, nothing happens. \note Advertising will stop automatically once a client connects to the local device. + + \since 5.7 + \sa stopAdvertising() */ void QLowEnergyController::startAdvertising(const QLowEnergyAdvertisingParameters ¶meters, const QLowEnergyAdvertisingData &advertisingData, @@ -834,6 +843,9 @@ void QLowEnergyController::startAdvertising(const QLowEnergyAdvertisingParameter /*! Stops advertising, if this object is currently in the advertising state. + + \since 5.7 + \sa startAdvertising() */ void QLowEnergyController::stopAdvertising() { @@ -849,6 +861,8 @@ void QLowEnergyController::stopAdvertising() Constructs and returns a \l QLowEnergyService object with \a parent from \a service. The controller must be in the \l PeripheralRole and in the \l UnconnectedState. The \a service object must be valid. + + \since 5.7 \sa QLowEnergyServiceData::addIncludedService */ QLowEnergyService *QLowEnergyController::addService(const QLowEnergyServiceData &service, @@ -920,6 +934,8 @@ QLowEnergyService *QLowEnergyController::addService(const QLowEnergyServiceData with the actual new parameters. See the \l QLowEnergyConnectionParameters class for more information on connection parameters. \note Currently, this functionality is only implemented on Linux. + + \since 5.7 */ void QLowEnergyController::requestConnectionUpdate(const QLowEnergyConnectionParameters ¶meters) { @@ -949,6 +965,11 @@ QString QLowEnergyController::errorString() const /*! Returns the role that this controller object is in. + + The role is determined when constructing a QLowEnergyController instance + using \l createCentral() or \l createPeripheral(). + + \since 5.7 */ QLowEnergyController::Role QLowEnergyController::role() const { diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp index 1e5c363d..e9722f81 100644 --- a/src/bluetooth/qlowenergyservice.cpp +++ b/src/bluetooth/qlowenergyservice.cpp @@ -229,6 +229,7 @@ QT_BEGIN_NAMESPACE \value LocalService The service is associated with a controller object in the \l{QLowEnergyController::PeripheralRole}{peripheral role}. Such service objects do not change their state. + This value was introduced by Qt 5.7. */ /*! |