0

I use CoreBluetooth to connect my iPhone with a device equipped with Bluetooth 4.0.

I print its (as a peripheral) UUID :

<CBPeripheral: 0x1742fca80, identifier = B148AD69-1FC7-498C-016F-33BA3BE041A3, name = HMSoft, state = disconnected>

I wonder whether this identifier is an inherent attribute of a device.

Since I use the following code in android to get its UUID which is different from what I get using CoreBluetooth in iPhone:

 BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
 for (ParcelUuid uuid : device.getUuids()) {
                    Log.d("UUID", uuid.getUuid().toString());
                }

( I connect with the same device but the print UUID is different).

rmaddy
  • 314,917
  • 42
  • 532
  • 579
chenzhongpu
  • 6,193
  • 8
  • 41
  • 79
  • possible duplicate of [Corebluetooth, How to get a unique UUID?](http://stackoverflow.com/questions/12524871/corebluetooth-how-to-get-a-unique-uuid) – Paulw11 Jan 15 '15 at 03:14
  • **UUID** of a peripheral is unique in every scanning, but iPhone and Android scanned different result. – chenzhongpu Jan 15 '15 at 04:21
  • That's right. A given iOS device will always see the same UUID for a given peripheral but different iOS devices will get a different UUID for the same peripheral and the UUID is not the MAC address - it is created by iOS – Paulw11 Jan 15 '15 at 04:22
  • *android* has API get the peripheral's mac address while **coreBluetooth** in *iOS* seems there is no public API. How to get the unique identifier that has consistency for both *iOS* and *android* ? – chenzhongpu Jan 15 '15 at 05:24
  • 1
    You can't - iOS doesn't expose that identifier. I did see one answer where the device information characteristic of the device contained the MAC,but that is probably device dependent and requires that you connect to the device to read the characteristic – Paulw11 Jan 15 '15 at 05:31

2 Answers2

0

Identifier in CBPeripheral is a randomly generated Unique identifier. This gets varied over time. In case of a CBPeripheral, we need to know about two kinds of UUIDs. One is ServiceUUID and other is CharacteristicUUID. Each peripheral broadcast data over each service. A single service can have more than one characteristics. For eg. a device information service can have device name, device version etc as its characteristics.

See the following image for a better understanding CBPeripheral. The Apple docs speaks well on this.

krishnanunni
  • 510
  • 7
  • 16
0

My first answer, so I hope I won't make a fool of myself ;-)

BluetoothDevice.getUuids(): Returns the supported features (UUIDs) of the remote device. I.e. UUIDs of services advertised by the device, not UUID of the device itself. I'm currently looking myself for an Android way to get the UUID of a discovered BLE device...

Sebastian Lenartowicz
  • 4,695
  • 4
  • 28
  • 39