【问题标题】:How to retrieve all connected bluetooth peripherals如何检索所有连接的蓝牙外围设备
【发布时间】:2017-10-02 12:15:52
【问题描述】:

我正在尝试获取所有连接到 iPhone 的外围设备的列表。我连接了 Bose Soundlink,但它没有显示在我的应用程序中。我不知道 UUID,所以正在传递 [] 因为这应该得到我的想法?

func centralManagerDidUpdateState(_ central: CBCentralManager) {
    var message = ""

    switch central.state {
      case .poweredOn:
         message = "Bluetooth LE is turned on and ready for communication."

         // scan for ALL devices
        centralManager.scanForPeripherals(withServices: nil, options: nil)

         let connectedPeripherals = self.centralManager.retrieveConnectedPeripherals(withServices: []) 
        // WILL [] RETURN ALL CONNECTED PERIPHERALS?
        print("connectedPeripherals are \(connectedPeripherals)")
    }
}

【问题讨论】:

标签: ios swift bluetooth-lowenergy


【解决方案1】:

如果要获取所有已连接的外设,我的建议是:将字符串 180A 作为参数添加到retrieveConnectedPeripherals。所有蓝牙智能设备都实现了 DEVICE INFORMATION (180A) 服务(至少是这个)。

【讨论】:

    猜你喜欢
    • 2013-10-13
    • 1970-01-01
    • 2019-09-26
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 2012-01-20
    • 2017-07-12
    • 1970-01-01
    相关资源
    最近更新 更多