4

I faced a problem about CoreBluetooth Framework.

As Example, I have two devices and each device performs both advertising and scanning. So, I use CBCentralManager and CBPeripheralManager on each.

So, to simplify problem, let's assume that Device1 is broadcasting and Device2 scanning.

When CBCentralManager on Device2 discover the Device1, callback centralManager:didDiscoverPeripheral:advertisementData:RSSI: is called and I can get Device1 identifier by calling [peripheral.identifier UUIDString].

How then I can get my local device (Device2) Identifier? I mean in case that both devices are advertising, Device1 will discover Device2 too and get it's peripheral identifier, but How can I get exact this identifier (some kind of self-address) on Device2?

P.S. I know that this Identifier is not unique for each device and can change over the time, it's not a problem.

4

1 回答 1

11

不幸的是,你不能这样做。返回的标识符[peripheral.identifier UUIDString]由 iOS 在接收设备上自动生成。它由发送器 Mac 地址(不会更改)和 iOS 开始看到设备的时间(确实会更改)播种。

由于第二个因素是不可预测的,并且没有公布 id 生成算法的事实,你无法预测这个 id 在发送方将是什么。

底线,如果你想要一个可预测的唯一 id,你不能使用这个字段

于 2014-11-14T13:43:27.393 回答