Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CBPeripheral, Get Local Peripheral Identifier

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.

like image 963
Roman F Avatar asked Dec 19 '22 09:12

Roman F


1 Answers

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

like image 65
davidgyoung Avatar answered Dec 24 '22 01:12

davidgyoung