我有两个项目。一个充当中心,另一个充当外围设备。 Central已连接到外围设备,然后是中央呼叫方法readValueForCharacteristic
。
不是立即,但在大约5-10秒后,外围设备调用委托方法- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request
。为什么会有延迟?如何消除延迟?
有什么想法吗?我已经尝试了差不多一个星期了。
感谢每一个帮助,谢谢
- (void)sendBtnClick:(id)sender
{
USCPeerBtn *btn = (USCPeerBtn *)sender;
CBPeripheral *peripheral = btn.connectedPeripheral;
if (!peripheral) {
return;
}
[self.charachterMDict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
if (key == peripheral) {
[(CBPeripheral *)key readValueForCharacteristic:(CBCharacteristic *)obj]; // read
*stop = YES;
}
}];
}
// CBPeripheralManagerDelegate
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request
{
NSLog(@"didReceiveReadRequest");
}
答案 0 :(得分:0)
在方法respondToRequest:
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request
// CBPeripheralManagerDelegate
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request
{
[peripheral respondToRequest:request withResult:CBATTErrorSuccess];
NSLog(@"didReceiveReadRequest");
}
@ Paulw11,谢谢