【问题标题】:How to detect a paired bluetooth device wake up and connected in iOS?如何检测配对的蓝牙设备在 iOS 中唤醒和连接?
【发布时间】:2020-03-23 16:46:51
【问题描述】:

我可以使用CBCentralManager.retrieveConnectedPeripherals(withServices:) 获得一次配对的蓝牙设备列表。有没有办法检测此列表中的更改,即当配对设备打开并连接时某些代表或通知触发? centralManager(_:didConnect:) 在这种情况下不会触发。 我想检测配对的 HID(远程相机快门)连接。

【问题讨论】:

  • 经典蓝牙还是BLE?

标签: ios swift bluetooth


【解决方案1】:

centralManager(_:didDiscover:advertisementData:rssi:)怎么样

【讨论】:

  • 也不触发。
  • 您可以将centralManager?.scanForPeripherals(withServices: nil, options: options) 放入didDiscoverPeripheral 中以继续扫描蓝牙设备
  • 我正在运行扫描,但这不是问题。设备已配对并在唤醒后立即连接,无需触发扫描仪。
  • 您是否将您的班级设置为 delegate = self?
  • 是的。我可以扫描和连接未在操作系统级别配对的 BLE 设备,并且代表可以正常触发。我的问题是在操作系统级别配对的蓝牙 HID 设备在唤醒时不会触发任何代表。我想检测到
【解决方案2】:

注册 EAAccessoryDidConnectNotification 以在蓝牙设备连接时收到通知。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多