【问题标题】:Core Bluetooth scan for peripherals does not work time to time外围设备的核心蓝牙扫描有时不工作
【发布时间】:2016-08-02 15:04:20
【问题描述】:

我使用此方法- (void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options; 开始扫描我的外围设备。但有时它不起作用。我没有收到外围设备不时发现的回调。

didFinishLaunchingWithOptions 开始扫描似乎并不总是有效。

【问题讨论】:

  • 你需要显示更多代码
  • 它最初是否会发现设备并在一段时间后停止,或者回调没有像您预期的那样频繁调用?

标签: ios objective-c bluetooth core-bluetooth


【解决方案1】:

不确定我是否能完全回答,因为您只提供了一小段 sn-p 代码。但: 1. scanForPeripheralsWithServices 仅查找具有该特定服务的外围设备。没有找到其他人。更多信息 - 看看这个answer 2. 要查找所有外围设备,我建议将 didDiscoverPeripheral 方法与 didDiscoverServices 结合使用来查找所有外围设备,然后选择一个具有所需服务的外围设备。 希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-08
    相关资源
    最近更新 更多