1

I'm a new developer developing a BLE service on iOS and Android. Currently there is a problem that I am facing, that the device address on iOS is the UUID mapped from the mac address, and on Android it is the mac address of the device. So now is there a way on iOS, from the mac address I received can get the corresponding UUID? Thanks everyone!

I am not sure how to do it.

Zeno
  • 11
  • 2

1 Answers1

3

the device address on iOS is the UUID mapped from the mac address

This is incorrect. The peripheral ID is not "from" the MAC address. It's just a random UUID. It's not even stable (it can, and does, change over time, though not quickly). There is no way on iOS to get the MAC address of a BLE device, or even to absolutely uniquely identify a BLE device unless you control the firmware. If you do control the firmware, then you can provide some mechanism to uniquely identify the device over a protocol of your own design.

As a broad rule, you can use the peripheral ID to identify or connect to a device you've connected to before. This isn't 100%, because the ID does change sometimes. But for the most part it does work (and it's intended to work, so Apple won't just break this arbitrarily). But you cannot otherwise identify the device.

As a corollary, the peripheral ID on one iPhone is completely unrelated to the peripheral ID on another phone for the same device. This is intentional.

You will have to adjust your design to deal with these facts.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Thanks for your answer. Maybe I used the wrong word. My understanding is that on each iOS device UUID and mac have a mapping relationship. However, what I'm interested in here is is there any way from my mac I can get the correct corresponding UUID? – Zeno Apr 04 '22 at 20:03
  • "My understanding is that on each iOS device UUID and mac have a mapping relationship." That's not correct. There is no meaningful relationship. (I don't know if Apple internally uses the MAC with some salt to generate the UUID, but even if they do, you don't have access to the salt, so it wouldn't help you.) There is no way to turn a MAC into the corresponding UUID. The UUID is not even consistent for the same device over time; it can change, though it does so rarely. And it is absolutely different from iPhone to iPhone. What led you to believe there is a mapping function? – Rob Napier Apr 04 '22 at 20:15
  • 2
    About every two years or so. Just be prepared when you enquire your UUID that it might not be the same as the last time, and if it is stored on a server, update the server. 10 years ago you could identify a specific device - with consequences from hilarious to disastrous if the user bought a new iPhone. The UUID is also application specific - app1 and app2 asking for the UUID will get totally different results. – gnasher729 Apr 04 '22 at 23:17