CBPeripheral, Get Local Peripheral Identifier

7.8k views Asked by At

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.

1

There are 1 answers

7
davidgyoung On BEST ANSWER

Unfortunately you can't do this. The identifier returned by [peripheral.identifier UUIDString] is auto generated by iOS on the receiving device. It is seeded by the transmitter Mac address (which does not change) and the time the device starts being seen by iOS (which does change).

Because of the second factor is not predictable and the fact that the id generation algorithm is not published, you cannot predict what this id will be on the transmitter side.

Bottom line, if you want a predictable unique id, you cannot use this field