Created
July 27, 2018 08:15
-
-
Save SunXiaoShan/f1cc6c0f9d43bf9db2ee8a2432c3593c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)peripheralManager:(CBPeripheralManager *)peripheral | |
| didReceiveWriteRequests:(NSArray <CBATTRequest *>*)requests { | |
| for (CBATTRequest *request in requests) { | |
| if (request.value) { | |
| NSString *value = [[NSString alloc] initWithData:request.value encoding:NSUTF8StringEncoding]; | |
| if ([_delegate respondsToSelector:@selector(BLEPeripheralComponentReceiveMessage:message:)]) { | |
| __weak typeof(self) weakSelf = self; | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| [weakSelf.delegate BLEPeripheralComponentReceiveMessage:self message:value]; | |
| }); | |
| } | |
| [peripheral respondToRequest:request withResult:CBATTErrorSuccess]; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment