gpt4 book ai didi

ios - DiscoverServices 有时从不触发

转载 作者:行者123 更新时间:2023-11-29 02:43:02 24 4
gpt4 key购买 nike

大多数时候,这在我的应用程序中正常工作。不幸的是,有时它在调用 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中的issue。我的问题是,鉴于这是 iOS 问题,如何解决这个问题?

最佳答案

非常感谢 Larme 和 henrik,我从你们的回复中得到了很多想法。

经过三天的验证,我似乎找到了解决这个问题的方法(这个问题更可能是 iOS 蓝牙堆栈的限制而不是问题)

我想总结一下我的发现并解决这个问题:

[根本原因]

  • iOS 中的蓝牙堆栈不够健壮,因此内部状态机在一些意外的 API 调用后损坏。
  • 由于 BTLE radio 遵循某种模式,一次与一个设备连接查询进行交互,BLE 应用程序应遵循 connectperiperal-->discover-->read-->disconnect 的 API 顺序(由本地、对等设备或链路层上的监管超时触发)。
  • Apple 承认这是 iOS 中的一个问题。

[分辨率]

  • 按照上面描述的API调用顺序

希望总结对其他人有用。

关于ios - DiscoverServices 有时从不触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25518394/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com