diff options
Diffstat (limited to 'src/bluetooth/osx')
-rw-r--r-- | src/bluetooth/osx/osxbtcentralmanager.mm | 8 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtledeviceinquiry.mm | 6 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtperipheralmanager.mm | 4 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtutility.mm | 15 | ||||
-rw-r--r-- | src/bluetooth/osx/osxbtutility_p.h | 3 |
5 files changed, 25 insertions, 11 deletions
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm index 15354f80..70473f1f 100644 --- a/src/bluetooth/osx/osxbtcentralmanager.mm +++ b/src/bluetooth/osx/osxbtcentralmanager.mm @@ -1031,7 +1031,7 @@ QT_END_NAMESPACE using namespace OSXBluetooth; const auto state = central.state; -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (state == CBManagerStateUnknown || state == CBManagerStateResetting) { #else @@ -1047,7 +1047,7 @@ QT_END_NAMESPACE } // Let's check some states we do not like first: -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) { #else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) { @@ -1067,7 +1067,7 @@ QT_END_NAMESPACE return; } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (state == CBManagerStatePoweredOff) { #else if (state == CBCentralManagerStatePoweredOff) { @@ -1086,7 +1086,7 @@ QT_END_NAMESPACE return; } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (state == CBManagerStatePoweredOn) { #else if (state == CBCentralManagerStatePoweredOn) { diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm index 05b20167..7a516dd4 100644 --- a/src/bluetooth/osx/osxbtledeviceinquiry.mm +++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm @@ -234,7 +234,7 @@ QT_USE_NAMESPACE Q_ASSERT(leQueue); const auto state = central.state; -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (state == CBManagerStatePoweredOn) { #else if (state == CBCentralManagerStatePoweredOn) { @@ -259,7 +259,7 @@ QT_USE_NAMESPACE [manager scanForPeripheralsWithServices:nil options:nil]; } // Else we ignore. -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) } else if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) { #else } else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) { @@ -276,7 +276,7 @@ QT_USE_NAMESPACE } [manager setDelegate:nil]; -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) } else if (state == CBManagerStatePoweredOff) { #else } else if (state == CBCentralManagerStatePoweredOff) { diff --git a/src/bluetooth/osx/osxbtperipheralmanager.mm b/src/bluetooth/osx/osxbtperipheralmanager.mm index 9c443cf6..64c8cd90 100644 --- a/src/bluetooth/osx/osxbtperipheralmanager.mm +++ b/src/bluetooth/osx/osxbtperipheralmanager.mm @@ -391,7 +391,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) if (peripheral != manager || !notifier) return; -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (peripheral.state == CBManagerStatePoweredOn) { #else if (peripheral.state == CBPeripheralManagerStatePoweredOn) { @@ -426,7 +426,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data) explicitly added again." */ -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) || QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13) if (peripheral.state == CBManagerStateUnauthorized || peripheral.state == CBManagerStateUnsupported) { #else diff --git a/src/bluetooth/osx/osxbtutility.mm b/src/bluetooth/osx/osxbtutility.mm index 1508c89f..e17006de 100644 --- a/src/bluetooth/osx/osxbtutility.mm +++ b/src/bluetooth/osx/osxbtutility.mm @@ -48,6 +48,7 @@ #ifndef QT_IOS_BLUETOOTH #import <IOBluetooth/objc/IOBluetoothSDPUUID.h> +#import <CoreFoundation/CoreFoundation.h> #if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12, __IPHONE_NA) #import <CoreBluetooth/CBUUID.h> #endif @@ -164,7 +165,19 @@ QString qt_error_string(IOReturn errorCode) } } -#endif +void qt_test_iobluetooth_runloop() +{ + // IOBluetooth heavily relies on a CFRunLoop machinery in a way it dispatches + // its callbacks. Technically, having a QThread with CFRunLoop-based event + // dispatcher would suffice. At the moment of writing we do not have such + // event dispatcher, so we only can work on the main thread. + if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) { + qCWarning(QT_BT_OSX) << "IOBluetooth works only on the main thread or a" + << "thread with a running CFRunLoop"; + } +} + +#endif // !QT_IOS_BLUETOOTH // Apple has: CBUUID, NSUUID, CFUUID, IOBluetoothSDPUUID diff --git a/src/bluetooth/osx/osxbtutility_p.h b/src/bluetooth/osx/osxbtutility_p.h index 5d90a54e..3312af12 100644 --- a/src/bluetooth/osx/osxbtutility_p.h +++ b/src/bluetooth/osx/osxbtutility_p.h @@ -287,8 +287,9 @@ BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &address); ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &uuid); QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid); QString qt_error_string(IOReturn errorCode); +void qt_test_iobluetooth_runloop(); -#endif +#endif // !QT_IOS_BLUETOOTH QBluetoothUuid qt_uuid(CBUUID *uuid); CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid); |