I would like to get the MAC address of the device my iOS device connects to via BLE, but I can see only the UUID.
I've understood from searching the issue over the web that's it's not possible to get the MAC, but only in UUID. I've also understood that the UUID is generated by the iOS and that the device doesn't "know" it...however the posts i've found were old (2-3 years old) so I was wondering if anything has changed? Is there a way to get the MAC rather than the UUID, or at least reproduce the process that iOS does to convert UUID back to MAC address?
Thanks in advance
In iOS not possible to get mac address of CBPeripheral object. If CBPeripheral object advertisement mac address in "kCBAdvDataServiceData" value then convert to mac address, otherwise not possible. In iOS unique id is UUID for CBPeripheral. Every diff. iOS device shows diff. UUID of same CBPeripheral. If differentiate two or more CBPeripheral object then use RSSI range/value.
Related
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.
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.
I just started learning the ionic framework and I am working with BLE libraries.
I can scan for other BLE devices and get thier information when I run it on an Android phone (physical). The response look something like this...
'name': 'Device Name',
'id': 'DC:A6:32:D9:56:15',
'advertising': {},
'rssi': -35
link to documentation of BLE https://ionicframework.com/docs/v3/native/ble/
I was able to do the same thing on IOS BUT the MAC address/ID looks like this...
88C4BC81-E67F-E804-03C3-47E4296F577D
It looks like a serial number.
Can someone please explain to me why?
I look at different encoding and such but no luck.
To be honest I do not know what the right question is to ask.
Thank you for your help.
Sorry if this question is not clear.
The "MAC address/ID" on iOS is not a MAC address. You're reading the identifier property. That's a UUID created by the phone. It's generally consistent for a given device, but may change over time (though never during a single connection, and they don't generally change that often).
There is no way to get the MAC address of a CBPeripheral on iOS. There is no way to uniquely identify a BLE device on iOS in a way that is consistent across iOS devices, or that is promised to be permanent on a single iOS device.
I am developing an application that requires the ios device to provide Bluetooth UUID (to get the Bluetooth UUID from scanned/connected device), then send it to the server for further development. I can not find any answer on the internet.
I am using core bluetooth for scanning and connecting device and sent device info name and uuid but uuid changed every 15-20 minutes. How can i recognize previously connected device and how can i get unique BLE device UUID so that i can match identifier with previously added device list. Help please...
You can get the identifier property of the discovered CBPeripheral and connect to that. If you connect then the identifier should not change for that device for a significant amount of time (in practice I don't think it ever changes, but in theory it can).
Once you have a peripherals identifier you can save that value and subsequently get the peripheral via retrievePeripherals rather than scanning.
The issue you will face is that the identifier is specific to the iOS device that discovers the peripheral. Another iOS device will get a different identifier for the same peripheral.
If you need a unique identifier for your peripheral that is transportable across iOS devices then you will need to expose such a value via a characteristic on the peripheral itself and have your app read that characteristic value after it has connected.
Now I'm looking for the solution to get the correct peripheral from IOS.
Our situation is we have 3-5 ble devices which have the same NAME (say "ZL_RELAY02") And we also have MAC of each devices. In android it very easy because we have MAC address but for IOS how can we identify to correct peripheral?
This case is iPhone device doesn't know all peripherals attributes before. it just have MAC & Password of target peripheral from server.
Hope someone have an idea to help us.
Thanks
I'm working on an application for iOS (Objective-C).
I'm looking for a way to connect to a BLE device so that you can specify the MAC or UUID of this device.
Currently I have two BLE devices with the same name so the app is not able to differentiate between the two , which gives many problems (these devices do not have the same functions).
Is there any way to specify the MAC or UUID when connected to BLE device?
RSSI signal strength discover the differentiate two or more device.
If once time UUID get from peripheral then also differentiate peripheral.
Note: iOS doesn't give permission to read MAC address of peripheral.
The MAC of the device is not available, nor is any other particularly useful identifier. However, since "these devices do not have the same functions," they should have different services that they advertise. When calling scanForPeripherals(withServices:options:) you should be passing the specific service or services you're interested in. This is much better for performance, and also will automatically filter out devices you are not interested in. Passing nil for serviceUUIDs should only be done for a generic BLE scanner.
If you control the device firmware, you can add services to identify the type of device, or add information in the manufacturer's advertising data to distinguish the devices during scanning.
If these devices advertise the same services and are otherwise identical, then you will need to connect to both and query them to determine which device you wanted. You still will not receive a MAC, however, unless the device provides it via some characteristic.
Typically, a given device will continue to have the same CBPeripheral UUID, and this can be used to reconnect to previously known devices. However, if the device never pairs securely, this UUID is not always stable, either.