flutter_blue icon indicating copy to clipboard operation
flutter_blue copied to clipboard

[iOS] bug in read descriptor value

Open lilinll77 opened this issue 2 years ago • 0 comments

code in iOS related file, if the service broadcast a string value long than 4 bytes, there are bug in flutter while read and parse the value

the org code

  • (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error xxxxxx int value = [descriptor.value intValue]; [result setValue:[NSData dataWithBytes:&value length:sizeof(value)]]; xxxxx xxxxx

i think should be fix it like this if ([descriptor.value isKindOfClass:[NSNumber class]]) { int value = [descriptor.value intValue]; [result setValue:[NSData dataWithBytes:&value length:sizeof(value)]]; } else if ([descriptor.value isKindOfClass:[NSString class]]) { NSString *value = descriptor.value; [result setValue:[value dataUsingEncoding:NSUTF8StringEncoding]]; }

lilinll77 avatar May 31 '22 10:05 lilinll77