大多数情况下,这在我的应用程序中正常运行。不幸的是,有时在调用discoverservice之后从未触发过它。
我的代码是:
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
{
NSLog(@"Did connect to peripheral: %@", peripheral);
[self.delegate statusMessage:[NSString stringWithFormat:@"Did connect to peripheral: %@\n", peripheral]];
peripheral.Delegate = self;
NSArray *serviceArray = [NSArray arrayWithObject:_uuid_tpms_sensor_service];
[_peripheral discoverServices:serviceArray];
[peripheral discoverServices:serviceArray ];
}
与之相关的一些帖子是
最终结论应该是iOS中的一个问题。我的问题是,鉴于这是iOS问题,该如何解决?
非常感谢Larme和henrik,我从您的回复中得到了很多想法。
经过三天的验证,看来我已经找到解决该问题的方法(该问题很可能是iOS的蓝牙堆栈的局限性而非问题)
我想总结一下我的发现并在这里解决:
[根本原因]
follow the API sequence of connectperiperal-->discover-->read-->disconnect
(由本地,对等设备触发或在链路层上监视超时)。[解析度]
希望摘要对其他人有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句