【问题标题】:CoreBluetooth - didDiscoverPeripheral in background mode not called without LightBlueCoreBluetooth - 在没有 LightBlue 的情况下不会调用后台模式下的 didDiscoverPeripheral
【发布时间】:2017-04-21 21:56:58
【问题描述】:

我正在尝试在后台扫描 BLE 设备,但我的 didDiscoverPeripheral 方法没有被调用。我已经等了 5 分钟,但什么也没发生,但是当我打开其他蓝牙应用程序(如“LightBlue”)时,我的 didDiscoverPeripheral 立即被调用。每次都会发生这种情况。如何在不运行 LightBlue 的情况下完成这项工作?

这是我的扫描代码: central.scanForPeripherals(withServices: [cbuuid], options: nil)

项目具有正确的后台设置,因为在启动 LightBlue 后 didDiscoverPeripheral 正在后台工作。

【问题讨论】:

    标签: ios swift bluetooth-lowenergy core-bluetooth


    【解决方案1】:

    我已经发现问题出在哪里了。

    蓝牙设备有两种广告,一种是无服务uuid​​。在后台 iOS 跳过没有服务 uuid 的广告。我已将设备内的所有广告包更改为具有服务 uuid,现在一切正常。

    【讨论】:

      猜你喜欢
      • 2014-09-22
      • 2021-09-05
      • 2014-03-30
      • 2014-12-14
      • 2020-12-02
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 2011-11-12
      相关资源
      最近更新 更多