From 153c6ba7a413ef6c4b5a5e1b89b8273687323ca8 Mon Sep 17 00:00:00 2001 From: Nebojsa Cvetkovic Date: Wed, 6 Nov 2024 20:04:09 -0500 Subject: [PATCH] [Fix] Descriptor primary/secondary service support on iOS --- ios/Classes/FlutterBluePlusPlugin.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/Classes/FlutterBluePlusPlugin.m b/ios/Classes/FlutterBluePlusPlugin.m index f72afc45..679fea16 100644 --- a/ios/Classes/FlutterBluePlusPlugin.m +++ b/ios/Classes/FlutterBluePlusPlugin.m @@ -1919,6 +1919,8 @@ - (NSDictionary *)bmBluetoothService:(CBPeripheral *)peripheral service:(CBServi - (NSDictionary*)bmBluetoothCharacteristic:(CBPeripheral *)peripheral characteristic:(CBCharacteristic *)characteristic { + ServicePair *pair = [self getServicePair:peripheral characteristic:characteristic]; + // descriptors NSMutableArray *descriptors = [NSMutableArray new]; for (CBDescriptor *d in [characteristic descriptors]) @@ -1926,10 +1928,10 @@ - (NSDictionary*)bmBluetoothCharacteristic:(CBPeripheral *)peripheral // See: BmBluetoothDescriptor NSDictionary* desc = @{ @"remote_id": [peripheral.identifier UUIDString], - @"service_uuid": [d.characteristic.service.UUID uuidStr], - @"service_index": d.characteristic.service.hash, - @"secondary_service_uuid": [NSNull null], - @"secondary_service_index": [NSNull null], + @"service_uuid": [pair.primary.UUID uuidStr], + @"service_index": pair.primary.hash, + @"secondary_service_uuid": pair.secondary ? [pair.secondary.UUID uuidStr] : [NSNull null], + @"secondary_service_index": pair.secondary ? pair.secondary.hash : [NSNull null], @"characteristic_uuid": [d.characteristic.UUID uuidStr], @"characteristic_index": d.characteristic.hash, @"descriptor_uuid": [d.UUID uuidStr], @@ -1938,8 +1940,6 @@ - (NSDictionary*)bmBluetoothCharacteristic:(CBPeripheral *)peripheral [descriptors addObject:desc]; } - ServicePair *pair = [self getServicePair:peripheral characteristic:characteristic]; - CBCharacteristicProperties props = characteristic.properties; // See: BmCharacteristicProperties