diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2016-11-08 16:47:51 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2016-11-09 14:15:40 +0000 |
commit | 8c2f88f2294ea871e374ef1a13ea4793854bd214 (patch) | |
tree | 5bea901e0caea907838c20812b955387b8531803 /src/bluetooth/osx/osxbtperipheralmanager.mm | |
parent | 85a626e83fa90bfae09be28e32c957f6bab2d861 (diff) | |
download | qtconnectivity-8c2f88f2294ea871e374ef1a13ea4793854bd214.tar.gz |
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/osxbtperipheralmanager.mm')
-rw-r--r-- | src/bluetooth/osx/osxbtperipheralmanager.mm | 14 |
1 files changed, 13 insertions, 1 deletions
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(); |