summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/bluetooth/btscanner/service.cpp1
-rw-r--r--src/bluetooth/bluetooth.pro25
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp125
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.h6
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp1
-rw-r--r--src/bluetooth/qlowenergycharacteristicinfo.cpp214
-rw-r--r--src/bluetooth/qlowenergycharacteristicinfo.h107
-rw-r--r--src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp72
-rw-r--r--src/bluetooth/qlowenergycharacteristicinfo_p.cpp64
-rw-r--r--src/bluetooth/qlowenergycharacteristicinfo_p.h91
-rw-r--r--src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp77
-rw-r--r--src/bluetooth/qlowenergycontroller.cpp261
-rw-r--r--src/bluetooth/qlowenergycontroller.h104
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp475
-rw-r--r--src/bluetooth/qlowenergycontroller_p.cpp96
-rw-r--r--src/bluetooth/qlowenergycontroller_p.h99
-rw-r--r--src/bluetooth/qlowenergycontroller_qnx.cpp676
-rw-r--r--src/bluetooth/qlowenergydescriptorinfo.cpp172
-rw-r--r--src/bluetooth/qlowenergydescriptorinfo.h86
-rw-r--r--src/bluetooth/qlowenergydescriptorinfo_p.h65
-rw-r--r--src/bluetooth/qlowenergyprocess_bluez.cpp141
-rw-r--r--src/bluetooth/qlowenergyprocess_p.cpp68
-rw-r--r--src/bluetooth/qlowenergyprocess_p.h96
-rw-r--r--src/bluetooth/qlowenergyprocess_qnx.cpp94
-rw-r--r--src/bluetooth/qlowenergyservice.cpp1
-rw-r--r--src/bluetooth/qlowenergyserviceinfo.cpp9
-rw-r--r--src/bluetooth/qlowenergyserviceinfo.h3
-rw-r--r--src/bluetooth/qlowenergyserviceinfo_bluez.cpp5
-rw-r--r--src/bluetooth/qlowenergyserviceinfo_p.h8
-rw-r--r--src/bluetooth/qlowenergyserviceinfo_qnx.cpp14
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp70
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp5
-rw-r--r--tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp4
33 files changed, 6 insertions, 3329 deletions
diff --git a/examples/bluetooth/btscanner/service.cpp b/examples/bluetooth/btscanner/service.cpp
index e304f850..d24837eb 100644
--- a/examples/bluetooth/btscanner/service.cpp
+++ b/examples/bluetooth/btscanner/service.cpp
@@ -46,7 +46,6 @@
#include <qbluetoothserviceinfo.h>
#include <qbluetoothlocaldevice.h>
#include <qlowenergyserviceinfo.h>
-#include <qlowenergycharacteristicinfo.h>
#include <qbluetoothuuid.h>
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index 6b015229..74309891 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -25,12 +25,9 @@ PUBLIC_HEADERS += \
qbluetoothtransferrequest.h \
qlowenergyserviceinfo.h \
qlowenergyservice.h \
- qlowenergycharacteristicinfo.h \
qlowenergycharacteristic.h \
- qlowenergydescriptorinfo.h \
qlowenergydescriptor.h \
qbluetoothtransferreply.h \
- qlowenergycontroller.h \
qlowenergycontrollernew.h
PRIVATE_HEADERS += \
@@ -47,10 +44,6 @@ PRIVATE_HEADERS += \
qprivatelinearbuffer_p.h \
qbluetoothlocaldevice_p.h \
qlowenergyserviceinfo_p.h \
- qlowenergycharacteristicinfo_p.h \
- qlowenergyprocess_p.h \
- qlowenergydescriptorinfo_p.h \
- qlowenergycontroller_p.h \
qlowenergycontrollernew_p.h \
qlowenergyserviceprivate_p.h
@@ -71,11 +64,8 @@ SOURCES += \
qbluetoothtransferreply.cpp \
qlowenergyserviceinfo.cpp \
qlowenergyservice.cpp \
- qlowenergycharacteristicinfo.cpp \
qlowenergycharacteristic.cpp \
- qlowenergydescriptorinfo.cpp \
qlowenergydescriptor.cpp \
- qlowenergycontroller.cpp \
qlowenergycontrollernew.cpp \
qlowenergyserviceprivate.cpp
@@ -101,10 +91,7 @@ config_bluez:qtHaveModule(dbus) {
# old versions of Bluez do not have the required BTLE symbols
config_bluez_le {
SOURCES += \
- qlowenergyprocess_bluez.cpp \
qlowenergyserviceinfo_bluez.cpp \
- qlowenergycharacteristicinfo_bluez.cpp \
- qlowenergycontroller_bluez.cpp \
qlowenergycontrollernew_bluez.cpp
} else {
message("Bluez version is too old to support Bluetooth Low Energy.")
@@ -112,9 +99,6 @@ config_bluez:qtHaveModule(dbus) {
DEFINES += QT_BLUEZ_NO_BTLE
SOURCES += \
qlowenergyserviceinfo_p.cpp \
- qlowenergycharacteristicinfo_p.cpp \
- qlowenergyprocess_p.cpp \
- qlowenergycontroller_p.cpp \
qlowenergycontrollernew_p.cpp
}
@@ -141,10 +125,7 @@ config_bluez:qtHaveModule(dbus) {
qbluetoothsocket_qnx.cpp \
qbluetoothserver_qnx.cpp \
qbluetoothtransferreply_qnx.cpp \
- qlowenergycharacteristicinfo_qnx.cpp \
qlowenergyserviceinfo_qnx.cpp \
- qlowenergyprocess_qnx.cpp \
- qlowenergycontroller_qnx.cpp \
qlowenergycontrollernew_p.cpp
} else:android:!android-no-sdk {
@@ -168,9 +149,6 @@ config_bluez:qtHaveModule(dbus) {
qbluetoothsocket_android.cpp \
qbluetoothserver_android.cpp \
qlowenergyserviceinfo_p.cpp \
- qlowenergycharacteristicinfo_p.cpp \
- qlowenergyprocess_p.cpp \
- qlowenergycontroller_p.cpp \
qlowenergycontrollernew_p.cpp
} else {
@@ -184,9 +162,6 @@ config_bluez:qtHaveModule(dbus) {
qbluetoothsocket_p.cpp \
qbluetoothserver_p.cpp \
qlowenergyserviceinfo_p.cpp \
- qlowenergycharacteristicinfo_p.cpp \
- qlowenergyprocess_p.cpp \
- qlowenergycontroller_p.cpp \
qlowenergycontrollernew_p.cpp
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
index 7b1a6f2f..c27a59ee 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
@@ -41,7 +41,6 @@
#include "qbluetoothservicediscoveryagent.h"
#include "qbluetoothservicediscoveryagent_p.h"
-#include "qlowenergycharacteristicinfo_p.h"
#include "qlowenergyserviceinfo_p.h"
#include "bluez/manager_p.h"
@@ -710,130 +709,6 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
_q_serviceDiscoveryFinished();
}
-/*
- * Following three methods are implemented in this way to avoid blocking the main thread.
- * We first go through list of services path and then through services characteristics paths.
- *
- * Bluez v4.x does not have support for LE devices through org.bluez interfaces. Because of that
- * these functions will not be used now. I propose to leave them commented because in Bluez v5.x
- * we have support for LE devices and we can use these functions.
- */
-/*
-void QBluetoothServiceDiscoveryAgentPrivate::_g_discoveredGattService()
-{
-
- if (!gattServices.empty()) {
- qDebug() << gattServices.at(0) << gattServices.size();
- gattService = QLowEnergyServiceInfo(gattServices.at(0));
- gattService.getProperties();
- QObject::connect(gattService.d_ptr.data(), SIGNAL(finished()), this, SLOT(_g_discoveredGattService()));
- characteristic = new OrgBluezCharacteristicInterface(QLatin1String("org.bluez"), gattServices.at(0), QDBusConnection::systemBus());
- QDBusPendingReply<QList<QDBusObjectPath> > characterictisReply = characteristic->DiscoverCharacteristics();
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(characterictisReply, this);
- QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(_q_discoverGattCharacteristics(QDBusPendingCallWatcher*)));
-
- gattServices.removeFirst();
- q_ptr->lowEnergyServiceDiscovered(gattService);
- emit gattService.d_ptr->finished();
- }
- else
- q_ptr->finished();
-
-}
-
-void QBluetoothServiceDiscoveryAgentPrivate::_q_discoverGattCharacteristics(QDBusPendingCallWatcher *watcher)
-{
-
- QDBusPendingReply<QList<QDBusObjectPath> > characterictisReply = *watcher;
- if (characterictisReply.isError()){
- qDebug()<< "Discovering service characteristic error" << characterictisReply.error().message();
- Q_Q(QBluetoothServiceDiscoveryAgent);
- error = QBluetoothServiceDiscoveryAgent::UnknownError;
- errorString = characterictisReply.error().message();
- emit q->error(error);
- _q_serviceDiscoveryFinished();
- return;
- }
-
- foreach (const QDBusObjectPath &characteristicPath, characterictisReply.value())
- gattCharacteristics.append(characteristicPath.path());
- characteristic = new OrgBluezCharacteristicInterface(QLatin1String("org.bluez"), gattCharacteristics.at(0), QDBusConnection::systemBus());
- QDBusPendingReply<QVariantMap> characteristicProperty = characteristic->GetProperties();
- watcher = new QDBusPendingCallWatcher(characteristicProperty, this);
- _q_discoveredGattCharacteristic(watcher);
-
-}
-
-void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredGattCharacteristic(QDBusPendingCallWatcher *watcher)
-{
-
- QDBusPendingReply<QVariantMap> characteristicProperty = *watcher;
- //qDebug()<<characteristicProperty.value();
- if (characteristicProperty.isError()){
- qDebug() << "Characteristic properties error" << characteristicProperty.error().message();
- Q_Q(QBluetoothServiceDiscoveryAgent);
- error = QBluetoothServiceDiscoveryAgent::UnknownError;
- errorString = characteristicProperty.error().message();
- emit q->error(error);
- _q_serviceDiscoveryFinished();
- return;
- }
- QStringList serviceName;
-
- if (characteristicProperty.isError())
- qDebug()<<characteristicProperty.error().message();
-
- QVariantMap properties = characteristicProperty.value();
- QString name = properties.value(QLatin1String("Name")).toString();
- QString description = properties.value(QLatin1String("Description")).toString();
- serviceName = description.split(QStringLiteral(" "));
- QString charUuid = properties.value(QLatin1String("UUID")).toString();
- QBluetoothUuid characteristicUuid(charUuid);
-
- QVariant value = properties.value(QLatin1String("Value"));
- QByteArray byteValue = QByteArray();
- if (value.type() == QVariant::ByteArray)
- byteValue = value.toByteArray();
-
- //qDebug() << name << description << characteristicUuid.toString()<< byteValue.size();
- gattCharacteristic = QLowEnergyCharacteristicInfo(name, description, characteristicUuid, byteValue);
- gattCharacteristic.setPath(gattCharacteristics.at(0));
- qDebug() << gattCharacteristics.at(0);
- gattService.addCharacteristic(gattCharacteristic);
-
-
- //Testing part for setting the property
- QString b = "f000aa02-0451-4000-b000-000000000000";
- QBluetoothUuid u(b);
- if (gattCharacteristic.uuid() == u){
- for (int j = 0; j< byteValue.size(); j++){
- qDebug() << (int) byteValue.at(j);
- byteValue[j]=1;
- qDebug() << (int) byteValue.at(j);
- }
- bool s = gattCharacteristic.setPropertyValue(QStringLiteral("Value"), byteValue);
- qDebug() <<s;
- }
-
- QString serName = serviceName.at(0) + " Service";
-
- gattCharacteristics.removeFirst();
- if (gattCharacteristics.isEmpty()){
- q_ptr->lowEnergyServiceDiscovered(gattService);
- emit gattService.d_ptr->finished();
- }
- else{
- OrgBluezCharacteristicInterface *characteristicProperties = new OrgBluezCharacteristicInterface(QLatin1String("org.bluez"), gattCharacteristics.at(0), QDBusConnection::systemBus());
- QDBusPendingReply<QVariantMap> characteristicProperty = characteristicProperties->GetProperties();
- watcher = new QDBusPendingCallWatcher(characteristicProperty, this);
- QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(_q_discoveredGattCharacteristic(QDBusPendingCallWatcher*)));
- }
-
-}
-*/
-
QVariant QBluetoothServiceDiscoveryAgentPrivate::readAttributeValue(QXmlStreamReader &xml)
{
if (xml.name() == QLatin1String("boolean")) {
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
index b316998b..0377ce1a 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
@@ -55,7 +55,6 @@
class OrgBluezManagerInterface;
class OrgBluezAdapterInterface;
class OrgBluezDeviceInterface;
-class OrgBluezCharacteristicInterface;
class OrgFreedesktopDBusObjectManagerInterface;
QT_BEGIN_NAMESPACE
@@ -194,11 +193,6 @@ private:
OrgFreedesktopDBusObjectManagerInterface *managerBluez5;
OrgBluezAdapterInterface *adapter;
OrgBluezDeviceInterface *device;
- // variables below are used for discovering Bluetooth Low Energy devices
- OrgBluezCharacteristicInterface *characteristic;
- QStringList gattServices;
- QStringList gattCharacteristics;
- QLowEnergyCharacteristicInfo gattCharacteristic;
#endif
#ifdef QT_ANDROID_BLUETOOTH
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
index 81d2c623..a2abbebc 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
@@ -45,7 +45,6 @@
#include "qbluetoothdeviceinfo.h"
#include "qbluetoothdevicediscoveryagent.h"
-#include "qlowenergycharacteristicinfo_p.h"
#include "qlowenergyserviceinfo_p.h"
#include <QStringList>
diff --git a/src/bluetooth/qlowenergycharacteristicinfo.cpp b/src/bluetooth/qlowenergycharacteristicinfo.cpp
deleted file mode 100644
index c1df5e06..00000000
--- a/src/bluetooth/qlowenergycharacteristicinfo.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergycharacteristicinfo.h"
-#include "qlowenergycharacteristicinfo_p.h"
-#include <QHash>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QLowEnergyCharacteristicInfo
- \inmodule QtBluetooth
- \brief The QLowEnergyCharacteristicInfo class stores information about a Bluetooth
- Low Energy service characteristic.
-
- \since 5.4
-
- QLowEnergyCharacteristicInfo provides information about a Bluetooth Low Energy
- service characteristic's name, UUID, value, permissions, handle and descriptors.
- To get the full characteristic specification and information it is necessary to
- connect to the service using QLowEnergyServiceInfo and QLowEnergyController classes.
- Some characteristics can contain none, one or more descriptors.
-*/
-
-/*!
- \enum QLowEnergyCharacteristicInfo::PropertyType
-
- This enum describes the properties of a characteristic.
-
- \value Unknown The type is not known.
- \value Broadcasting Allow for the broadcasting of Generic Attributes (GATT) characteristic values.
- \value Read Allow the characteristic values to be read.
- \value WriteNoResponse Allow characteristic values without responses to be written.
- \value Write Allow for characteristic values to be written.
- \value Notify Permits notification of characteristic values.
- \value Indicate Permits indications of characteristic values.
- \value WriteSigned Permits signed writes of the GATT characteristic values.
- \value ExtendedProperty Additional characteristic properties are defined in the characteristic
- extended properties descriptor.
-
- \sa properties()
-*/
-
-/*!
- Construct a new QLowEnergyCharacteristicInfo.
-*/
-QLowEnergyCharacteristicInfo::QLowEnergyCharacteristicInfo():
- d_ptr(new QLowEnergyCharacteristicInfoPrivate)
-{
-
-}
-
-/*!
- Construct a new QLowEnergyCharacteristicInfo with given \a uuid.
-*/
-QLowEnergyCharacteristicInfo::QLowEnergyCharacteristicInfo(const QBluetoothUuid &uuid):
- d_ptr(new QLowEnergyCharacteristicInfoPrivate)
-{
- d_ptr->uuid = uuid;
-}
-
-/*!
- Construct a new QLowEnergyCharacteristicInfo that is a copy of \a other.
-
- The two copies continue to share the same underlying data which does not detach
- upon write.
-*/
-QLowEnergyCharacteristicInfo::QLowEnergyCharacteristicInfo(const QLowEnergyCharacteristicInfo &other):
- d_ptr(other.d_ptr)
-{
-
-}
-
-/*!
- Destroys the QLowEnergyCharacteristicInfo object.
-*/
-QLowEnergyCharacteristicInfo::~QLowEnergyCharacteristicInfo()
-{
-
-}
-
-/*!
- Returns the name of the gatt characteristic type.
-*/
-QString QLowEnergyCharacteristicInfo::name() const
-{
- return QBluetoothUuid::characteristicToString(
- static_cast<QBluetoothUuid::CharacteristicType>(d_ptr->uuid.toUInt16()));
-}
-
-/*!
- Returns the UUID of the gatt characteristic.
-*/
-QBluetoothUuid QLowEnergyCharacteristicInfo::uuid() const
-{
- return d_ptr->uuid;
-}
-
-/*!
- Returns the properties of the gatt characteristic.
-*/
-QLowEnergyCharacteristicInfo::PropertyTypes QLowEnergyCharacteristicInfo::properties() const
-{
- return d_ptr->properties;
-}
-
-/*!
- Returns value of the gatt characteristic.
-*/
-QByteArray QLowEnergyCharacteristicInfo::value() const
-{
- return d_ptr->value;
-}
-
-/*!
- Returns the handle of the gatt characteristic.
-*/
-QLowEnergyHandle QLowEnergyCharacteristicInfo::handle() const
-{
- return d_ptr->handle;
-}
-
-/*!
- Returns the true or false statement depending whether the characteristic is notification
- (enables conctant updates when value is changed on LE device).
-*/
-bool QLowEnergyCharacteristicInfo::isNotificationCharacteristic() const
-{
- return d_ptr->notification;
-}
-
-/*!
- Sets the value \a value of the characteristic. This only caches the value. To write
- a value directly to the device QLowEnergyController class must be used.
-
- \sa QLowEnergyController::writeCharacteristic()
-*/
-void QLowEnergyCharacteristicInfo::setValue(const QByteArray &value)
-{
- d_ptr->value = value;
-}
-
-/*!
- Makes a copy of the \a other and assigns it to this QLowEnergyCharacteristicInfo object.
- The two copies continue to share the same service and registration details.
-*/
-QLowEnergyCharacteristicInfo &QLowEnergyCharacteristicInfo::operator=(const QLowEnergyCharacteristicInfo &other)
-{
- d_ptr = other.d_ptr;
- return *this;
-}
-
-/*!
- Returns true if the QLowEnergyCharacteristicInfo object is valid, otherwise returns false.
- If it returns false, it means that service that this characteristic belongs was not connected.
-*/
-bool QLowEnergyCharacteristicInfo::isValid() const
-{
- if (d_ptr->uuid == QBluetoothUuid())
- return false;
- if (!d_ptr->handle)
- return false;
- if (!d_ptr->valid())
- return false;
- return true;
-}
-
-/*!
- Returns the list of characteristic descriptors.
-*/
-QList<QLowEnergyDescriptorInfo> QLowEnergyCharacteristicInfo::descriptors() const
-{
- return d_ptr->descriptorsList;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycharacteristicinfo.h b/src/bluetooth/qlowenergycharacteristicinfo.h
deleted file mode 100644
index 6d3d2187..00000000
--- a/src/bluetooth/qlowenergycharacteristicinfo.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOWENERGYCHARACTERISTICINFO_H
-#define QLOWENERGYCHARACTERISTICINFO_H
-#include <QtCore/QSharedPointer>
-#include <QtCore/QObject>
-#include <QtBluetooth/qbluetooth.h>
-#include <QtBluetooth/QBluetoothUuid>
-#include <QtBluetooth/QLowEnergyDescriptorInfo>
-
-QT_BEGIN_NAMESPACE
-
-class QBluetoothUuid;
-class QLowEnergyCharacteristicInfoPrivate;
-
-//TODO rename class to QLowEnergyCharacteristic
-class Q_BLUETOOTH_EXPORT QLowEnergyCharacteristicInfo
-{
- friend class QLowEnergyController;
- friend class QLowEnergyControllerPrivate;
-public:
-
- enum PropertyType {
- Unknown = 0x00,
- Broadcasting = 0x01,
- Read = 0x02,
- WriteNoResponse = 0x04,
- Write = 0x08,
- Notify = 0x10,
- Indicate = 0x20,
- WriteSigned = 0x40,
- ExtendedProperty = 0x80
- };
- Q_DECLARE_FLAGS(PropertyTypes, PropertyType)
-
- QLowEnergyCharacteristicInfo();
- QLowEnergyCharacteristicInfo(const QBluetoothUuid &uuid);
- QLowEnergyCharacteristicInfo(const QLowEnergyCharacteristicInfo &other);
- ~QLowEnergyCharacteristicInfo();
-
- QLowEnergyCharacteristicInfo &operator=(const QLowEnergyCharacteristicInfo &other);
-
- QString name() const;
-
- QBluetoothUuid uuid() const;
-
- void setValue(const QByteArray &value);
- QByteArray value() const;
-
- QLowEnergyCharacteristicInfo::PropertyTypes properties() const;
- QLowEnergyHandle handle() const;
-
- bool isNotificationCharacteristic() const;
-
- QList<QLowEnergyDescriptorInfo> descriptors() const;
-
- bool isValid() const;
-
-protected:
- QSharedPointer<QLowEnergyCharacteristicInfoPrivate> d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QLowEnergyCharacteristicInfo::PropertyTypes)
-
-QT_END_NAMESPACE
-
-#endif // QLOWENERGYCHARACTERISTICINFO_H
diff --git a/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp b/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp
deleted file mode 100644
index 2aba98c9..00000000
--- a/src/bluetooth/qlowenergycharacteristicinfo_bluez.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergycharacteristicinfo.h"
-#include "qlowenergycharacteristicinfo_p.h"
-#include "qlowenergyprocess_p.h"
-
-#include <QtDBus/QDBusPendingCallWatcher>
-
-//#define QT_LOWENERGYCHARACTERISTIC_DEBUG
-
-#ifdef QT_LOWENERGYCHARACTERISTIC_DEBUG
-#include <QtCore/QDebug>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate()
- : properties(QLowEnergyCharacteristicInfo::Unknown),
- notification (false), handle(0)
-{
-}
-
-QLowEnergyCharacteristicInfoPrivate::~QLowEnergyCharacteristicInfoPrivate()
-{
-}
-
-
-bool QLowEnergyCharacteristicInfoPrivate::valid()
-{
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycharacteristicinfo_p.cpp b/src/bluetooth/qlowenergycharacteristicinfo_p.cpp
deleted file mode 100644
index 30122b39..00000000
--- a/src/bluetooth/qlowenergycharacteristicinfo_p.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergycharacteristicinfo_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate()
- : properties(QLowEnergyCharacteristicInfo::Unknown),
- notification(false),
- handle(0)
-{
-
-}
-
-QLowEnergyCharacteristicInfoPrivate::~QLowEnergyCharacteristicInfoPrivate()
-{
-
-}
-
-
-bool QLowEnergyCharacteristicInfoPrivate::valid()
-{
- return false;
-}
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycharacteristicinfo_p.h b/src/bluetooth/qlowenergycharacteristicinfo_p.h
deleted file mode 100644
index 651be2aa..00000000
--- a/src/bluetooth/qlowenergycharacteristicinfo_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOWENERGYCHARACTERISTICINFO_P_H
-#define QLOWENERGYCHARACTERISTICINFO_P_H
-#include "qbluetoothuuid.h"
-#include "qlowenergycharacteristicinfo.h"
-
-#ifdef QT_BLUEZ_BLUETOOTH
-#include <QtDBus/QtDBus>
-#include <QObject>
-#endif
-#ifdef QT_QNX_BLUETOOTH
-#include <btapi/btdevice.h>
-#include <btapi/btgatt.h>
-#include <btapi/btspp.h>
-#include <btapi/btle.h>
-#endif
-#ifdef QT_BLUEZ_BLUETOOTH
-QT_FORWARD_DECLARE_CLASS(QLowEnergyProcess);
-#endif
-
-QT_BEGIN_NAMESPACE
-class QBluetoothUuid;
-class QLowEnergyCharacteristicInfo;
-
-class QLowEnergyCharacteristicInfoPrivate
-{
-public:
- QLowEnergyCharacteristicInfoPrivate();
- ~QLowEnergyCharacteristicInfoPrivate();
- bool valid();
-
- QString name;
- QBluetoothUuid uuid;
- QByteArray value;
- QLowEnergyCharacteristicInfo::PropertyType properties;
- bool notification;
- QLowEnergyHandle handle;
- int instance;
- QList<QLowEnergyDescriptorInfo> descriptorsList;
-#ifdef QT_QNX_BLUETOOTH
- bt_gatt_characteristic_t characteristic;
- int characteristicMtu;
- bt_gatt_char_prop_mask characteristicProperties;
-#endif
-
-private:
-
-};
-QT_END_NAMESPACE
-
-#endif // QLOWENERGYCHARACTERISTICINFO_P_H
diff --git a/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp b/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp
deleted file mode 100644
index cbe5bc5b..00000000
--- a/src/bluetooth/qlowenergycharacteristicinfo_qnx.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QLoggingCategory>
-#include "qlowenergycharacteristicinfo_p.h"
-#include <btapi/btdevice.h>
-#include <btapi/btgatt.h>
-#include <btapi/btle.h>
-#include <errno.h>
-#include "qlowenergyserviceinfo.h"
-#include "qlowenergyserviceinfo_p.h"
-#include "qlowenergydescriptorinfo_p.h"
-#include "qnx/ppshelpers_p.h"
-
-
-QT_BEGIN_NAMESPACE
-
-Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX)
-
-QLowEnergyCharacteristicInfoPrivate::QLowEnergyCharacteristicInfoPrivate()
- : properties(QLowEnergyCharacteristicInfo::Unknown),
- notification(false), handle(0), instance(-1)
-{
-
-}
-
-QLowEnergyCharacteristicInfoPrivate::~QLowEnergyCharacteristicInfoPrivate()
-{
-
-}
-
-bool QLowEnergyCharacteristicInfoPrivate::valid()
-{
- if (instance == -1)
- return false;
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp
deleted file mode 100644
index fb60e4df..00000000
--- a/src/bluetooth/qlowenergycontroller.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergycontroller.h"
-#include "qlowenergycontroller_p.h"
-#include "qlowenergyserviceinfo_p.h"
-#include "qlowenergycharacteristicinfo_p.h"
-
-QT_BEGIN_NAMESPACE
-/*!
- \class QLowEnergyController
- \inmodule QtBluetooth
- \brief The QLowEnergyController class is used for connecting and reading data from LE device
- services.
- \since 5.4
-
- To read data contained in LE service characteristics, the LE device must be paired and turned on.
- First, connect necessary signals from the class and then connect to service by passing the wanted service
- to \l connectToService() function. \l connected() signal will be emitted on success or \l error()
- signal in case of failure. It is possible to get error message by calling errorString function
- in QLowEnergyServiceInfo class.
-
- In case of disconnecting from service, pass the wanted service to \l disconnectFromService()
- function and \l disconnected() signal will be emitted.
-
- It is enough to use one instance of this class to connect to more service on more devices,
- but it is not possible to create more QLowEnergyController classes and connect to same
- service on the same LE device.
-
-
- \sa QLowEnergyServiceInfo, QLowEnergyCharacteristicInfo, QLowEnergyDescriptorInfo
-*/
-
-/*!
- \enum QLowEnergyController::Error
-
- Indicates all possible error conditions found during Bluetooth Low Energy communication.
-
- \value NoError No error has occurred.
- \value UnknownError An unknown error has occurred.
- \value InputOutputError BLE device is not responding.
- \value OperationError The error occurred while communicating with the BLE device
- (connecting, disconnecting, receiving updates,etc).
- \value PermissionError Characteristic does not have required permissions.
-*/
-
-/*!
- \fn void QLowEnergyController::connected(const QLowEnergyServiceInfo &info)
-
- This signal is emitted when the connection to the Bluetooth Low Energy service
- \a info was established.
-
- \sa disconnected(), connectToService()
-*/
-
-/*!
- \fn void QLowEnergyController::error(const QLowEnergyServiceInfo &info, QLowEnergyController::Error error)
-
- This signal is emitted when the service \a info triggered an \a error.
-
- \sa errorString()
-*/
-
-/*!
- \fn void QLowEnergyController::error(const QLowEnergyCharacteristicInfo &info, QLowEnergyController::Error error)
-
- This signal is emitted when the characteristic \a info triggered an \a error.
-
- \sa errorString()
-*/
-
-/*!
- \fn void QLowEnergyController::disconnected(const QLowEnergyServiceInfo &info)
-
- This signal is emitted when the connection to the Bluertooth Low Energy service \a info
- was severed.
-
- \sa connected(), disconnectFromService()
-*/
-
-/*!
- \fn QLowEnergyController::valueChanged(const QLowEnergyCharacteristicInfo &info)
-
- Emits a signal when the value of \a info has changed. This signal is only emitted
- once the \l enableNotifications() function was called.
-
- \sa enableNotifications()
-*/
-
-
-/*!
- Construct a new QLowEnergyController object with \a parent.
-*/
-QLowEnergyController::QLowEnergyController(QObject *parent)
- : QObject(parent), d_ptr(new QLowEnergyControllerPrivate)
-{
- d_ptr->q_ptr = this;
-}
-
-/*!
- Constructs a new QLowEnergyController for \a localAdapter and with \a parent.
-
- It uses \a localAdapter for the device connection. If \a localAdapter is default constructed
- the resulting object will use the local default Bluetooth adapter.
-*/
-QLowEnergyController::QLowEnergyController(const QBluetoothAddress &localAdapter, QObject *parent)
- : QObject(parent), d_ptr(new QLowEnergyControllerPrivate)
-{
- d_ptr->q_ptr = this;
- d_ptr->localAdapter = localAdapter;
-}
-
-/*!
- Destroys the QLowEnergyController instance.
-*/
-QLowEnergyController::~QLowEnergyController()
-{
-
-}
-
-/*!
- Returns the list of all Bluetooth Low Energy services managed by this controller instance.
-*/
-QList<QLowEnergyServiceInfo> QLowEnergyController::services() const
-{
- return d_ptr->m_leServices;
-}
-
-/*!
- Connects to the given \a leService. If the given service is not valid, or if
- the given service is already connected, nothing will happen.
-
-*/
-void QLowEnergyController::connectToService(const QLowEnergyServiceInfo &leService)
-{
- d_ptr->connectService(leService);
-}
-
-
-/*!
- Disconnects the given \a leService. If the given service was not connected, nothing will be done.
-
- If \a leService is invalid, all connected services will be disconnected.
-
-*/
-void QLowEnergyController::disconnectFromService(const QLowEnergyServiceInfo &leService)
-{
- d_ptr->disconnectService(leService);
-}
-
-
-/*!
- Enables receiving notifications from the given \a characteristic. If the service characteristic
- does not belong to one of the services or characteristic permissions do not allow notifications,
- the function will return false.
-*/
-bool QLowEnergyController::enableNotifications(const QLowEnergyCharacteristicInfo &characteristic)
-{
- return d_ptr->enableNotification(characteristic);
-}
-
-/*!
- Disables receiving notifications from the given \a characteristic. If the service characteristic
- does not belong to one of the services, nothing will be done.
-*/
-void QLowEnergyController::disableNotifications(const QLowEnergyCharacteristicInfo &characteristic)
-{
- d_ptr->disableNotification(characteristic);
-}
-
-/*!
- Returns a human-readable description of the last error that occurred.
-*/
-QString QLowEnergyController::errorString() const
-{
- return d_ptr->errorString;
-}
-
-/*!
- This method is called for the Linux platform if a device has a random device address that
- is used for connecting.
- */
-void QLowEnergyController::setRandomAddress()
-{
- d_ptr->m_randomAddress = true;
-}
-
-/*!
- This method writes \a characteristic using its current value. The value is directly written
- to the Bluetooth Low Energy device. If the service associated to \a characteristic is not
- connected or does not have write permission, the function returns \c false with
- a corresponding \l errorString() being set.
-
- \sa QLowEnergyCharacteristicInfo::setValue(), errorString(), error()
- */
-bool QLowEnergyController::writeCharacteristic(const QLowEnergyCharacteristicInfo &characteristic)
-{
- return d_ptr->write(characteristic);
-}
-
-/*!
- This method writes \a descriptor using its current value. The value is directly written
- to the Bluetooth Low Energy device. If the service associated to \a descriptor is not
- connected it returns \c false with a corresponding \l errorString() being set.
-
- \sa QLowEnergyDescriptorInfo::setValue(), errorString()
- */
-bool QLowEnergyController::writeDescriptor(const QLowEnergyDescriptorInfo &descriptor)
-{
- return d_ptr->write(descriptor);
-}
-
-/*!
- This method returns the last occurred error.
-
- \sa errorString()
- */
-QLowEnergyController::Error QLowEnergyController::error() const
-{
- return d_ptr->error;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller.h b/src/bluetooth/qlowenergycontroller.h
deleted file mode 100644
index 60400ada..00000000
--- a/src/bluetooth/qlowenergycontroller.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOWENERGYCONTROLLER_H
-#define QLOWENERGYCONTROLLER_H
-
-#include <QtCore/QObject>
-#include <QtBluetooth/qbluetoothglobal.h>
-#include <QtBluetooth/QBluetoothAddress>
-#include <QtBluetooth/QLowEnergyCharacteristicInfo>
-#include <QtBluetooth/QLowEnergyServiceInfo>
-#include <QtBluetooth/QLowEnergyDescriptorInfo>
-
-QT_BEGIN_NAMESPACE
-
-class QLowEnergyControllerPrivate;
-
-class Q_BLUETOOTH_EXPORT QLowEnergyController: public QObject
-{
- Q_OBJECT
-public:
- enum Error {
- NoError,
- UnknownError,
- OperationError,
- InputOutputError,
- PermissionError
- };
- QLowEnergyController(QObject *parent = 0);
- QLowEnergyController(const QBluetoothAddress &localAdapter, QObject *parent = 0);
- ~QLowEnergyController();
-
- QList<QLowEnergyServiceInfo> services() const;
-
- void connectToService(const QLowEnergyServiceInfo &leService);
- void disconnectFromService(const QLowEnergyServiceInfo &leService = QLowEnergyServiceInfo());
-
- bool enableNotifications(const QLowEnergyCharacteristicInfo &characteristic);
- void disableNotifications(const QLowEnergyCharacteristicInfo &characteristic);
-
- bool writeCharacteristic(const QLowEnergyCharacteristicInfo &characteristic);
- bool writeDescriptor(const QLowEnergyDescriptorInfo &descriptor);
-
- QString errorString() const;
-
- void setRandomAddress();
- Error error() const;
-
-Q_SIGNALS:
- void connected(const QLowEnergyServiceInfo &);
- void error(const QLowEnergyServiceInfo &, QLowEnergyController::Error);
- void error(const QLowEnergyCharacteristicInfo &, QLowEnergyController::Error);
- void disconnected(const QLowEnergyServiceInfo &);
- void valueChanged(const QLowEnergyCharacteristicInfo &);
-
-private:
- Q_DECLARE_PRIVATE(QLowEnergyController)
- QLowEnergyControllerPrivate *d_ptr;
-#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
- Q_PRIVATE_SLOT(d_func(), void _q_replyReceived(const QString &reply))
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif // QLOWENERGYCONTROLLER_H
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
deleted file mode 100644
index 09922de6..00000000
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ /dev/null
@@ -1,475 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtBluetooth/QBluetoothLocalDevice>
-#include "qlowenergycontroller.h"
-#include "qlowenergycontroller_p.h"
-#include "qlowenergyserviceinfo_p.h"
-#include "qlowenergycharacteristicinfo_p.h"
-#include "qlowenergyprocess_p.h"
-#include "qlowenergydescriptorinfo.h"
-#include "qlowenergydescriptorinfo_p.h"
-#include "moc_qlowenergycontroller.cpp"
-
-QT_BEGIN_NAMESPACE
-
-Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ)
-
-QLowEnergyControllerPrivate::QLowEnergyControllerPrivate():
- error(QLowEnergyController::NoError), m_randomAddress(false), m_step(0), m_commandStarted(false)
-{
-
-}
-
-QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
-{
-
-}
-
-void QLowEnergyControllerPrivate::connectService(const QLowEnergyServiceInfo &service)
-{
- errorString = QString();
- service.d_ptr->characteristicList.clear();
- bool add = true;
- for (int i = 0; i < m_leServices.size(); i++) {
- if (m_leServices.at(i).serviceUuid() == service.serviceUuid()) {
- m_leServices.replace(i, service);
- add = false;
- break;
- }
- }
- if (add)
- m_leServices.append(service);
- process = process->instance();
- if (!process->isConnected()) {
- if (m_commandStarted)
- connectToTerminal();
- else {
- QObject::connect(process, SIGNAL(replySend(const QString &)), q_ptr, SLOT(_q_replyReceived(const QString &)));
- if (localAdapter.isNull()) {
- QBluetoothLocalDevice localDevice;
- localAdapter = localDevice.address();
- }
- QString command = QStringLiteral("gatttool -i ") + localAdapter.toString()
- + QStringLiteral(" -b ")
- + service.d_ptr->deviceInfo.address().toString()
- + QStringLiteral(" -I");
- if (m_randomAddress)
- command += QStringLiteral(" -t random");
- qCDebug(QT_BT_BLUEZ) << "[REGISTER] uuid inside: " << service.d_ptr->uuid << command;
- process->startCommand(command);
- m_commandStarted = true;
- }
- process->addConnection();
- }
- else
- service.d_ptr->m_step = 1;
-}
-
-void QLowEnergyControllerPrivate::disconnectService(const QLowEnergyServiceInfo &service)
-{
- if (service.isValid()) {
- for (int i = 0; i < m_leServices.size(); i++) {
- if (m_leServices.at(i).serviceUuid() == service.serviceUuid() && service.isConnected()) {
- process = process->instance();
- process->endProcess();
- m_leServices.at(i).d_ptr->connected = false;
- m_leServices.at(i).d_ptr->m_step = 0;
- m_leServices.at(i).d_ptr->m_valueCounter = 0;
- m_leServices.removeAt(i);
- emit q_ptr->disconnected(service);
- break;
- }
- }
- }
- else
- disconnectAllServices();
-}
-
-void QLowEnergyControllerPrivate::_q_replyReceived(const QString &reply)
-{
- qCDebug(QT_BT_BLUEZ) << "reply: " << reply;
- // STEP 0
- if (m_step == 0 && !m_leServices.isEmpty())
- connectToTerminal();
- if (reply.contains(QStringLiteral("Connection refused (111)"))) {
- errorString = QStringLiteral("Connection refused (111)");
- error = QLowEnergyController::InputOutputError;
- disconnectAllServices();
- }
- else if (reply.contains(QStringLiteral("Device busy"))) {
- errorString = QStringLiteral("Device busy");
- error = QLowEnergyController::InputOutputError;
- disconnectAllServices();
- }
- else if (reply.contains(QStringLiteral("disconnected"))) {
- errorString = QStringLiteral("Trying to execute command on disconnected service");
- error = QLowEnergyController::OperationError;
- disconnectAllServices();
- }
- else {
- // STEP 1 -> connect
- if (reply.contains(QStringLiteral("[CON]"))) {
- for (int i = 0; i < m_leServices.size(); i++) {
- if (m_leServices.at(i).d_ptr->m_step == 1) {
- setHandles();
- m_leServices.at(i).d_ptr->m_step++;
- }
- }
- }
-
- // STEP 2 -> primary
- if (reply.contains(QStringLiteral("attr")) && reply.contains(QStringLiteral("uuid"))){
- const QStringList handles = reply.split(QStringLiteral("\n"));
- foreach (const QString &handle, handles) {
- if (handle.contains(QStringLiteral("attr")) && handle.contains(QStringLiteral("uuid"))) {
- const QStringList handleDetails = handle.split(QRegularExpression(QStringLiteral("[\\s+|,]")),
- QString::SkipEmptyParts);
- Q_ASSERT(handleDetails.count() == 9);
- const QBluetoothUuid foundUuid(handleDetails.at(8));
- for (int i = 0; i < m_leServices.size(); i++) {
- if (foundUuid == m_leServices.at(i).serviceUuid() && m_leServices.at(i).d_ptr->m_step == 2) {
- m_leServices.at(i).d_ptr->startingHandle = handleDetails.at(2);
- m_leServices.at(i).d_ptr->endingHandle = handleDetails.at(6);
- setCharacteristics(i);
- }
- }
- }
- }
- }
-
- // STEP 3 -> "characteristics startHandle endHandle"
- if (reply.contains(QStringLiteral("char")) && reply.contains(QStringLiteral("uuid")) && reply.contains(QStringLiteral("properties"))) {
- const QStringList handles = reply.split(QStringLiteral("\n"));
- int stepSet = -1;
- foreach (const QString& handle, handles) {
- if (handle.contains(QStringLiteral("char")) && handle.contains(QStringLiteral("uuid"))) {
- const QStringList handleDetails = handle.split(QRegularExpression(QStringLiteral("[\\s+|,]")),
- QString::SkipEmptyParts);
- Q_ASSERT(handleDetails.count() == 11);
- const QString charHandle = handleDetails.at(8);
- QLowEnergyHandle charHandleId = charHandle.toUShort(0, 0);
- for (int i = 0; i < m_leServices.size(); i++) {
- if ( charHandleId >= m_leServices.at(i).d_ptr->startingHandle.toUShort(0,0) &&
- charHandleId <= m_leServices.at(i).d_ptr->endingHandle.toUShort(0,0))
- {
- const QBluetoothUuid charUuid(handleDetails.at(10));
-
- QLowEnergyCharacteristicInfo charInfo(charUuid);
- charInfo.d_ptr->handle = charHandleId;
- charInfo.d_ptr->properties =
- static_cast<QLowEnergyCharacteristicInfo::PropertyType>(
- handleDetails.at(4).toUShort(0,0));
- if (!(charInfo.d_ptr->properties & QLowEnergyCharacteristicInfo::Read))
- qCDebug(QT_BT_BLUEZ) << "GATT characteristic: Read not permitted: " << charInfo.d_ptr->uuid;
- else
- m_leServices.at(i).d_ptr->m_readCounter++;
- m_leServices.at(i).d_ptr->characteristicList.append(charInfo);
- stepSet = i;
- break;
- }
- }
- }
- }
- if ( stepSet != -1)
- readCharacteristicValue(stepSet);
- }
-
- // STEP 4 and STEP 5 -> char-read-uuid
- // This part is for reading characteristic values and setting the notifications
- if (reply.contains(QStringLiteral("handle")) && reply.contains(QStringLiteral("value")) && !reply.contains(QStringLiteral("char"))) {
- int index = -1; // setting characteristics values
- int index1 = -1; // setting notifications and descriptors
- for (int i = 0; i < m_leServices.size(); i++) {
- if (m_leServices.at(i).d_ptr->m_step == 4)
- index = i;
- if (m_leServices.at(i).d_ptr->m_step == 5)
- index1 = i;
- }
- const QStringList handles = reply.split(QStringLiteral("\n"));
- bool lastStep = false;
- foreach (const QString &handle, handles) {
- if (handle.contains(QStringLiteral("handle")) &&
- handle.contains(QStringLiteral("value")))
- {
- const QStringList handleDetails = handle.split(QRegularExpression(QStringLiteral("\\W+")), QString::SkipEmptyParts);
- if (index != -1) {
- if (!m_leServices.at(index).d_ptr->characteristicList.isEmpty()) {
- for (int j = 0; j < m_leServices.at(index).d_ptr->characteristicList.size(); j++) {
- const QLowEnergyCharacteristicInfo chars = m_leServices.at(index).d_ptr->characteristicList.at(j);
- const QLowEnergyHandle handleId = handleDetails.at(1).toUShort(0, 0);
- qCDebug(QT_BT_BLUEZ) << QString::number(handleId, 16) << handleId
- << chars.handle() << QString::number(chars.handle(), 16);
- if (handleId == chars.handle()) {
- QString value;
- for ( int k = 3; k < handleDetails.size(); k++)
- value = value + handleDetails.at(k);
- m_leServices.at(index).d_ptr->characteristicList[j].d_ptr->value = value.toUtf8();
- qCDebug(QT_BT_BLUEZ) << "Characteristic value set." << m_leServices.at(index).d_ptr->characteristicList[j].uuid()
- << hex << chars.d_ptr->handle << value;
- m_leServices.at(index).d_ptr->m_valueCounter++;
- }
- }
- }
- if (m_leServices.at(index).d_ptr->m_valueCounter == m_leServices.at(index).d_ptr->m_readCounter) {
- setNotifications();
- m_leServices.at(index).d_ptr->m_step++;
- }
- }
- if (index1 != -1) {
- QLowEnergyServiceInfo service = m_leServices.at(index1);
- for (int j = 0; j < service.d_ptr->characteristicList.size()-1; j++) {
- QLowEnergyCharacteristicInfo chars = service.d_ptr->characteristicList.at(j);
- QLowEnergyCharacteristicInfo charsNext = service.d_ptr->characteristicList.at(j+1);
- const QLowEnergyHandle handleId = handleDetails.at(1).toUShort(0, 0);
- qCDebug(QT_BT_BLUEZ) << hex << handleId << hex << chars.handle();
-
- if (handleId > chars.handle() && handleId < charsNext.handle()) {
- chars.d_ptr->notification = true;
- QLowEnergyDescriptorInfo descriptor(
- service.d_ptr->characteristicList[j].uuid(),
- QBluetoothUuid::ClientCharacteristicConfiguration,
- handleId);
- QString val;
- //TODO why do we start parsing value from k = 0? Shouldn't it be k = 2
- for (int k = 3; k < handleDetails.size(); k++)
- val = val + handleDetails.at(k);
- descriptor.d_ptr->m_value = val.toUtf8();
- service.d_ptr->characteristicList[j].d_ptr->descriptorsList.append(descriptor);
- qCDebug(QT_BT_BLUEZ) << "Notification characteristic set."
- << hex << chars.d_ptr->handle
- << handleId;
- }
- }
- if (!lastStep) {
- service.d_ptr->m_step++;
- service.d_ptr->connected = true;
- emit q_ptr->connected(service);
- }
- lastStep = true;
- }
- }
- }
- }
-
- // READING ADVERTISEMENT FROM THE BLE DEVICE
- if (reply.contains(QStringLiteral("Notification handle"))) {
- QStringList update, row;
- update = reply.split(QStringLiteral("\n"));
- for (int i = 0; i< update.size(); i ++) {
- if (update.at(i).contains(QStringLiteral("Notification handle"))) {
- row = update.at(i).split(QRegularExpression(QStringLiteral("\\W+")), QString::SkipEmptyParts);
- for (int j = 0; j < m_leServices.size(); j++) {
- for (int k = 0; k < m_leServices.at(j).characteristics().size(); k++) {
- if (m_leServices.at(j).characteristics().at(k).handle() == row.at(2).toUShort(0, 0)) {
-
- QString notificationValue = QStringLiteral("");
- for (int s = 4 ; s< row.size(); s++)
- notificationValue += row.at(s);
- m_leServices.at(j).characteristics().at(k).d_ptr->value = notificationValue.toUtf8();
- emit q_ptr->valueChanged(m_leServices.at(j).characteristics().at(k));
- }
- }
- }
- }
-
- }
- }
- }
-}
-
-void QLowEnergyControllerPrivate::disconnectAllServices()
-{
- for (int i = 0; i < m_leServices.size(); i++) {
- process = process->instance();
- process->endProcess();
- m_leServices.at(i).d_ptr->m_step = 0;
- m_leServices.at(i).d_ptr->m_valueCounter = 0;
- if (m_leServices.at(i).isConnected()) {
- m_leServices.at(i).d_ptr->connected = false;
- emit q_ptr->disconnected(m_leServices.at(i));
- }
- if (error != QLowEnergyController::NoError)
- emit q_ptr->error(m_leServices.at(i), error);
- m_step = 0;
- }
- m_leServices.clear();
-}
-
-void QLowEnergyControllerPrivate::connectToTerminal()
-{
- process->executeCommand(QStringLiteral("connect"));
- for (int i = 0; i < m_leServices.size(); i++)
- m_leServices.at(i).d_ptr->m_step = 1;
- m_step++;
-}
-
-void QLowEnergyControllerPrivate::setHandles()
-{
- process->executeCommand(QStringLiteral("primary"));
- m_step++;
-}
-
-void QLowEnergyControllerPrivate::setCharacteristics(int a)
-{
- const QString command = QStringLiteral("characteristics ") + m_leServices.at(a).d_ptr->startingHandle
- + QStringLiteral(" ") + m_leServices.at(a).d_ptr->endingHandle;
- process->executeCommand(command);
- m_leServices.at(a).d_ptr->m_step++;
-}
-
-void QLowEnergyControllerPrivate::setNotifications()
-{
- // TODO at the moment we only search for 2902 descriptors
- // it doesn't show all 2902's and we leave a lot of other descriptors out
- process->executeCommand(QStringLiteral("char-read-uuid 2902"));
-}
-
-void QLowEnergyControllerPrivate::readCharacteristicValue(int index)
-{
- bool charReadRequested = false;
-
- QLowEnergyServiceInfo info = m_leServices.at(index);
- for (int i = 0; i < info.d_ptr->characteristicList.size(); i++) {
- if ((info.d_ptr->characteristicList.at(i).d_ptr->properties & QLowEnergyCharacteristicInfo::Read)) {
- const QString uuidHandle = info.d_ptr->characteristicList.at(i).uuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));
- const QString command = QStringLiteral("char-read-uuid ") + uuidHandle;
- process->executeCommand(command);
- charReadRequested = true;
- }
- }
- info.d_ptr->m_step++;
-
- // Sometimes the service doesn't have readable characteristics
- // Finish service connect request
- if (!charReadRequested) {
- info.d_ptr->connected = true;
- emit q_ptr->connected(info);
- }
-}
-
-void QLowEnergyControllerPrivate::writeValue(QLowEnergyHandle handle, const QByteArray &value)
-{
- process = process->instance();
- QString command = QStringLiteral("char-write-req ") + QString::number(handle, 16)
- + QStringLiteral(" ")
- + QString::fromLocal8Bit(value.constData());
- process->executeCommand(command);
-}
-
-bool QLowEnergyControllerPrivate::enableNotification(const QLowEnergyCharacteristicInfo &characteristic)
-{
- const QBluetoothUuid descUuid((ushort)0x2902);
- for (int i = 0; i < m_leServices.size(); i++) {
- for (int j = 0; j < m_leServices.at(i).characteristics().size(); j++) {
- if (m_leServices.at(i).characteristics().at(j).uuid() == characteristic.uuid()) {
- for (int k = 0; k < m_leServices.at(i).characteristics().at(j).descriptors().size(); k++) {
- if (m_leServices.at(i).characteristics().at(j).descriptors().at(k).uuid() == descUuid){
- QByteArray val;
- val.append(48);
- val.append(49);
- val.append(48);
- val.append(48);
- writeValue(m_leServices.at(i).characteristics().at(j).descriptors().at(k).handle(), val);
- return true;
- }
- }
- }
- }
- }
- error = QLowEnergyController::UnknownError;
- errorString = QStringLiteral("Characteristic or notification descriptor not found.");
- emit q_ptr->error(characteristic, error);
- return false;
-}
-
-void QLowEnergyControllerPrivate::disableNotification(const QLowEnergyCharacteristicInfo &characteristic)
-{
- const QBluetoothUuid descUuid((ushort)0x2902);
- for (int i = 0; i < m_leServices.size(); i++) {
- for (int j = 0; j < m_leServices.at(i).characteristics().size(); j++) {
- if (m_leServices.at(i).characteristics().at(j).uuid() == characteristic.uuid()) {
- for (int k = 0; k < m_leServices.at(i).characteristics().at(j).descriptors().size(); k++) {
- if (m_leServices.at(i).characteristics().at(j).descriptors().at(k).uuid() == descUuid){
- QByteArray val;
- val.append(48);
- val.append(48);
- val.append(48);
- val.append(48);
- writeValue(m_leServices.at(i).characteristics().at(j).descriptors().at(k).handle(), val);
- }
- }
- }
- }
- }
-}
-
-bool QLowEnergyControllerPrivate::write(const QLowEnergyCharacteristicInfo &characteristic)
-{
- if (process->isConnected() && characteristic.isValid()) {
- if (QLowEnergyCharacteristicInfo::Write & characteristic.properties()) {
- writeValue(characteristic.handle(), characteristic.value());
- return true;
- } else {
- error = QLowEnergyController::PermissionError;
- errorString = QStringLiteral("This characteristic does not support write operations.");
- }
- } else {
- error = QLowEnergyController::OperationError;
- errorString = QStringLiteral("The device is not connected or characteristic is not valid");
- }
-
- emit q_ptr->error(characteristic, error);
- return false;
-}
-
-bool QLowEnergyControllerPrivate::write(const QLowEnergyDescriptorInfo &descriptor)
-{
- if (process->isConnected()) {
- writeValue(descriptor.handle(), descriptor.value());
- return true;
- }
-
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller_p.cpp b/src/bluetooth/qlowenergycontroller_p.cpp
deleted file mode 100644
index 07d58fdd..00000000
--- a/src/bluetooth/qlowenergycontroller_p.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergycontroller_p.h"
-#include "moc_qlowenergycontroller.cpp"
-
-QT_BEGIN_NAMESPACE
-
-QLowEnergyControllerPrivate::QLowEnergyControllerPrivate():
- error(QLowEnergyController::NoError)
-{
-
-}
-
-QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
-{
-
-}
-
-void QLowEnergyControllerPrivate::connectService(const QLowEnergyServiceInfo &service)
-{
- Q_UNUSED(service);
-}
-
-void QLowEnergyControllerPrivate::disconnectService(const QLowEnergyServiceInfo &leService)
-{
- Q_UNUSED(leService);
-}
-
-void QLowEnergyControllerPrivate::disconnectAllServices()
-{
-
-}
-
-bool QLowEnergyControllerPrivate::enableNotification(const QLowEnergyCharacteristicInfo &characteristic)
-{
- Q_UNUSED(characteristic);
- return false;
-}
-
-void QLowEnergyControllerPrivate::disableNotification(const QLowEnergyCharacteristicInfo &characteristic)
-{
- Q_UNUSED(characteristic);
-}
-
-bool QLowEnergyControllerPrivate::write(const QLowEnergyCharacteristicInfo &characteristic)
-{
- Q_UNUSED(characteristic);
- return false;
-}
-
-bool QLowEnergyControllerPrivate::write(const QLowEnergyDescriptorInfo &descriptor)
-{
- Q_UNUSED(descriptor);
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller_p.h b/src/bluetooth/qlowenergycontroller_p.h
deleted file mode 100644
index 92d06f36..00000000
--- a/src/bluetooth/qlowenergycontroller_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QLOWENERGYCONTROLLER_P_H
-#define QLOWENERGYCONTROLLER_P_H
-#include "qlowenergycontroller.h"
-
-QT_BEGIN_NAMESPACE
-
-class QLowEnergyProcess;
-
-class QLowEnergyControllerPrivate
-{
- Q_DECLARE_PUBLIC(QLowEnergyController)
-public:
- QLowEnergyControllerPrivate();
- ~QLowEnergyControllerPrivate();
- void connectService(const QLowEnergyServiceInfo &service);
- void disconnectService(const QLowEnergyServiceInfo &leService = QLowEnergyServiceInfo());
- bool enableNotification(const QLowEnergyCharacteristicInfo &characteristic);
- void disableNotification(const QLowEnergyCharacteristicInfo &characteristic);
- bool write(const QLowEnergyCharacteristicInfo &characteristic);
- bool write(const QLowEnergyDescriptorInfo &descriptor);
- void disconnectAllServices();
-
- QList<QLowEnergyServiceInfo> m_leServices;
- QString errorString;
- QLowEnergyController::Error error;
-
-#ifdef QT_QNX_BLUETOOTH
- static void serviceConnected(const char*, const char*, int, int, short unsigned int, short unsigned int, short unsigned int, void*);
- static void serviceUpdate(const char *, int , short unsigned int, short unsigned int, short unsigned int, void *);
- static void serviceDisconnected(const char *, const char *, int, int, void *);
- static void serviceNotification(int, short unsigned int, const char unsigned *, short unsigned int, void *);
- void readDescriptors(QLowEnergyCharacteristicInfo &characteristic);
- void readValue(QLowEnergyCharacteristicInfo &characteristic);
- void writeValue(const int &instance, QLowEnergyHandle handle, const QByteArray &value);
-#endif
-
-#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
- void connectToTerminal();
- void setHandles();
- void setCharacteristics(int);
- void setNotifications();
- void readCharacteristicValue(int);
- void writeValue(QLowEnergyHandle, const QByteArray &);
-public slots:
- void _q_replyReceived(const QString &reply);
-#endif
-private:
- bool m_randomAddress;
- QLowEnergyProcess *process;
- QBluetoothAddress localAdapter;
-#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
- int m_step;
- bool m_deviceConnected;
- bool m_commandStarted;
-#endif
- QLowEnergyController *q_ptr;
-};
-QT_END_NAMESPACE
-#endif // QLOWENERGYCONTROLLER_P_H
diff --git a/src/bluetooth/qlowenergycontroller_qnx.cpp b/src/bluetooth/qlowenergycontroller_qnx.cpp
deleted file mode 100644
index df2e8b3b..00000000
--- a/src/bluetooth/qlowenergycontroller_qnx.cpp
+++ /dev/null
@@ -1,676 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QLoggingCategory>
-#include "qlowenergycontroller_p.h"
-#include "qlowenergyserviceinfo_p.h"
-#include "qlowenergycharacteristicinfo.h"
-#include "qlowenergycharacteristicinfo_p.h"
-#include "qlowenergydescriptorinfo.h"
-#include "qlowenergydescriptorinfo_p.h"
-#include "qlowenergyprocess_p.h"
-#include <btapi/btdevice.h>
-#include <btapi/btgatt.h>
-#include <btapi/btspp.h>
-#include <btapi/btle.h>
-#include <errno.h>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-
-Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX)
-
-int hexValue(QChar inChar)
-{
- if (inChar.isDigit())
- return (inChar.unicode() - '0');
- else
- return (inChar.toUpper().unicode() - 'A' + 10);
- return -1;
-}
-
-int stringToBuffer(const QString &stringData, quint8 *buffer, int bufferLength)
-{
- int consumed = 0;
- for (int i = 0; i < bufferLength; i++) {
- const int hex = hexValue(stringData.at(i).toLatin1());
- if (hex >= 0) {
- if ((consumed % 2) == 0) {
- buffer[(consumed / 2)] = hex << 4;
- } else {
- buffer[(consumed / 2)] |= hex;
- }
-
- consumed++;
- }
- }
-
- // Round up the number of bytes we consumed to a multiple of 2.
- if ((consumed % 2) != 0)
- ++consumed;
-
- return consumed;
-}
-
-void QLowEnergyControllerPrivate::serviceConnected(const char *bdaddr, const char *service, int instance,
- int err, short unsigned int connInt, short unsigned int latency,
- short unsigned int superTimeout, void *userData)
-{
- Q_UNUSED(latency);
- Q_UNUSED(connInt);
- Q_UNUSED(superTimeout);
- QSharedPointer<QLowEnergyControllerPrivate> *classPointer =
- static_cast<QSharedPointer<QLowEnergyControllerPrivate> *>(userData);
- QLowEnergyControllerPrivate *p = classPointer->data();
-
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] (instance):" << instance;
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] Device address: " << bdaddr;
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] Device service: " << service;
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] Possible error: " << err;
-
- QString lowEnergyUuid = QLatin1String(service);
- QBluetoothUuid leUuid;
-
- //In case of custom UUIDs (e.g. Texas Instruments SenstorTag LE Device)
- if (lowEnergyUuid.length() > 6) {
- lowEnergyUuid.remove(0,2);
- leUuid = QBluetoothUuid(lowEnergyUuid);
- } else { // Official UUIDs are presented in 6 characters (for instance 0x180A)
- leUuid = QBluetoothUuid(lowEnergyUuid.toUShort(0,0));
- }
- qCDebug(QT_BT_QNX) << leUuid;
-
- int index = -1;
- for (int i = 0; i < p->m_leServices.size(); i++) {
- if (p->m_leServices.at(i).serviceUuid() == leUuid) {
- index = i;
- break;
- }
- }
-
- if (err != 0) {
- qCDebug(QT_BT_QNX) << "An error occurred in service connected callback: " << qt_error_string(err);
- p->error = QLowEnergyController::OperationError;
- p->errorString = qt_error_string(err);
- Q_EMIT p->q_ptr->error(p->m_leServices.at(index), p->error);
- }
- if (index != -1) {
- p->m_leServices.at(index).d_ptr->characteristicList.clear();
- bt_gatt_characteristic_t* data;
- data = (bt_gatt_characteristic_t*) malloc(sizeof(bt_gatt_characteristic_t));
- if (!data) {
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] GATT characteristics: Not enough memory";
- bt_gatt_disconnect_instance(instance);
- p->error = QLowEnergyController::OperationError;
- p->errorString = QStringLiteral("GATT characteristics: Not enough memory");
- Q_EMIT p->q_ptr->error(p->m_leServices.at(index), p->error);
- return;
- }
-
- int num_characteristics = bt_gatt_characteristics_count(instance);
-
- if (num_characteristics > -1) {
- qCDebug(QT_BT_QNX) << "Characteristics number: "<< num_characteristics;
- bt_gatt_characteristic_t *allCharacteristicList;
-
- allCharacteristicList = (bt_gatt_characteristic_t*) malloc(num_characteristics * sizeof(bt_gatt_characteristic_t));
- if (!allCharacteristicList) {
- qCDebug(QT_BT_QNX) <<" GATT characteristics: Not enough memory";
- bt_gatt_disconnect_instance(instance);
- p->error = QLowEnergyController::OperationError;
- p->errorString = QStringLiteral("GATT characteristics: Not enough memory");
- Q_EMIT p->q_ptr->error(p->m_leServices.at(index), p->error);
- return;
- }
-
- /* BEGIN WORKAROUND - Temporary fix to address race condition */
- int number = 0;
- do {
- number = bt_gatt_characteristics(instance, allCharacteristicList, num_characteristics);
- } while ((number == -1) && (errno == EBUSY));
- //Using sub to subscribe notification callback only once
- bool sub = false;
- int characteristicListSize = number;
-
- for (int i = 0; i < characteristicListSize; i++) {
- qCDebug(QT_BT_QNX) << "Characteristic: uuid,handle,value_handle, properties:"
- << allCharacteristicList[i].uuid << "," << allCharacteristicList[i].handle
- << "," << allCharacteristicList[i].value_handle
- << ", " << allCharacteristicList[i].properties;
- QString charUuid = QString::fromLatin1(allCharacteristicList[i].uuid);
- QBluetoothUuid characteristicUuid;
- if (!charUuid.toUShort(0,0)) {
- charUuid = charUuid.remove(0,2);
- characteristicUuid = QBluetoothUuid(charUuid);
- } else {
- characteristicUuid = QBluetoothUuid(charUuid.toUShort(0,0));
- }
- QLowEnergyCharacteristicInfo characteristicInfo(characteristicUuid);
- characteristicInfo.d_ptr->handle = allCharacteristicList[i].value_handle;
- characteristicInfo.d_ptr->instance = instance;
- characteristicInfo.d_ptr->characteristic = allCharacteristicList[i];
- characteristicInfo.d_ptr->properties =
- static_cast<QLowEnergyCharacteristicInfo::PropertyType>(
- allCharacteristicList[i].properties);
- p->readDescriptors(characteristicInfo);
- p->readValue(characteristicInfo);
- //Subscribe only once since it is static function
- if (!sub) {
- int rc = bt_gatt_reg_notifications(instance, &(p->serviceNotification));
- if (!rc) {
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] bt_gatt_reg_notifications failed." << errno << qt_error_string(errno);
- p->error = QLowEnergyController::OperationError;
- p->errorString = qt_error_string(errno);
- Q_EMIT p->q_ptr->error(p->m_leServices.at(index), p->error);
- } else {
- qCDebug(QT_BT_QNX) << "[SERVICE: Connected] bt_gatt_reg_notifications was presumably OK";
- }
- sub = true;
- }
- p->m_leServices.at(index).d_ptr->characteristicList.append(characteristicInfo);
-
- }
-
- if (!allCharacteristicList) {
- free(allCharacteristicList);
- allCharacteristicList = 0;
- }
-
- /* END WORKAROUND */
- }
-
- p->m_leServices.at(index).d_ptr->connected = true;
-
- qCDebug(QT_BT_QNX) << p;
- Q_EMIT p->q_ptr->connected(p->m_leServices.at(index));
- qCDebug(QT_BT_QNX) << "---------------------------------------------------------------------------------";
- } else {
- qCDebug(QT_BT_QNX) << "Unregistered service connected";
- }
-}
-
-void QLowEnergyControllerPrivate::serviceNotification(int instance, short unsigned int handle,
- const unsigned char*val, short unsigned int len, void *userData)
-{
- if (!val)
- return;
- QSharedPointer<QLowEnergyControllerPrivate> *ClassPointer
- = static_cast<QSharedPointer<QLowEnergyControllerPrivate> *>(userData);
- QLowEnergyControllerPrivate *p = ClassPointer->data();
-
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
- qCDebug(QT_BT_QNX) << "[Notification] received (handle, value, instance):" << handle << val << instance;
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
-
- //Check if the notification from wanted characteristic
- bool current = false;
- QLowEnergyCharacteristicInfo chars;
- for (int i = 0; i < p->m_leServices.size(); i++) {
- for (int j = 0; j < p->m_leServices.at(i).characteristics().size(); j++) {
-
-// QString charHandle;
-// charHandle.setNum(handle);
-// charHandle = charHandle;
- if (handle == p->m_leServices.at(i).d_ptr->characteristicList.at(j).handle() ) {
- chars = QLowEnergyCharacteristicInfo(p->m_leServices.at(i).d_ptr->characteristicList.at(j));
- QByteArray receivedValue;
-
- for (int k = 0; k < len; k++) {
- QByteArray hexadecimal;
- hexadecimal.append(val[k]);
- receivedValue.append(hexadecimal.toHex());
- }
-
- p->m_leServices.at(i).d_ptr->characteristicList.at(j).d_ptr->notification = true;
- p->m_leServices.at(i).d_ptr->characteristicList.at(j).d_ptr->value = receivedValue;
- Q_EMIT p->q_ptr->valueChanged(p->m_leServices.at(i).d_ptr->characteristicList.at(j));
- current = true;
- }
- }
- }
-
- if (!current)
- qCDebug(QT_BT_QNX) << "Notificiation received and does not belong to this characteristic.";
-}
-
-void QLowEnergyControllerPrivate::serviceUpdate(const char *bdaddr, int instance,
- short unsigned int connInt, short unsigned int latency,
- short unsigned int superTimeout, void *userData)
-{
- Q_UNUSED(latency);
- Q_UNUSED(connInt);
- Q_UNUSED(superTimeout);
- Q_UNUSED(userData);
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
- qCDebug(QT_BT_QNX) << "[SERVICE: Update] (instance):" << instance;
- qCDebug(QT_BT_QNX) << "[SERVICE: Update] Device address: " << bdaddr;
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
-}
-
-void QLowEnergyControllerPrivate::serviceDisconnected(const char *bdaddr, const char *service,
- int instance, int reason, void *userData)
-{
- QSharedPointer<QLowEnergyControllerPrivate> *classPointer = static_cast<QSharedPointer<QLowEnergyControllerPrivate> *>(userData);
- QLowEnergyControllerPrivate *p = classPointer->data();
- QString lowEnergyUuid = QLatin1String(service);
- qCDebug(QT_BT_QNX) << "LE Service: " << lowEnergyUuid << service;
- QBluetoothUuid leUuid;
-
- //In case of custom UUIDs (e.g. Texas Instruments SenstorTag LE Device)
- if ( lowEnergyUuid.length() > 4 ) {
- leUuid = QBluetoothUuid(lowEnergyUuid);
- }
- else {// Official UUIDs are presented in 4 characters (for instance 180A)
- lowEnergyUuid = QStringLiteral("0x") + lowEnergyUuid;
- leUuid = QBluetoothUuid(lowEnergyUuid.toUShort(0,0));
- }
- QLowEnergyServiceInfo leService(leUuid);
- Q_EMIT p->q_ptr->connected(leService);
-
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
- qCDebug(QT_BT_QNX) << "[SERVICE: Disconnect] (service, instance, reason):" << service << instance << reason;
- qCDebug(QT_BT_QNX) << "[SERVICE: Disconnect] Device address: " << bdaddr;
- qCDebug(QT_BT_QNX) << "---------------------------------------------------";
- delete p;
- delete classPointer;
-}
-
-QLowEnergyControllerPrivate::QLowEnergyControllerPrivate():
- error(QLowEnergyController::NoError)
-{
- qRegisterMetaType<QLowEnergyServiceInfo>("QLowEnergyServiceInfo");
- qRegisterMetaType<QLowEnergyCharacteristicInfo>("QLowEnergyCharacteristicInfo");
-}
-
-QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
-{
-
-}
-
-void QLowEnergyControllerPrivate::connectService(const QLowEnergyServiceInfo &service)
-{
- Q_Q(QLowEnergyController);
- if (!service.isValid()) {
- error = QLowEnergyController::UnknownError;
- errorString = QStringLiteral("Service not valid.");
- Q_EMIT q->error(service, error);
- return;
- }
-
- bool add = true;
- for (int i = 0; i < m_leServices.size(); i++) {
- if (m_leServices.at(i).serviceUuid() == service.serviceUuid()) {
- if (m_leServices.at(i).isConnected()) {
- error = QLowEnergyController::OperationError;
- errorString = QStringLiteral("Service already connected");
- Q_EMIT q->error(m_leServices.at(i), error);
- }
- else {
- m_leServices.replace(i, service);
- add = false;
- break;
- }
- }
- }
- if (add)
- m_leServices.append(service);
-
- bt_gatt_callbacks_t gatt_callbacks = {&(this->serviceConnected), this->serviceDisconnected, this->serviceUpdate};
-
- errno = 0;
- process = process->instance();
- if (!process->isConnected()) {
- qCDebug(QT_BT_QNX) << "[INIT] Init problem." << errno << qt_error_string(errno);
- error = QLowEnergyController::InputOutputError;
- errorString = QStringLiteral("Initialization of device falied. ") + qt_error_string(errno);
- Q_EMIT q->error(service, error);
- return;
- }
-
- errno = 0;
- if (bt_gatt_init(&gatt_callbacks) < 0) {
- qCDebug(QT_BT_QNX) << "[INIT] GAT Init problem." << errno << qt_error_string(errno);
- error = QLowEnergyController::UnknownError;
- errorString = QStringLiteral("Callbacks initialization failed. ") + qt_error_string(errno);
- Q_EMIT q->error(service, error);
- return;
- }
- if (bt_le_init(0) != EOK) {
- qWarning() << "LE initialization failure " << errno;
- }
-
- QSharedPointer<QLowEnergyControllerPrivate> *classPointer = new QSharedPointer<QLowEnergyControllerPrivate>(this);
- process->addPointer(classPointer->data());
- QString serviceUuid = service.serviceUuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));
- if (service.serviceName() == QStringLiteral("Unknown Service"))
- serviceUuid = QStringLiteral("0x") + serviceUuid.toUpper();
- else
- serviceUuid = QStringLiteral("0x") + serviceUuid[4] + serviceUuid[5] + serviceUuid[6] + serviceUuid[7];
- errno = 0;
-
- bt_gatt_conn_parm_t conParm;
- conParm.minConn = 0x30;
- conParm.maxConn = 0x50;
- conParm.latency = 0;
- conParm.superTimeout = 50;
-
- if (bt_gatt_connect_service(service.device().address().toString().toLocal8Bit().constData(), serviceUuid.toLocal8Bit().constData(), 0, &conParm, classPointer) < 0) {
- qCDebug(QT_BT_QNX) << "[SERVICE] Connection to service failed." << errno << qt_error_string(errno);
- error = QLowEnergyController::OperationError;
- errorString = QStringLiteral("[SERVICE] Connection to service failed.") + qt_error_string(errno);
- Q_EMIT q->error(service, error);
- }
- qCDebug(QT_BT_QNX) << "errno after connect: " << errno;
-}
-
-void QLowEnergyControllerPrivate::disconnectService(const QLowEnergyServiceInfo &leService)
-{
- Q_Q(QLowEnergyController);
- if (leService.isValid()){
- QString serviceUuid = leService.serviceUuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));
- if (leService.serviceName() == QStringLiteral("Unknown Service"))
- serviceUuid = QStringLiteral("0x") + serviceUuid.toUpper();
- else
- serviceUuid = QStringLiteral("0x") + serviceUuid[4] + serviceUuid[5] + serviceUuid[6] + serviceUuid[7];
- if (leService.isConnected()) {
- if (bt_gatt_disconnect_service(leService.device().address().toString().toLocal8Bit().constData(), serviceUuid.toLocal8Bit().constData()) < 0) {
- qCDebug(QT_BT_QNX) << "[SERVICE] Disconnect service request failed. " << errno << qt_error_string(errno);
- error = QLowEnergyController::OperationError;
- errorString = QStringLiteral("[SERVICE] Disconnect service request failed. ") + qt_error_string(errno);
- Q_EMIT q->error(leService, error);
- } else {
- for (int i = 0; i < m_leServices.size(); i++) {
- if (leService.serviceUuid() == m_leServices.at(i).serviceUuid()) {
- m_leServices.removeAt(i);
- break;
- }
- }
- leService.d_ptr->connected = false;
- Q_EMIT q->disconnected(leService);
- qCDebug(QT_BT_QNX) << "[SERVICE] Disconnected from service OK.";
- }
- } else {
- error = QLowEnergyController::UnknownError;
- errorString = QStringLiteral("Service is not connected");
- Q_EMIT q->error(leService, error);
- }
- } else {
- disconnectAllServices();
- }
-}
-
-void QLowEnergyControllerPrivate::disconnectAllServices()
-{
- Q_Q(QLowEnergyController);
- for (int i = 0; i < m_leServices.size(); i++) {
- QString serviceUuid = m_leServices.at(i).serviceUuid().toString().remove(QLatin1Char('{')).remove(QLatin1Char('}'));
- if (m_leServices.at(i).serviceName() == QStringLiteral("Unknown Service"))
- serviceUuid = QStringLiteral("0x") + serviceUuid.toUpper();
- else
- serviceUuid = QStringLiteral("0x") + serviceUuid[4] + serviceUuid[5] + serviceUuid[6] + serviceUuid[7];
-
- if (m_leServices.at(i).isConnected()) {
- qCDebug(QT_BT_QNX) << m_leServices.at(i).device().address().toString().toLocal8Bit().constData() << serviceUuid.toLocal8Bit().constData();
- if (bt_gatt_disconnect_service( m_leServices.at(i).device().address().toString().toLocal8Bit().constData(), serviceUuid.toLocal8Bit().constData()) < 0) {
- qCDebug(QT_BT_QNX) << "[SERVICE] Disconnect service request failed. " << errno << qt_error_string(errno);
- error = QLowEnergyController::OperationError;
- errorString = QStringLiteral("[SERVICE] Disconnect service request failed. ") + qt_error_string(errno);
- Q_EMIT q->error( m_leServices.at(i), error);
- } else {
- m_leServices.at(i).d_ptr->connected = false;
- Q_EMIT q->disconnected(m_leServices.at(i));
- qCDebug(QT_BT_QNX) << "[SERVICE] Disconnected from service OK.";
- }
- }
- }
- m_leServices.clear();
-}
-
-bool QLowEnergyControllerPrivate::enableNotification(const QLowEnergyCharacteristicInfo &characteristic)
-{
- Q_Q(QLowEnergyController);
- if (characteristic.d_ptr->instance == -1) {
- qCDebug(QT_BT_QNX) << " GATT service not connected ";
- error = QLowEnergyController::UnknownError;
- errorString = QStringLiteral("Service is not connected");
- Q_EMIT q->error(characteristic, error);
- return false;
- }
- if (!(characteristic.d_ptr->properties & QLowEnergyCharacteristicInfo::Notify)) {
- qCDebug(QT_BT_QNX) << "Notification changes not allowed";
- error = QLowEnergyController::PermissionError;
- errorString = QStringLiteral("This characteristic does not support notifications.");
- Q_EMIT q->error(characteristic, error);
- return false;
- }
-
- int rc = bt_gatt_enable_notify(characteristic.d_ptr->instance, &characteristic.d_ptr->characteristic, 1);
- if (!rc) {
- qCDebug(QT_BT_QNX) << "bt_gatt_enable_notify errno=" << errno << qt_error_string(errno);
- error = QLowEnergyController::OperationError;
- errorString = qt_error_string(errno);
- Q_EMIT q->error(characteristic, error);
- return false;
- } else {
- qCDebug(QT_BT_QNX) << "bt_gatt_enable_notify was presumably OK";
- return true;
- }
-}
-
-void QLowEnergyControllerPrivate::disableNotification(const QLowEnergyCharacteristicInfo &characteristic)
-{
- int rc = bt_gatt_enable_notify(characteristic.d_ptr->instance, &characteristic.d_ptr->characteristic, 0);
- if (!rc)
- qCDebug(QT_BT_QNX) << "bt_gatt_enable_notify errno=" << errno << qt_error_string(errno);
- else
- qCDebug(QT_BT_QNX) << "bt_gatt_enable_notify was presumably OK";
-}
-
-bool QLowEnergyControllerPrivate::write(const QLowEnergyCharacteristicInfo &characteristic)
-{
- Q_Q(QLowEnergyController);
- if (!characteristic.isValid()) {
- error = QLowEnergyController::UnknownError;
- errorString = QStringLiteral("Characteristic not valid.");
- Q_EMIT q->error(characteristic, error);
- return false;
- }
-
- if (characteristic.properties() & QLowEnergyCharacteristicInfo::Write) {
- writeValue(characteristic.d_ptr->instance, characteristic.d_ptr->handle, characteristic.d_ptr->value);
- if (errorString == QString()) {
- return true;
- } else {
- error = QLowEnergyController::OperationError;
- Q_EMIT q->error(characteristic, error);
- return false;
- }
- } else {
- error = QLowEnergyController::PermissionError;
- errorString = QStringLiteral("Characteristic does not allow write operations. The wanted value was not written to the device.");
- Q_EMIT q->error(characteristic, error);
- return false;
- }
-
-}
-
-bool QLowEnergyControllerPrivate::write(const QLowEnergyDescriptorInfo &descriptor)
-{
- Q_UNUSED(descriptor);
- return false;
-}
-
-void QLowEnergyControllerPrivate::readDescriptors(QLowEnergyCharacteristicInfo &characteristic)
-{
- characteristic.d_ptr->descriptorsList.clear();
- int count = bt_gatt_descriptors_count(characteristic.d_ptr->instance, &characteristic.d_ptr->characteristic);
-
- if (count == -1) {
- qWarning() << "GATT descriptors count failed:" << errno << "(" << qt_error_string(errno) << ")";
- bt_gatt_disconnect_instance(characteristic.d_ptr->instance);
- return;
- }
-
- bt_gatt_descriptor_t *descriptorList = 0;
- if (count > 0) {
- descriptorList = (bt_gatt_descriptor_t*)alloca(count * sizeof(bt_gatt_descriptor_t));
- if (!descriptorList) {
- qCDebug(QT_BT_QNX) <<"GATT descriptors: Not enough memory";
- bt_gatt_disconnect_instance(characteristic.d_ptr->instance);
- return;
- }
-
- /* BEGIN WORKAROUND - Temporary fix to address race condition */
- int number = 0;
- do {
- number = bt_gatt_descriptors(characteristic.d_ptr->instance, &characteristic.d_ptr->characteristic, descriptorList, count);
- } while ((number == -1) && (errno == EBUSY));
-
- count = number;
- /* END WORKAROUND */
- }
-
- if (count == -1) {
- qCDebug(QT_BT_QNX) << "GATT descriptors failed: %1 (%2)" << errno << qt_error_string(errno);
- bt_gatt_disconnect_instance(characteristic.d_ptr->instance);
- return;
- }
-
- characteristic.d_ptr->characteristicMtu = bt_gatt_get_mtu(characteristic.d_ptr->instance);
-
- uint8_t *descriptorBuffer = (uint8_t *)alloca(characteristic.d_ptr->characteristicMtu);
- if (!descriptorBuffer) {
- qCDebug(QT_BT_QNX) <<"GATT descriptors: Not enough memory";
- bt_gatt_disconnect_instance(characteristic.d_ptr->instance);
- return;
- }
-
- for (int i = 0; i < count; i++) {
- QString descriptorUuid = QLatin1String(descriptorList[i].uuid);
- QBluetoothUuid descUuid(descriptorUuid);
- QLowEnergyDescriptorInfo descriptor(descUuid, QBluetoothUuid::CharacteristicExtendedProperties, descriptorList[i].handle); //TODO set proper descriptor type
-
- uint8_t more = 1;
- int byteCount;
- for (int offset = 0; more; offset += byteCount) {
- byteCount = bt_gatt_read_value(characteristic.d_ptr->instance, descriptorList[i].handle, offset, descriptorBuffer, characteristic.d_ptr->characteristicMtu, &more);
- if (byteCount < 0) {
- qCDebug(QT_BT_QNX) << "Unable to read descriptor value:"<< errno<< qt_error_string(errno);
- break;
- }
- descriptor.d_ptr->m_value = QByteArray();
- for (int j = 0; j < byteCount; j++) {
- QString hexadecimal;
- hexadecimal.setNum(descriptorBuffer[j], 16);
- descriptor.d_ptr->m_value.append(hexadecimal.toLatin1());
- }
-
- }
- descriptor.d_ptr->instance = characteristic.d_ptr->instance;
- characteristic.d_ptr->descriptorsList.append(descriptor);
- }
-
- if (!descriptorList) {
- free(descriptorList);
- descriptorList = 0;
- }
-}
-
-void QLowEnergyControllerPrivate::readValue(QLowEnergyCharacteristicInfo &characteristic)
-{
- if (!(characteristic.d_ptr->properties & QLowEnergyCharacteristicInfo::Read)) {
- qCDebug(QT_BT_QNX) << "GATT characteristic: Read not permitted";
- return;
- }
-
- uint8_t *characteristicBuffer = (uint8_t *)alloca(characteristic.d_ptr->characteristicMtu);
- if (!characteristicBuffer) {
- qCDebug(QT_BT_QNX) << "GATT characteristic: Not enough memory";
- bt_gatt_disconnect_instance(characteristic.d_ptr->instance);
- return;
- }
-
- int byteCount = 0;
- uint8_t more = 1;
- for (int offset = 0; more; offset += byteCount) {
- byteCount = bt_gatt_read_value(characteristic.d_ptr->instance,
- characteristic.d_ptr->handle, offset, characteristicBuffer,
- characteristic.d_ptr->characteristicMtu, &more);
- if (byteCount < 0) {
- qCDebug(QT_BT_QNX) << "Unable to read characteristic value: " << errno << qt_error_string(errno);
- break;
- }
- characteristic.d_ptr->value = QByteArray();
- for (int j = 0; j < byteCount; j++) {
- QString hexadecimal;
- hexadecimal.setNum(characteristicBuffer[j], 16);
- characteristic.d_ptr->value.append(hexadecimal.toLatin1());
- }
- }
-}
-
-void QLowEnergyControllerPrivate::writeValue(const int &instance, QLowEnergyHandle handle, const QByteArray &value)
-{
- errorString = QString();
- const int characteristicLen = value.size();
- uint8_t *characteristicBuffer = (uint8_t *)alloca(characteristicLen / 2 + 1);
- if (!characteristicBuffer) {
- qCDebug(QT_BT_QNX) << "GATT characteristic: Not enough memory";
- errorString = QStringLiteral("Not enough memory.");
- bt_gatt_disconnect_instance(instance);
- return;
- }
-
- const int consumed = stringToBuffer(QString::fromLocal8Bit(value), characteristicBuffer, characteristicLen);
-
- if (consumed > 0) {
- int byteCount;
- byteCount = bt_gatt_write_value(instance, handle, 0, characteristicBuffer, (consumed / 2));
-
- if (byteCount < 0) {
- qCDebug(QT_BT_QNX) << "Unable to write characteristic value: " << errno << qt_error_string(errno);
- errorString = QStringLiteral("Unable to write characteristic value: ") + qt_error_string(errno);
- }
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergydescriptorinfo.cpp b/src/bluetooth/qlowenergydescriptorinfo.cpp
deleted file mode 100644
index b4789670..00000000
--- a/src/bluetooth/qlowenergydescriptorinfo.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergydescriptorinfo.h"
-#include "qlowenergydescriptorinfo_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QLowEnergyDescriptorInfo
- \inmodule QtBluetooth
- \brief The QLowEnergyDescriptorInfo class stores information about the Bluetooth
- Low Energy descriptor.
- \since 5.4
-
- QLowEnergyDescriptorInfo provides information about a Bluetooth Low Energy
- descriptor's name, UUID, value and handle. Descriptors are contained in the
- Bluetooth Low Energy characteristic and they provide additional information
- about the characteristic (data format, notification activation, etc).
-*/
-
-QLowEnergyDescriptorInfoPrivate::QLowEnergyDescriptorInfoPrivate(const QBluetoothUuid &uuid, QLowEnergyHandle handle)
- : m_uuid(uuid), m_handle(handle),
- m_type(QBluetoothUuid::ClientCharacteristicConfiguration) //by default a notification
-{
-#ifdef QT_QNX_BLUETOOTH
- instance = -1;
-#endif
-}
-
-QLowEnergyDescriptorInfoPrivate::~QLowEnergyDescriptorInfoPrivate()
-{
-
-}
-
-/*!
- Construct a new QLowEnergyCharacteristicInfo with given \a uuid.
-*/
-QLowEnergyDescriptorInfo::QLowEnergyDescriptorInfo(const QBluetoothUuid &uuid):
- d_ptr(new QLowEnergyDescriptorInfoPrivate(uuid, 0u))
-{
-}
-
-/*!
- \internal
- Construct a new QLowEnergyDescriptorInfo with given parent
- characteristic \a uuid, descriptor \a type and \a handle.
-*/
-QLowEnergyDescriptorInfo::QLowEnergyDescriptorInfo(const QBluetoothUuid &uuid,
- QBluetoothUuid::DescriptorType type,
- QLowEnergyHandle handle):
- d_ptr(new QLowEnergyDescriptorInfoPrivate(uuid, handle))
-{
- d_ptr->m_type = type;
-}
-
-/*!
- Destroys the QLowEnergyDescriptorInfo object.
-*/
-QLowEnergyDescriptorInfo::~QLowEnergyDescriptorInfo()
-{
-
-}
-
-/*!
- Makes a copy of the \a other and assigns it to this QLowEnergyDescriptorInfo object.
- The two copies continue to share the same service and registration details.
-*/
-QLowEnergyDescriptorInfo &QLowEnergyDescriptorInfo::operator=(const QLowEnergyDescriptorInfo &other)
-{
- d_ptr = other.d_ptr;
- return *this;
-}
-
-/*!
- Returns the UUID of the characteristic that this descriptor belongs to.
-*/
-
-//TODO should this return the characteristic uuid or indeed 0x2902?
-QBluetoothUuid QLowEnergyDescriptorInfo::uuid() const
-{
- return d_ptr->m_uuid;
-}
-
-/*!
- Returns the handle of the descriptor.
-*/
-QLowEnergyHandle QLowEnergyDescriptorInfo::handle() const
-{
- return d_ptr->m_handle;
-}
-
-/*!
- Returns the value of the descriptor.
-*/
-QByteArray QLowEnergyDescriptorInfo::value() const
-{
- return d_ptr->m_value;
-}
-
-/*!
- Returns the name of the descriptor type.
-
- \sa type()
-*/
-//TODO check that we really need this function. The static
-// QBluetoothUuid::descriptorToString should actually be sufficient.
-QString QLowEnergyDescriptorInfo::name() const
-{
- return QBluetoothUuid::descriptorToString(
- static_cast<QBluetoothUuid::DescriptorType>(d_ptr->m_type));
-}
-
-/*!
- Returns the type of descriptor.
- */
-QBluetoothUuid::DescriptorType QLowEnergyDescriptorInfo::type() const
-{
- return d_ptr->m_type;
-}
-
-/*!
- Sets the value \a value of the descriptor. This only caches the value. To write
- a value directly to the device QLowEnergyController class must be used.
-
- \sa QLowEnergyController::writeDescriptor()
-*/
-void QLowEnergyDescriptorInfo::setValue(const QByteArray &value)
-{
- d_ptr->m_value = value;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergydescriptorinfo.h b/src/bluetooth/qlowenergydescriptorinfo.h
deleted file mode 100644
index 9f56ef38..00000000
--- a/src/bluetooth/qlowenergydescriptorinfo.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOWENERGYDESCRIPTORINFO_H
-#define QLOWENERGYDESCRIPTORINFO_H
-
-#include <QtCore/QSharedPointer>
-#include <QtCore/QVariantMap>
-#include <QtBluetooth/qbluetooth.h>
-#include <QtBluetooth/QBluetoothUuid>
-
-QT_BEGIN_NAMESPACE
-
-class QLowEnergyCharacteristicInfo;
-class QLowEnergyDescriptorInfoPrivate;
-
-//TODO rename to QLowEnergyDescriptor
-class Q_BLUETOOTH_EXPORT QLowEnergyDescriptorInfo
-{
- friend class QLowEnergyControllerPrivate;
-public:
- //TODO - add QLowEnergyDescriptorInfo() <- for invalid descriptor object
- // - remove QLowEnergyDescriptorInfo(QBluetoothUuid) <- not really needed
- explicit QLowEnergyDescriptorInfo(const QBluetoothUuid &uuid);
- ~QLowEnergyDescriptorInfo();
-
- QLowEnergyDescriptorInfo &operator=(const QLowEnergyDescriptorInfo &other);
-
- QByteArray value() const;
- void setValue(const QByteArray &value);
-
- QBluetoothUuid uuid() const;
- QLowEnergyHandle handle() const;
- QString name() const;
-
- QBluetoothUuid::DescriptorType type() const;
-
-private:
- QSharedPointer<QLowEnergyDescriptorInfoPrivate> d_ptr;
- QLowEnergyDescriptorInfo(const QBluetoothUuid &uuid,
- QBluetoothUuid::DescriptorType desc,
- QLowEnergyHandle handle);
-};
-
-QT_END_NAMESPACE
-
-#endif // QLOWENERGYDESCRIPTORINFO_H
diff --git a/src/bluetooth/qlowenergydescriptorinfo_p.h b/src/bluetooth/qlowenergydescriptorinfo_p.h
deleted file mode 100644
index 921e4992..00000000
--- a/src/bluetooth/qlowenergydescriptorinfo_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOWENERGYDESCRIPTORINFO_P_H
-#define QLOWENERGYDESCRIPTORINFO_P_H
-
-#include <QtBluetooth/qbluetooth.h>
-#include <QtBluetooth/QBluetoothUuid>
-
-QT_BEGIN_NAMESPACE
-
-class QLowEnergyDescriptorInfoPrivate
-{
-public:
- QLowEnergyDescriptorInfoPrivate(const QBluetoothUuid &uuid, QLowEnergyHandle handle);
- ~QLowEnergyDescriptorInfoPrivate();
- QByteArray m_value;
- QBluetoothUuid m_uuid;
- QLowEnergyHandle m_handle;
- QBluetoothUuid::DescriptorType m_type;
-#ifdef QT_QNX_BLUETOOTH
- int instance;
-#endif
-};
-QT_END_NAMESPACE
-#endif // QLOWENERGYDESCRIPTORINFO_P_H
diff --git a/src/bluetooth/qlowenergyprocess_bluez.cpp b/src/bluetooth/qlowenergyprocess_bluez.cpp
deleted file mode 100644
index 9f94da4f..00000000
--- a/src/bluetooth/qlowenergyprocess_bluez.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergyprocess_p.h"
-
-#include <QtCore/QLoggingCategory>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QLowEnergyProcess, processInstance)
-Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ)
-
-/*
- Private constructor. Constructs the new QLowEnergyProcess, sets variables and connects
- signal to a slot.
-*/
-QLowEnergyProcess::QLowEnergyProcess()
-{
- m_process = new QProcess();
- connected = false;
- m_counter = 0;
- connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(replyRead()));
-}
-
-/*
- Destroys the QLowEnergyProcess object.
-*/
-QLowEnergyProcess::~QLowEnergyProcess()
-{
- m_process->kill();
- delete m_process;
-}
-
-/*
- Returns the singleton instance of this class.
-*/
-
-QLowEnergyProcess *QLowEnergyProcess::instance()
-{
- return processInstance();
-}
-
-/*
- Slot that emits a signal replySend. This slot is connected with QProcess signal
- and it is called whenever something comes to output.
-*/
-void QLowEnergyProcess::replyRead()
-{
- QByteArray result = m_process->readAll();
- QString back = QString::fromLocal8Bit(result.data());
- if (back.size() > 10)
- emit replySend(back);
-}
-
-/*
- Starts the process with \a command. This method is used only when starting the
- process.
-
- \sa executeCommand()
-*/
-void QLowEnergyProcess::startCommand(const QString &command)
-{
- m_process->start(command);
- if (!m_process->waitForStarted())
- qDebug() << "Could not start the process under the command: "<<command;
-}
-
-/*
- Executes the \a command. This method is called after process started.
-
- \sa startCommand()
-*/
-void QLowEnergyProcess::executeCommand(const QString &command)
-{
- qCDebug(QT_BT_BLUEZ) << "gatttool command:" << command;
- QByteArray cmd(command.toUtf8() + '\n');
- m_process->write(cmd.constData());
-}
-
-/*
- Terminate running process.
-*/
-void QLowEnergyProcess::endProcess()
-{
- m_counter--;
- if (m_counter == 0) {
- executeCommand(QStringLiteral("disconnect"));
- connected = false;
- }
-}
-
-bool QLowEnergyProcess::isConnected() const
-{
- return connected;
-}
-
-void QLowEnergyProcess::addConnection()
-{
- m_counter++;
- connected = true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyprocess_p.cpp b/src/bluetooth/qlowenergyprocess_p.cpp
deleted file mode 100644
index 3bbacdbf..00000000
--- a/src/bluetooth/qlowenergyprocess_p.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergyprocess_p.h"
-
-QLowEnergyProcess::QLowEnergyProcess()
-{
-
-}
-
-/*
- Destroys the QLowEnergyProcess object.
-*/
-QLowEnergyProcess::~QLowEnergyProcess()
-{
-
-}
-
-/*
- Returns the singleton instance of this class.
-*/
-QLowEnergyProcess *QLowEnergyProcess::instance()
-{
- return 0;
-}
-
-bool QLowEnergyProcess::isConnected() const
-{
- return false;
-}
diff --git a/src/bluetooth/qlowenergyprocess_p.h b/src/bluetooth/qlowenergyprocess_p.h
deleted file mode 100644
index 5d3fb0ed..00000000
--- a/src/bluetooth/qlowenergyprocess_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOWENERGYPROCESS_H
-#define QLOWENERGYPROCESS_H
-
-#include <QtCore>
-#include <QObject>
-#ifdef QT_QNX_BLUETOOTH
-#include <QList>
-#include <QPointer>
-#include "qlowenergycontroller_p.h"
-#endif
-#ifdef QT_BLUEZ_BLUETOOTH
-#include <QProcess>
-#endif
-QT_BEGIN_NAMESPACE
-
-class QLowEnergyProcess: public QObject
-{
- Q_OBJECT
- friend class QLowEnergyServiceInfoPrivate;
-public:
- QLowEnergyProcess();
- ~QLowEnergyProcess();
-
- static QLowEnergyProcess *instance();
- bool isConnected() const;
-#ifdef QT_QNX_BLUETOOTH
- static void handleEvent(const int, const char *, const char *);
- void addPointer(QLowEnergyControllerPrivate* classPointer);
-#endif
-#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
- void startCommand(const QString &command);
- void executeCommand(const QString &command);
- void endProcess();
- void addConnection();
-
-Q_SIGNALS:
- void replySend(const QString &reply);
-
-private slots:
- void replyRead();
-#endif
-
-private:
-#ifdef QT_BLUEZ_BLUETOOTH
- QProcess *m_process;
- int m_counter;
-#endif
-#ifdef QT_QNX_BLUETOOTH
- QList<QLowEnergyControllerPrivate*> m_classPointers;
-#endif
- bool connected;
-};
-QT_END_NAMESPACE
-
-#endif // QLOWENERGYPROCESS_H
diff --git a/src/bluetooth/qlowenergyprocess_qnx.cpp b/src/bluetooth/qlowenergyprocess_qnx.cpp
deleted file mode 100644
index f7e298de..00000000
--- a/src/bluetooth/qlowenergyprocess_qnx.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlowenergyprocess_p.h"
-#include <btapi/btdevice.h>
-#include <errno.h>
-#include <btapi/btgatt.h>
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QLowEnergyProcess, processInstance)
-
-void QLowEnergyProcess::handleEvent(const int event, const char *bt_address, const char *event_data)
-{
- qDebug() << "[HANDLE Event] (event, address, event data): " << event << bt_address << event_data;
-}
-
-QLowEnergyProcess::QLowEnergyProcess()
-{
- connected = false;
- if (bt_device_init( &(this->handleEvent) ) < 0)
- qDebug() << "[INIT] Init problem." << errno << strerror(errno);
- else
- connected = true;
-
-}
-
-/*
- Destroys the QLowEnergyProcess object.
-*/
-QLowEnergyProcess::~QLowEnergyProcess()
-{
- bt_device_deinit();
- bt_gatt_deinit();
- qDeleteAll(m_classPointers);
- m_classPointers.clear();
-}
-
-/*
- Returns the singleton instance of this class.
-*/
-
-QLowEnergyProcess *QLowEnergyProcess::instance()
-{
- return processInstance();
-}
-
-bool QLowEnergyProcess::isConnected() const
-{
- return connected;
-}
-
-void QLowEnergyProcess::addPointer(QLowEnergyControllerPrivate* classPointer)
-{
- m_classPointers.append(classPointer);
-}
-QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp
index 401468f4..8c7a7d02 100644
--- a/src/bluetooth/qlowenergyservice.cpp
+++ b/src/bluetooth/qlowenergyservice.cpp
@@ -42,7 +42,6 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QPointer>
#include <QtBluetooth/QLowEnergyService>
-#include <QtBluetooth/QLowEnergyCharacteristicInfo>
#include <algorithm>
diff --git a/src/bluetooth/qlowenergyserviceinfo.cpp b/src/bluetooth/qlowenergyserviceinfo.cpp
index 80b0038b..5ed9690a 100644
--- a/src/bluetooth/qlowenergyserviceinfo.cpp
+++ b/src/bluetooth/qlowenergyserviceinfo.cpp
@@ -120,15 +120,6 @@ QBluetoothUuid QLowEnergyServiceInfo::serviceUuid() const
}
/*!
- Returns the list of service characteristics. If service was not connected, an empty
- list will be returned.
-*/
-QList<QLowEnergyCharacteristicInfo> QLowEnergyServiceInfo::characteristics() const
-{
- return d_ptr->characteristicList;
-}
-
-/*!
Returns the service name.
*/
QString QLowEnergyServiceInfo::serviceName() const
diff --git a/src/bluetooth/qlowenergyserviceinfo.h b/src/bluetooth/qlowenergyserviceinfo.h
index 8365236a..626203bf 100644
--- a/src/bluetooth/qlowenergyserviceinfo.h
+++ b/src/bluetooth/qlowenergyserviceinfo.h
@@ -45,7 +45,6 @@
#include <QtBluetooth/QBluetoothAddress>
#include <QtBluetooth/QBluetoothDeviceInfo>
#include <QtBluetooth/QBluetoothUuid>
-#include <QtBluetooth/QLowEnergyCharacteristicInfo>
QT_BEGIN_NAMESPACE
@@ -74,8 +73,6 @@ public:
QBluetoothUuid serviceUuid() const;
- QList<QLowEnergyCharacteristicInfo> characteristics() const;
-
QString serviceName() const;
void setServiceType(QLowEnergyServiceInfo::ServiceType type);
diff --git a/src/bluetooth/qlowenergyserviceinfo_bluez.cpp b/src/bluetooth/qlowenergyserviceinfo_bluez.cpp
index 09748470..5946205d 100644
--- a/src/bluetooth/qlowenergyserviceinfo_bluez.cpp
+++ b/src/bluetooth/qlowenergyserviceinfo_bluez.cpp
@@ -41,11 +41,6 @@
#include "qlowenergyserviceinfo_p.h"
#include "qlowenergyserviceinfo.h"
-#include "qlowenergycharacteristicinfo.h"
-#include "qlowenergycharacteristicinfo_p.h"
-#include "qlowenergyprocess_p.h"
-#include "qlowenergydescriptorinfo.h"
-#include "qlowenergydescriptorinfo_p.h"
#ifdef QT_LOWENERGYSERVICE_DEBUG
#include <QtCore/QDebug>
diff --git a/src/bluetooth/qlowenergyserviceinfo_p.h b/src/bluetooth/qlowenergyserviceinfo_p.h
index 3f03ca02..fcdb0555 100644
--- a/src/bluetooth/qlowenergyserviceinfo_p.h
+++ b/src/bluetooth/qlowenergyserviceinfo_p.h
@@ -43,15 +43,12 @@
#define QLOWENERGYSERVICEINFO_P_H
#include "qbluetoothuuid.h"
#include "qlowenergyserviceinfo.h"
-#include "qlowenergycharacteristicinfo.h"
#include <QPointer>
QT_BEGIN_NAMESPACE
class QBluetoothUuid;
class QLowEnergyServiceInfo;
-class QLowEnergyCharacteristicInfo;
-class QLowEnergyProcess;
class QLowEnergyServiceInfoPrivate
{
@@ -63,7 +60,6 @@ public:
QBluetoothUuid uuid;
- QList<QLowEnergyCharacteristicInfo> characteristicList;
QLowEnergyServiceInfo::ServiceType serviceType;
bool connected;
QBluetoothDeviceInfo deviceInfo;
@@ -72,10 +68,6 @@ public:
QString endingHandle;
#endif
-#ifdef QT_QNX_BLUETOOTH
- static void serviceNotification(int, short unsigned int, const char unsigned *, short unsigned int, void *);
-#endif
-
private:
#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
int m_step;
diff --git a/src/bluetooth/qlowenergyserviceinfo_qnx.cpp b/src/bluetooth/qlowenergyserviceinfo_qnx.cpp
index c310a5db..26d0e9d9 100644
--- a/src/bluetooth/qlowenergyserviceinfo_qnx.cpp
+++ b/src/bluetooth/qlowenergyserviceinfo_qnx.cpp
@@ -1,4 +1,3 @@
-
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
@@ -40,22 +39,11 @@
**
****************************************************************************/
-#include <QtCore/QLoggingCategory>
#include "qlowenergyserviceinfo_p.h"
-#include "qlowenergycharacteristicinfo.h"
-#include "qlowenergycharacteristicinfo_p.h"
-#include "qlowenergyprocess_p.h"
-#include <btapi/btdevice.h>
-#include <btapi/btgatt.h>
-#include <btapi/btspp.h>
-#include <btapi/btle.h>
-#include <errno.h>
-#include <QPointer>
-#include "qnx/ppshelpers_p.h"
QT_BEGIN_NAMESPACE
-Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX)
+Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX);
QLowEnergyServiceInfoPrivate::QLowEnergyServiceInfoPrivate()
{
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index 75c1c821..398fb1ad 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
@@ -52,8 +52,6 @@
#include <qbluetoothserver.h>
#include <qbluetoothserviceinfo.h>
#include <qlowenergyserviceinfo.h>
-#include <qlowenergycontroller.h>
-#include <qlowenergycharacteristicinfo.h>
QT_USE_NAMESPACE
@@ -376,8 +374,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
QFETCH(QBluetoothDeviceInfo, deviceInfo);
QFETCH(QList<QBluetoothUuid>, uuidFilter);
QFETCH(QBluetoothServiceDiscoveryAgent::Error, serviceDiscoveryError);
- QLowEnergyController leController;
- bool leDevice = false;
+
QBluetoothLocalDevice localDevice;
qDebug() << "Scanning address" << deviceInfo.address().toString();
QBluetoothServiceDiscoveryAgent discoveryAgent(localDevice.address());
@@ -406,8 +403,6 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error)));
- QSignalSpy leConnectedSpy(&leController, SIGNAL(connected(QLowEnergyServiceInfo)));
-
discoveryAgent.start();
/*
@@ -469,7 +464,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
}
}
- int leCounter = 0;
+
while (!leDiscoveredSpy.isEmpty()) {
const QVariant v = leDiscoveredSpy.takeFirst().at(0);
if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>())
@@ -478,72 +473,13 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
*reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData());
QVERIFY(info.isValid());
- if (info.device().coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) {
- leDevice = true;
- leController.connectToService(info);
- leCounter ++;
- }
-
+ QVERIFY(info.device().coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
} else {
QFAIL("Unknown type returned by service discovery");
}
}
- // In case it is not LE device next steps will be skipped.
- // In case of regular Bluetooth devices there is no need to go in to the loop below.
- if (leDevice) {
- scanTime = MaxScanTime;
- while (leConnectedSpy.count() != leCounter && scanTime > 0) {
- QTest::qWait(1000);
- scanTime -= 1000;
- }
- int leTestCounter = 0;
- QSignalSpy leDisonnectedSpy(&leController, SIGNAL(disconnected(QLowEnergyServiceInfo)));
- while (!leConnectedSpy.isEmpty()) {
- const QVariant v = leConnectedSpy.takeFirst().at(0);
- if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>())
- {
- const QLowEnergyServiceInfo info =
- *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData());
-
- QVERIFY(info.isValid());
- QCOMPARE(leController.errorString(), QString());
- QCOMPARE(leController.error(), QLowEnergyController::NoError);
- QVERIFY((info.characteristics().size() > 0));
- qDebug() << "LE Service Connected: " << info.serviceName() << info.serviceUuid();
- leTestCounter++;
- for (int i = 0; i < info.characteristics().size(); i++)
- QVERIFY(info.characteristics().at(i).isValid());
- leController.disconnectFromService(info);
- } else {
- QFAIL("Unknown type returned by service discovery");
- }
-
- }
- QCOMPARE(leCounter, leTestCounter);
- scanTime = MaxScanTime;
- while (leDisonnectedSpy.count() != leTestCounter && scanTime > 0) {
- QTest::qWait(1000);
- scanTime -= 1000;
- }
-
- while (!leDisonnectedSpy.isEmpty()) {
- const QVariant v = leDisonnectedSpy.takeFirst().at(0);
- if (v.userType() == qMetaTypeId<QLowEnergyServiceInfo>())
- {
- const QLowEnergyServiceInfo info =
- *reinterpret_cast<const QLowEnergyServiceInfo*>(v.constData());
-
- QVERIFY(info.isValid());
- qDebug() << "LE Service Disconnected: " << info.serviceName() << info.serviceUuid();
- } else {
- QFAIL("Unknown type returned by service discovery");
- }
-
- }
- }
-
QVERIFY(discoveryAgent.discoveredServices().count() != 0);
discoveryAgent.clear();
QVERIFY(discoveryAgent.discoveredServices().count() == 0);
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 8a4c5af7..3d501351 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -191,7 +191,6 @@ void tst_QLowEnergyController::tst_verifyAllServices()
info.serviceUuid().toString().toLatin1());
}
- QVERIFY(info.characteristics().isEmpty());
QCOMPARE(remoteDevice, info.device().address());
}
}
@@ -1351,7 +1350,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// value different in other revisions and test may fail
QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x82));
QCOMPARE(chars[0].properties(),
- (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristicInfo::WriteNoResponse));
+ (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse));
QCOMPARE(chars[0].value(), QByteArray(""));
QVERIFY(chars[0].isValid());
QVERIFY(info->contains(chars[0]));
@@ -1385,7 +1384,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// value different in other revisions and test may fail
QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x86));
QCOMPARE(chars[1].properties(),
- (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristicInfo::WriteNoResponse));
+ (QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse));
QCOMPARE(chars[1].value(), QByteArray(""));
QVERIFY(chars[1].isValid());
QVERIFY(info->contains(chars[1]));
diff --git a/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp
index 84631a9c..e908ae97 100644
--- a/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp
+++ b/tests/auto/qlowenergyserviceinfo/tst_qlowenergyserviceinfo.cpp
@@ -104,7 +104,6 @@ void tst_QLowEnergyServiceInfo::tst_construction()
QCOMPARE(serviceInfo.serviceUuid().toString(), QBluetoothUuid().toString());
QCOMPARE(serviceInfo.serviceType(), QLowEnergyServiceInfo::PrimaryService);
QCOMPARE(serviceInfo.isConnected(), false);
- QCOMPARE(serviceInfo.characteristics().size(), 0);
QCOMPARE(serviceInfo.device(), QBluetoothDeviceInfo());
}
@@ -223,7 +222,6 @@ void tst_QLowEnergyServiceInfo::tst_assignment()
QCOMPARE(copyInfo.device().coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo.serviceType(), serviceType);
QCOMPARE(copyInfo.isConnected(), false);
- QCOMPARE(copyInfo.characteristics().size(), 0);
QCOMPARE(copyInfo.device(), deviceInfo);
}
@@ -265,8 +263,6 @@ void tst_QLowEnergyServiceInfo::tst_assignment()
QCOMPARE(copyInfo2.device().coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo1.isConnected(), false);
QCOMPARE(copyInfo2.isConnected(), false);
- QCOMPARE(copyInfo1.characteristics().size(), 0);
- QCOMPARE(copyInfo2.characteristics().size(), 0);
QCOMPARE(copyInfo1.device(), deviceInfo);
QCOMPARE(copyInfo2.device(), deviceInfo);
}