我正在尝试将所有连接的外围设备列表添加到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)")
}
}
答案 0 :(得分:1)
如果你想获得所有连接的外围设备,我的建议是:添加字符串180A作为retrieveConnectedPeripherals的参数。所有蓝牙智能设备都实现设备信息(180A)服务(至少这一项)。