【发布时间】:2015-03-13 09:52:40
【问题描述】:
我使用 CoreBluetooth 将我的 iPhone 与配备 Bluetooth 4.0 的设备连接。
我打印它的(作为外围设备)UUID:
<CBPeripheral: 0x1742fca80, identifier = B148AD69-1FC7-498C-016F-33BA3BE041A3, name = HMSoft, state = disconnected>
我想知道这个标识符是否是设备的固有属性。
由于我在 android 中使用以下代码来获取它的 UUID,这与我在 iPhone 中使用 CoreBluetooth 得到的不同: p>
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
for (ParcelUuid uuid : device.getUuids()) {
Log.d("UUID", uuid.getUuid().toString());
}
(我连接的是同一个设备,但打印的 UUID 不同)。
【问题讨论】:
-
外设的UUID在每次扫描中都是唯一的,但iPhone和Android扫描的结果不同。
-
没错。给定的 iOS 设备对于给定的外围设备将始终看到相同的 UUID,但不同的 iOS 设备将为同一外围设备获得不同的 UUID,并且 UUID 不是 MAC 地址 - 它是由 iOS 创建的
-
android 有 API 获取外围设备的 mac 地址,而 iOS 中的 coreBluetooth 似乎没有公共 API。如何获取对 iOS 和 android 都具有一致性的唯一标识符?
-
您不能 - iOS 不会公开该标识符。我确实看到了一个答案,其中设备的设备信息特征包含 MAC,但这可能取决于设备,需要您连接到设备才能读取特征
标签: android ios uuid core-bluetooth