summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/osx
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2016-11-08 16:47:51 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2016-11-09 14:15:40 +0000
commit8c2f88f2294ea871e374ef1a13ea4793854bd214 (patch)
tree5bea901e0caea907838c20812b955387b8531803 /src/bluetooth/osx
parent85a626e83fa90bfae09be28e32c957f6bab2d861 (diff)
Emit descriptorWritten for notification/indication enabled/disabled
From CoreBluetooth's point of view - this is just a callback, not a descriptor write request (they even consider all descriptors immutable in peripheral), but for Qt it should be a descriptor write operation, and we must emit a signal. Oh, and set endHandle correctly on a LE service object! Change-Id: I71922507a6ece987ad8b5c317ef618301ae240c2 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/osx')
-rw-r--r--src/bluetooth/osx/osxbtnotifier_p.h1
-rw-r--r--src/bluetooth/osx/osxbtperipheralmanager.mm14
2 files changed, 14 insertions, 1 deletions
diff --git a/src/bluetooth/osx/osxbtnotifier_p.h b/src/bluetooth/osx/osxbtnotifier_p.h
index 0ffd7f51..47ee6ba1 100644
--- a/src/bluetooth/osx/osxbtnotifier_p.h
+++ b/src/bluetooth/osx/osxbtnotifier_p.h
@@ -88,6 +88,7 @@ Q_SIGNALS:
void characteristicUpdated(QLowEnergyHandle charHandle, const QByteArray &value);
void descriptorRead(QLowEnergyHandle descHandle, const QByteArray &value);
void descriptorWritten(QLowEnergyHandle descHandle, const QByteArray &value);
+ void notificationEnabled(QLowEnergyHandle charHandle, bool enabled);
void LEnotSupported();
void CBManagerError(QBluetoothDeviceDiscoveryAgent::Error error);
diff --git a/src/bluetooth/osx/osxbtperipheralmanager.mm b/src/bluetooth/osx/osxbtperipheralmanager.mm
index a44fb95c..1a461be9 100644
--- a/src/bluetooth/osx/osxbtperipheralmanager.mm
+++ b/src/bluetooth/osx/osxbtperipheralmanager.mm
@@ -236,6 +236,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
services.push_back(newCBService);
serviceIndex[data.uuid()] = newCBService;
+ newQtService->endHandle = lastHandle;
+
return newQtService;
}
@@ -357,6 +359,8 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
return;
}
+ emit notifier->characteristicWritten(charHandle, value);
+
const auto nsData = mutable_data_from_bytearray(value);
charValues[charHandle] = nsData;
// We copy data here: sending update requests is async (see sendUpdateRequests),
@@ -480,6 +484,9 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
return;
[self addConnectedCentral:central];
+
+ if (const auto handle = charMap.key(characteristic))
+ emit notifier->notificationEnabled(handle, true);
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central
@@ -491,6 +498,11 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
return;
[self removeConnectedCentral:central];
+
+ if (![connectedCentrals count]) {
+ if (const auto handle = charMap.key(characteristic))
+ emit notifier->notificationEnabled(handle, false);
+ }
}
- (void)peripheralManager:(CBPeripheralManager *)peripheral
@@ -757,7 +769,7 @@ bool qt_validate_value_range(const QLowEnergyCharacteristicData &data)
valueRanges[declHandle] = ValueRange(ch.minimumValueLength(), ch.maximumValueLength());
// QT part:
QLowEnergyServicePrivate::CharData charData;
- charData.valueHandle = ++lastHandle;
+ charData.valueHandle = declHandle;
charData.uuid = ch.uuid();
charData.properties = ch.properties();
charData.value = ch.value();