@@ -425,14 +425,14 @@ - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(C
425
425
NSLog (@" didUpdateValueForCharacteristic %@ " , [peripheral.identifier UUIDString ]);
426
426
ProtosReadCharacteristicResponse *result = [[ProtosReadCharacteristicResponse alloc ] init ];
427
427
[result setRemoteId: [peripheral.identifier UUIDString ]];
428
- [result setCharacteristic: [self toCharacteristicProto: characteristic]];
428
+ [result setCharacteristic: [self toCharacteristicProto: peripheral characteristic: characteristic]];
429
429
[_channel invokeMethod: @" ReadCharacteristicResponse" arguments: [self toFlutterData: result]];
430
430
431
431
// on iOS, this method also handles notification values
432
- ProtosOnCharacteristicChanged *result = [[ProtosOnCharacteristicChanged alloc ] init ];
433
- [result setRemoteId: [peripheral.identifier UUIDString ]];
434
- [result setCharacteristic: [self toCharacteristicProto: characteristic]];
435
- [_channel invokeMethod: @" OnCharacteristicChanged" arguments: [self toFlutterData: result ]];
432
+ ProtosOnCharacteristicChanged *onChangedResult = [[ProtosOnCharacteristicChanged alloc ] init ];
433
+ [onChangedResult setRemoteId: [peripheral.identifier UUIDString ]];
434
+ [onChangedResult setCharacteristic: [self toCharacteristicProto: peripheral characteristic : characteristic]];
435
+ [_channel invokeMethod: @" OnCharacteristicChanged" arguments: [self toFlutterData: onChangedResult ]];
436
436
}
437
437
438
438
- (void )peripheral : (CBPeripheral *)peripheral didWriteValueForCharacteristic : (CBCharacteristic *)characteristic error : (NSError *)error {
@@ -455,7 +455,7 @@ - (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForChara
455
455
// Send error
456
456
ProtosSetNotificationResponse *response = [[ProtosSetNotificationResponse alloc ] init ];
457
457
[response setRemoteId: [peripheral.identifier UUIDString ]];
458
- [response setCharacteristic: [self toCharacteristicProto: characteristic]];
458
+ [response setCharacteristic: [self toCharacteristicProto: peripheral characteristic: characteristic]];
459
459
[response setSuccess: false ];
460
460
[_channel invokeMethod: @" SetNotificationResponse" arguments: [self toFlutterData: response]];
461
461
return ;
@@ -487,7 +487,7 @@ - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDes
487
487
if ([descriptor.UUID.UUIDString isEqualToString: @" 2902" ]){
488
488
ProtosSetNotificationResponse *response = [[ProtosSetNotificationResponse alloc ] init ];
489
489
[response setRemoteId: [peripheral.identifier UUIDString ]];
490
- [response setCharacteristic: [self toCharacteristicProto: descriptor.characteristic]];
490
+ [response setCharacteristic: [self toCharacteristicProto: peripheral characteristic: descriptor.characteristic]];
491
491
[response setSuccess: true ];
492
492
[_channel invokeMethod: @" SetNotificationResponse" arguments: [self toFlutterData: response]];
493
493
}
@@ -629,7 +629,7 @@ - (ProtosBluetoothService*)toServiceProto:(CBPeripheral *)peripheral service:(CB
629
629
// Characteristic Array
630
630
NSMutableArray *characteristicProtos = [NSMutableArray new ];
631
631
for (CBCharacteristic *c in [service characteristics ]) {
632
- [characteristicProtos addObject: [self toCharacteristicProto: c]];
632
+ [characteristicProtos addObject: [self toCharacteristicProto: peripheral characteristic: c]];
633
633
}
634
634
[result setCharacteristicsArray: characteristicProtos];
635
635
@@ -643,15 +643,16 @@ - (ProtosBluetoothService*)toServiceProto:(CBPeripheral *)peripheral service:(CB
643
643
return result;
644
644
}
645
645
646
- - (ProtosBluetoothCharacteristic*)toCharacteristicProto : (CBCharacteristic *)characteristic {
646
+ - (ProtosBluetoothCharacteristic*)toCharacteristicProto : (CBPeripheral *) peripheral characteristic : ( CBCharacteristic *)characteristic {
647
647
ProtosBluetoothCharacteristic *result = [[ProtosBluetoothCharacteristic alloc ] init ];
648
648
[result setUuid: [characteristic.UUID fullUUIDString ]];
649
+ [result setRemoteId: [peripheral.identifier UUIDString ]];
649
650
[result setProperties: [self toCharacteristicPropsProto: characteristic.properties]];
650
651
[result setValue: [characteristic value ]];
651
652
NSLog (@" uuid: %@ value: %@ " , [characteristic.UUID fullUUIDString ], [characteristic value ]);
652
653
NSMutableArray *descriptorProtos = [NSMutableArray new ];
653
654
for (CBDescriptor *d in [characteristic descriptors ]) {
654
- [descriptorProtos addObject: [self toDescriptorProto: d]];
655
+ [descriptorProtos addObject: [self toDescriptorProto: peripheral descriptor: d]];
655
656
}
656
657
[result setDescriptorsArray: descriptorProtos];
657
658
if ([characteristic.service isPrimary ]) {
@@ -665,9 +666,10 @@ - (ProtosBluetoothCharacteristic*)toCharacteristicProto:(CBCharacteristic *)char
665
666
return result;
666
667
}
667
668
668
- - (ProtosBluetoothDescriptor*)toDescriptorProto : (CBDescriptor *)descriptor {
669
+ - (ProtosBluetoothDescriptor*)toDescriptorProto : (CBPeripheral *) peripheral descriptor : ( CBDescriptor *)descriptor {
669
670
ProtosBluetoothDescriptor *result = [[ProtosBluetoothDescriptor alloc ] init ];
670
671
[result setUuid: [descriptor.UUID fullUUIDString ]];
672
+ [result setRemoteId: [peripheral.identifier UUIDString ]];
671
673
[result setCharacteristicUuid: [descriptor.characteristic.UUID fullUUIDString ]];
672
674
[result setServiceUuid: [descriptor.characteristic.service.UUID fullUUIDString ]];
673
675
int value = [descriptor.value intValue ];
0 commit comments