[英]iOS: Not receiving the write requests from Central to Peripheral
我正在尝试获取来自Central的写入请求,并且没有在Peripheral中调用相同的委托。 如果我从Central取消订阅特征,那么将调用didUnsubscribeFromCharacteristic。 我不确定如何在外围应用程序中获得请求。
[外围写入值:特征数据:特征类型:CBCharacteristicWriteWithResponse];
尝试调用类型为CBCharacteristicWriteWithoutResponse的相同方法,但未按预期工作。
任何帮助将被申请。
提前致谢!
我认为在Peripheral中,您应该调用didReceiveWriteRequests
委托。
您如何在外围设备中初始化自己的特性? 检查其属性,您需要:
properties: CBCharacteristicPropertyWrite
permissions: CBAttributePermissionWriteable
调用哪个PeripheralManager Delegate方法? 必须不仅是外围设备管理器:中央:didUnsubscribeFromCharacteristic
peripheralManagerDidUpdateState
peripheralManager:didAddService:error
peripheralManagerDidStartAdvertising:error
...
请参阅CBPeripheralManagerDelegate。...检查是否全部调用了该错误。 您的服务/特性可能有问题...
并检查是否也调用了您中心的方法。 例如
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service
error:(NSError *)error
而且,当然,您必须使用正确的委托在外围设备中初始化外周管理器(并实现所有其他需要的委托方法):
self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.