summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-05-07 14:03:23 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-05-12 09:00:45 +0000
commit193ed20a9d6f4b65fdffd4d3c43d7824eb450089 (patch)
tree08f42394b5fbc9d8a18acff92cd122f3b96e6d32 /examples
parent26009d55b503e4bffbddf1f68530797ef81a1127 (diff)
Reduce platform specific code lines
QLEController(QBluetoothAddress) ctor is not usable on iOS and OSX. On those platforms we have to use QLECOntroller(QBluetoothDeviceInfo). We mark the QBluetoothAddress based ctors of QLEController obsolete and remove most uses of them. This cleans up some ifdefs throughout the QtBluetooth code base. Change-Id: Ibe1e3fa271a29461e39fc3c0eeba7a910a250077 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/bluetooth/heartlistener/heartrate.cpp10
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp11
2 files changed, 3 insertions, 18 deletions
diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp
index b4496925..fe53a740 100644
--- a/examples/bluetooth/heartlistener/heartrate.cpp
+++ b/examples/bluetooth/heartlistener/heartrate.cpp
@@ -152,15 +152,7 @@ void HeartRate::connectToService(const QString &address)
}
//! [Connect signals]
-#ifdef Q_OS_MAC
- // with CoreBluetooth controller requires QBluetoothDeviceInfo to connect:
- m_control = new QLowEnergyController(m_currentDevice.getDevice(),
- this);
-
-#else
- m_control = new QLowEnergyController(m_currentDevice.getDevice().address(),
- this);
-#endif
+ m_control = new QLowEnergyController(m_currentDevice.getDevice(), this);
connect(m_control, SIGNAL(serviceDiscovered(QBluetoothUuid)),
this, SLOT(serviceDiscovered(QBluetoothUuid)));
connect(m_control, SIGNAL(discoveryFinished()),
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index a95bc48b..5ef2cf76 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -158,12 +158,7 @@ void Device::scanServices(const QString &address)
setUpdate("Back\n(Connecting to device...)");
-#ifdef Q_OS_MAC
if (controller && m_previousAddress != currentDevice.getAddress()) {
- m_previousAddress = currentDevice.getAddress();
-#else
- if (controller && controller->remoteAddress() != currentDevice.getDevice().address()) {
-#endif
controller->disconnectFromDevice();
delete controller;
controller = 0;
@@ -172,11 +167,7 @@ void Device::scanServices(const QString &address)
//! [les-controller-1]
if (!controller) {
// Connecting signals and slots for connecting to LE services.
-#ifdef Q_OS_MAC
controller = new QLowEnergyController(currentDevice.getDevice());
-#else
- controller = new QLowEnergyController(currentDevice.getDevice().address());
-#endif
connect(controller, SIGNAL(connected()),
this, SLOT(deviceConnected()));
connect(controller, SIGNAL(error(QLowEnergyController::Error)),
@@ -195,6 +186,8 @@ void Device::scanServices(const QString &address)
controller->setRemoteAddressType(QLowEnergyController::PublicAddress);
controller->connectToDevice();
//! [les-controller-1]
+
+ m_previousAddress = currentDevice.getAddress();
}
void Device::addLowEnergyService(const QBluetoothUuid &serviceUuid)