summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-06-16 12:27:55 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-06-16 14:17:42 +0200
commit50e7588d6d2b4a21b2c4aebc0417b5cfcd8a9c03 (patch)
treefdc93854fb3614f8557a4b53ce983ac9c09c78e0 /src
parent680537e519c859c79251da94fa15740d87b5ca35 (diff)
Provide guarding against non-BTLE enabled versions of Bluez
This disables the gatttool based controller as well. While it might compile on older systems they are likely to not have a gatttool and why would a Bluez version without BTLE symbols ever work anyway. Change-Id: I761e482d3dd1e99008c5d170053e19a1a3a51e6c Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src')
-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
7 files changed, 36 insertions, 15 deletions
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;