diff options
author | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-05-20 11:37:12 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-05-23 05:48:58 +0000 |
commit | 20ab809d4ad00f480e448d64e1890c8856871044 (patch) | |
tree | c8b70f9fcaecff434444fbfd40ba6c38165d0aa9 | |
parent | 2d98ac01e74dc53d9fd42668e3757ca806af9556 (diff) |
QtBluetooth (BTLE) - fix build on tvOS
CoreBluetooth for tvOS does not support peripheral role.
Change-Id: I82e7a61abfd907ea53faf33264951727f3cbe5a2
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r-- | src/bluetooth/osx/osxbt.pri | 12 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_osx.mm | 37 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_osx_p.h | 2 |
3 files changed, 45 insertions, 6 deletions
diff --git a/src/bluetooth/osx/osxbt.pri b/src/bluetooth/osx/osxbt.pri index fc0a5a65..8d5486f4 100644 --- a/src/bluetooth/osx/osxbt.pri +++ b/src/bluetooth/osx/osxbt.pri @@ -39,11 +39,15 @@ CONFIG(osx) { osx/osxbtledeviceinquiry_p.h \ osx/corebluetoothwrapper_p.h \ osx/osxbtcentralmanager_p.h \ - osx/osxbtnotifier_p.h \ - osx/osxbtperipheralmanager_p.h + osx/osxbtnotifier_p.h + ios { + PRIVATE_HEADERS += osx/osxbtperipheralmanager_p.h + } OBJECTIVE_SOURCES += osx/osxbtutility.mm \ osx/osxbtledeviceinquiry.mm \ - osx/osxbtcentralmanager.mm \ - osx/osxbtperipheralmanager.mm + osx/osxbtcentralmanager.mm + ios { + OBJECTIVE_SOURCES += osx/osxbtperipheralmanager.mm + } } diff --git a/src/bluetooth/qlowenergycontroller_osx.mm b/src/bluetooth/qlowenergycontroller_osx.mm index 1e0f84d8..97c154d7 100644 --- a/src/bluetooth/qlowenergycontroller_osx.mm +++ b/src/bluetooth/qlowenergycontroller_osx.mm @@ -162,6 +162,7 @@ QLowEnergyControllerPrivateOSX::QLowEnergyControllerPrivateOSX(QLowEnergyControl QScopedPointer<LECBManagerNotifier> notifier(new LECBManagerNotifier); if (role == QLowEnergyController::PeripheralRole) { +#ifndef Q_OS_TVOS if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_6_0)) { peripheralManager.reset([[ObjCPeripheralManager alloc] initWith:notifier.data()]); if (!peripheralManager) { @@ -170,6 +171,9 @@ QLowEnergyControllerPrivateOSX::QLowEnergyControllerPrivateOSX(QLowEnergyControl return; } } else { +#else + { +#endif qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "peripheral role is not supported on your platform"; return; @@ -200,19 +204,25 @@ QLowEnergyControllerPrivateOSX::~QLowEnergyControllerPrivateOSX() [manager detach]; }); } else { +#ifndef Q_OS_TVOS if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_6_0)) { const auto manager = peripheralManager.data(); dispatch_sync(leQueue, ^{ [manager detach]; }); } +#endif } } } bool QLowEnergyControllerPrivateOSX::isValid() const { +#ifdef Q_OS_TVOS + return centralManager; +#else return centralManager || peripheralManager; +#endif } void QLowEnergyControllerPrivateOSX::_q_connected() @@ -720,13 +730,16 @@ void QLowEnergyControllerPrivateOSX::writeCharacteristic(QSharedPointer<QLowEner withResponse:mode == QLowEnergyService::WriteWithResponse]; }); } else { - +#ifndef Q_OS_TVOS if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_6_0)) { const auto manager = peripheralManager.data(); dispatch_async(leQueue, ^{ [manager write:newValueCopy charHandle:charHandle]; }); } else { +#else + { +#endif qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "peripheral role is not supported on your platform"; } @@ -1220,6 +1233,13 @@ void QLowEnergyController::startAdvertising(const QLowEnergyAdvertisingParameter const QLowEnergyAdvertisingData &advertisingData, const QLowEnergyAdvertisingData &scanResponseData) { +#ifdef Q_OS_TVOS + Q_UNUSED(params) + Q_UNUSED(advertisingData) + Q_UNUSED(scanResponseData) + qCWarning(QT_BT_OSX) << Q_FUNC_INFO + << "advertising is not supported on your platform"; +#else OSX_D_PTR; if (!osx_d_ptr->isValid()) @@ -1253,10 +1273,15 @@ void QLowEnergyController::startAdvertising(const QLowEnergyAdvertisingParameter dispatch_async(leQueue, ^{ [manager startAdvertising]; }); +#endif } void QLowEnergyController::stopAdvertising() { +#ifdef Q_OS_TVOS + qCWarning(QT_BT_OSX) << Q_FUNC_INFO + << "advertising is not supported on your platform"; +#else OSX_D_PTR; if (!osx_d_ptr->isValid()) @@ -1280,11 +1305,18 @@ void QLowEnergyController::stopAdvertising() osx_d_ptr->setErrorDescription(QLowEnergyController::UnknownError); return; } +#endif } QLowEnergyService *QLowEnergyController::addService(const QLowEnergyServiceData &data, QObject *parent) { +#ifdef Q_OS_TVOS + Q_UNUSED(data) + Q_UNUSED(parent) + qCWarning(QT_BT_OSX) << Q_FUNC_INFO + << "peripheral role is not supported on your platform"; +#else OSX_D_PTR; if (!osx_d_ptr->isValid()) { @@ -1315,6 +1347,7 @@ QLowEnergyService *QLowEnergyController::addService(const QLowEnergyServiceData osx_d_ptr->discoveredServices.insert(servicePrivate->uuid, servicePrivate); return new QLowEnergyService(servicePrivate, parent); } +#endif return nullptr; } @@ -1322,7 +1355,7 @@ QLowEnergyService *QLowEnergyController::addService(const QLowEnergyServiceData void QLowEnergyController::requestConnectionUpdate(const QLowEnergyConnectionParameters ¶ms) { Q_UNUSED(params); - qCWarning(QT_BT_OSX) << "Connection update not implemented for OS X"; + qCWarning(QT_BT_OSX) << "Connection update not implemented on your platform"; } QT_END_NAMESPACE diff --git a/src/bluetooth/qlowenergycontroller_osx_p.h b/src/bluetooth/qlowenergycontroller_osx_p.h index f6e2a03e..b7399ed7 100644 --- a/src/bluetooth/qlowenergycontroller_osx_p.h +++ b/src/bluetooth/qlowenergycontroller_osx_p.h @@ -168,9 +168,11 @@ private: typedef OSXBluetooth::ObjCScopedPointer<ObjCCentralManager> CentralManager; CentralManager centralManager; +#ifndef Q_OS_TVOS typedef QT_MANGLE_NAMESPACE(OSXBTPeripheralManager) ObjCPeripheralManager; typedef OSXBluetooth::ObjCScopedPointer<ObjCPeripheralManager> PeripheralManager; PeripheralManager peripheralManager; +#endif typedef QMap<QBluetoothUuid, QSharedPointer<QLowEnergyServicePrivate> > ServiceMap; typedef ServiceMap::const_iterator ConstServiceIterator; |