Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created July 27, 2018 08:38
Show Gist options
  • Save SunXiaoShan/1ef2d2133d573933c443e4aa3cfc953e to your computer and use it in GitHub Desktop.
Save SunXiaoShan/1ef2d2133d573933c443e4aa3cfc953e to your computer and use it in GitHub Desktop.
- (void)peripheral:(CBPeripheral *)peripheral
didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic
error:(NSError *)error {
if (error) {
return;
}
if (characteristic.value == nil) {
return;
}
NSString *value = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding];
if ([_delegate respondsToSelector:@selector(BLECentralComponentReceiveMessage:message:)]) {
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.delegate BLECentralComponentReceiveMessage:self message:value];
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment