summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--config.tests/bluez_le/bluez_le.pro8
-rw-r--r--config.tests/bluez_le/main.cpp52
-rw-r--r--qtconnectivity.pro1
-rw-r--r--src/bluetooth/bluetooth.pro26
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp5
-rw-r--r--src/bluetooth/qlowenergycontroller.h2
-rw-r--r--src/bluetooth/qlowenergycontroller_p.h4
-rw-r--r--src/bluetooth/qlowenergycontrollernew_p.h8
-rw-r--r--src/bluetooth/qlowenergyprocess_p.h2
-rw-r--r--src/bluetooth/qlowenergyserviceinfo_p.h4
11 files changed, 98 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 6d454385..bb997bd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ tmp
imports/*
include
config.tests/bluez/bluez
+config.tests/bluez_le/bluez_le
examples/bluetooth/btchat/btchat
examples/bluetooth/btfiletransfer/btfiletransfer
examples/bluetooth/btscanner/btscanner
diff --git a/config.tests/bluez_le/bluez_le.pro b/config.tests/bluez_le/bluez_le.pro
new file mode 100644
index 00000000..27b19a45
--- /dev/null
+++ b/config.tests/bluez_le/bluez_le.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+CONFIG += link_pkgconfig
+PKGCONFIG += bluez
+
+TARGET = bluez_le
+
+SOURCES += main.cpp
diff --git a/config.tests/bluez_le/main.cpp b/config.tests/bluez_le/main.cpp
new file mode 100644
index 00000000..ae23f6a6
--- /dev/null
+++ b/config.tests/bluez_le/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtConnectivity 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 <bluetooth/bluetooth.h>
+#include <bluetooth/l2cap.h>
+
+int main()
+{
+ sockaddr_l2 addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.l2_family = AF_BLUETOOTH;
+ addr.l2_cid = 4;
+ addr.l2_bdaddr_type = BDADDR_LE_PUBLIC;
+}
diff --git a/qtconnectivity.pro b/qtconnectivity.pro
index e2a73944..365c4104 100644
--- a/qtconnectivity.pro
+++ b/qtconnectivity.pro
@@ -1,5 +1,6 @@
load(configure)
qtCompileTest(bluez)
+qtCompileTest(bluez_le)
qtCompileTest(btapi10_2_1)
qtCompileTest(libbb2)
load(qt_parts)
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index 0d798956..b8f241c9 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -88,11 +88,27 @@ config_bluez:qtHaveModule(dbus) {
qbluetoothserver_bluez.cpp \
qbluetoothlocaldevice_bluez.cpp \
qbluetoothtransferreply_bluez.cpp \
- qlowenergyprocess_bluez.cpp \
- qlowenergyserviceinfo_bluez.cpp \
- qlowenergycharacteristicinfo_bluez.cpp \
- qlowenergycontroller_bluez.cpp \
- qlowenergycontrollernew_bluez.cpp
+
+
+ # 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.")
+ message("Only classic Bluetooth will be available.")
+ DEFINES += QT_BLUEZ_NO_BTLE
+ SOURCES += \
+ qlowenergyserviceinfo_p.cpp \
+ qlowenergycharacteristicinfo_p.cpp \
+ qlowenergyprocess_p.cpp \
+ qlowenergycontroller_p.cpp \
+ qlowenergycontrollernew_p.cpp
+ }
CONFIG += link_pkgconfig
PKGCONFIG_PRIVATE += bluez
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp
index cb963b4f..c4d84211 100644
--- a/src/bluetooth/qbluetoothsocket_bluez.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluez.cpp
@@ -167,12 +167,17 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address,
// We don't want to make this public API offering for now especially since
// only Linux (of all platforms supported by this library) supports this type
// of socket.
+
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
if (isLowEnergySocket) {
addr.l2_cid = port;
addr.l2_bdaddr_type = BDADDR_LE_PUBLIC;
} else {
addr.l2_psm = port;
}
+#else
+ addr.l2_psm = port;
+#endif
convertAddress(address.toUInt64(), addr.l2_bdaddr.b);
diff --git a/src/bluetooth/qlowenergycontroller.h b/src/bluetooth/qlowenergycontroller.h
index 53e29343..60400ada 100644
--- a/src/bluetooth/qlowenergycontroller.h
+++ b/src/bluetooth/qlowenergycontroller.h
@@ -94,7 +94,7 @@ Q_SIGNALS:
private:
Q_DECLARE_PRIVATE(QLowEnergyController)
QLowEnergyControllerPrivate *d_ptr;
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
Q_PRIVATE_SLOT(d_func(), void _q_replyReceived(const QString &reply))
#endif
};
diff --git a/src/bluetooth/qlowenergycontroller_p.h b/src/bluetooth/qlowenergycontroller_p.h
index e5763103..92d06f36 100644
--- a/src/bluetooth/qlowenergycontroller_p.h
+++ b/src/bluetooth/qlowenergycontroller_p.h
@@ -74,7 +74,7 @@ public:
void writeValue(const int &instance, QLowEnergyHandle handle, const QByteArray &value);
#endif
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
void connectToTerminal();
void setHandles();
void setCharacteristics(int);
@@ -88,7 +88,7 @@ private:
bool m_randomAddress;
QLowEnergyProcess *process;
QBluetoothAddress localAdapter;
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
int m_step;
bool m_deviceConnected;
bool m_commandStarted;
diff --git a/src/bluetooth/qlowenergycontrollernew_p.h b/src/bluetooth/qlowenergycontrollernew_p.h
index ff6eec66..5c1d9d86 100644
--- a/src/bluetooth/qlowenergycontrollernew_p.h
+++ b/src/bluetooth/qlowenergycontrollernew_p.h
@@ -43,11 +43,11 @@
#define QLOWENERGYCONTROLLERNEWPRIVATE_P_H
#include <qglobal.h>
+#include <QtBluetooth/qbluetooth.h>
#include "qlowenergycontrollernew.h"
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
#include <QtBluetooth/QBluetoothSocket>
-#include <QtBluetooth/qbluetooth.h>
#endif
typedef QPair<QLowEnergyHandle,QLowEnergyHandle> HandlePair;
@@ -63,7 +63,7 @@ public:
: QObject(),
state(QLowEnergyControllerNew::UnconnectedState),
error(QLowEnergyControllerNew::NoError)
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
, l2cpSocket(0)
#endif
{}
@@ -89,7 +89,7 @@ private:
// list of all found service uuids
QMap<QBluetoothUuid, HandlePair> serviceList;
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
QBluetoothSocket *l2cpSocket;
void sendReadByGroupRequest(QLowEnergyHandle start, QLowEnergyHandle end);
diff --git a/src/bluetooth/qlowenergyprocess_p.h b/src/bluetooth/qlowenergyprocess_p.h
index 0c63bc46..5d3fb0ed 100644
--- a/src/bluetooth/qlowenergyprocess_p.h
+++ b/src/bluetooth/qlowenergyprocess_p.h
@@ -68,7 +68,7 @@ public:
static void handleEvent(const int, const char *, const char *);
void addPointer(QLowEnergyControllerPrivate* classPointer);
#endif
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
void startCommand(const QString &command);
void executeCommand(const QString &command);
void endProcess();
diff --git a/src/bluetooth/qlowenergyserviceinfo_p.h b/src/bluetooth/qlowenergyserviceinfo_p.h
index ecd84f4c..3f03ca02 100644
--- a/src/bluetooth/qlowenergyserviceinfo_p.h
+++ b/src/bluetooth/qlowenergyserviceinfo_p.h
@@ -67,7 +67,7 @@ public:
QLowEnergyServiceInfo::ServiceType serviceType;
bool connected;
QBluetoothDeviceInfo deviceInfo;
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
QString startingHandle;
QString endingHandle;
#endif
@@ -77,7 +77,7 @@ public:
#endif
private:
-#ifdef QT_BLUEZ_BLUETOOTH
+#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
int m_step;
int m_valueCounter;
int m_readCounter;