发现和过滤蓝牙外围设备

时间:2019-12-17 21:33:57

标签: ios swift bluetooth core-bluetooth

使用

centralManager.scanForPeripherals(withServices: nil)

我打印出附近所有的蓝牙设备,输出示例为

<CBPeripheral: 0x2819241e0, identifier = CDF9E8B5-370B-A593-5AC5-F73E37BDC5C4, name = (null), state = disconnected>

然后我尝试使用此标识符过滤centralManager.scanForPeripherals():

let device = CBUUID(string: "CDF9E8B5-370B-A593-5AC5-F73E37BDC5C4")
centralManager.scanForPeripherals(withServices: [device])

,我什么也没得到,结论是这个标识符显然不是我需要的服务标识符。

如何找到我所有设备的服务标识符?或使用另一种过滤方式仅显示我要查找的内容。

0 个答案:

没有答案
相关问题