summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-01 21:57:38 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-01 21:57:38 +0200
commitc4b8dee6b4cfdc6728094d237d7984791e2cecea (patch)
tree884d11acf657ec14e478843b691dc84bc9ae8cd2
parentaabce3a08d1a65f8abc4872bd91a6dfd45cf7fd6 (diff)
parente53f828a1644fab1821a7696c190777a3bbb1880 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
-rw-r--r--src/bluetooth/osx/osxbtcentralmanager.mm21
-rw-r--r--src/bluetooth/osx/osxbtledeviceinquiry.mm13
2 files changed, 34 insertions, 0 deletions
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm
index 62009845..06425753 100644
--- a/src/bluetooth/osx/osxbtcentralmanager.mm
+++ b/src/bluetooth/osx/osxbtcentralmanager.mm
@@ -1077,10 +1077,19 @@ QT_END_NAMESPACE
{
using namespace OSXBluetooth;
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ const CBManagerState state = central.state;
+#else
const CBCentralManagerState state = central.state;
+#endif
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ if (state == CBManagerStateUnknown
+ || state == CBManagerStateResetting) {
+#else
if (state == CBCentralManagerStateUnknown
|| state == CBCentralManagerStateResetting) {
+#endif
// We still have to wait, docs say:
// "The current state of the central manager is unknown;
// an update is imminent." or
@@ -1090,7 +1099,11 @@ 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 (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) {
+#else
if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) {
+#endif
if (managerState == CentralManagerUpdating) {
// We tried to connect just to realize, LE is not supported. Report this.
managerState = CentralManagerIdle;
@@ -1106,7 +1119,11 @@ QT_END_NAMESPACE
return;
}
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ if (state == CBManagerStatePoweredOff) {
+#else
if (state == CBCentralManagerStatePoweredOff) {
+#endif
managerState = CentralManagerIdle;
if (managerState == CentralManagerUpdating) {
// I've seen this instead of Unsupported on OS X.
@@ -1121,7 +1138,11 @@ QT_END_NAMESPACE
return;
}
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ if (state == CBManagerStatePoweredOn) {
+#else
if (state == CBCentralManagerStatePoweredOn) {
+#endif
if (managerState == CentralManagerUpdating && !disconnectPending) {
managerState = CentralManagerIdle;
[self retrievePeripheralAndConnect];
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm
index 88370fa6..c3f515d0 100644
--- a/src/bluetooth/osx/osxbtledeviceinquiry.mm
+++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm
@@ -210,8 +210,13 @@ using namespace QT_NAMESPACE;
dispatch_queue_t leQueue(qt_LE_queue());
Q_ASSERT(leQueue);
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ const CBManagerState cbState(central.state);
+ if (cbState == CBManagerStatePoweredOn) {
+#else
const CBCentralManagerState cbState(central.state);
if (cbState == CBCentralManagerStatePoweredOn) {
+#endif
if (internalState == InquiryStarting) {
internalState = InquiryActive;
// Scan time is actually 10 seconds. Having a block with such delay can prevent
@@ -226,7 +231,11 @@ using namespace QT_NAMESPACE;
});
[manager scanForPeripheralsWithServices:nil options:nil];
} // Else we ignore.
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ } else if (state == CBManagerStateUnsupported || state == CBManagerStateUnauthorized) {
+#else
} else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) {
+#endif
if (internalState == InquiryActive) {
[manager stopScan];
// Not sure how this is possible at all, probably, can never happen.
@@ -236,7 +245,11 @@ using namespace QT_NAMESPACE;
}
[manager setDelegate:nil];
+#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0)
+ } else if (cbState == CBManagerStatePoweredOff) {
+#else
} else if (cbState == CBCentralManagerStatePoweredOff) {
+#endif
if (internalState == InquiryStarting) {
#ifndef Q_OS_OSX
// On iOS a user can see at this point an alert asking to enable