![](/img/trans.png)
[英]How does a CBPeripheralManager know it is connected or disconnected by a central device in Core Bluetooth?
[英]How to know if a Bluetooth Device is Connected in iOS?
了解蓝牙设备如何连接的最佳方式是什么? 我正在使用CBCentralManager来识别蓝牙是否已打开,但我无法找出如何识别蓝牙设备是否已连接。
我正在通过连接的蓝牙设备实现 AVAudioSession 呼叫的路由,但 AudioSession 类别更改被重复调用,因此我无法找到蓝牙设备是否已连接。 如果有人尝试实施此行为,您的输入可能会有所帮助。 请分享信息。
我正在使用CBPeripheral.state ==.connected
来检查 BLE 设备的 state。
从文档中:
/**
* @enum CBPeripheralState
*
* @discussion Represents the current connection state of a CBPeripheral.
*
*/
@available(iOS 7.0, *)
public enum CBPeripheralState : Int {
case disconnected = 0
case connecting = 1
case connected = 2
@available(iOS 9.0, *)
case disconnecting = 3
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.