my question is the UUID of CBPeripheral seems not to be unique.
I have two iPad2, and a bluetooth4.0 device.
The UUID of the bluetooth device differs from the two iPad.
As shown in following images.
Is there any way to find a unique UUID of bluetooth device on iOS device?
I need to find a UUID or mac address that would not change between different devices.
Thank you very much, please help me!!
I was looking for a way to deploy platform-independent, static configurations of BLE devices. I was getting discouraged (Apple's UUIDs are +/- meaningless, and the MAC/BDADDR which can be obtained on most/all other platforms is not accessible from CoreBluetooth). Fortunately, I noticed that the "Device Information Service" profile (0x180A) contains a "System ID" attribute (0x2A23) which encodes the device's unique MAC/BDADDR address. I don't know if it is mandatory for a BLE device to expose this service, however.
The peripheral uses a random resolvable address that changes at least every 15 minutes, at which point the peripheral will appear to be new. To change this behavior you need to pair with the peripheral, then you will see the UUID and it will be persistent.
To answer your question, the UUID is unique given the same pair iDevice-btDevice, but it changes if you change the iOS device, as you noticed in your try.
To reach the goal to have a unique identifier, unfortunately, you have to modify the firmware and add an application identifier.
In case when you develop and control Bluetooth 4.0+ device,
Assign your bluetooth device address as it's device name and broadcast it via Scan Response package.
Scan Response package is a 31 bytes of data that bluetooth device broadcast after master device (e.g. smartphone) send scan request.
Important
Some bluetooth devices allow to set their name without programming, for example HM-10 bluetooth module name can be changed with AT+NAME text command.
You can add some unique "Manufacturer Specific Data" in Bluetooth advertising data package and read it from iOS. It's much faster than reading "System ID" attribute from "Device Information Service", as was proposed in other answer, because it does not require connect to bluetooth device.
Advertising data is 31 bytes of data that bluetooth 4.0+ broadcasting to air (before anyone connected to it) at some interval of time (from 20ms to 10s) depending on this device configuration.
Also there is scan response data, it's extra package of 31 byte that bluetooth device broadcast after master device (e.g. smartphone) send scan request. It have same structure as advertising data package.
In total there 31+31=62 bytes of data that we can use.
Advertising data consist of set of advertising data structures (AD struct)
First byte describes the length of AD Struct including 1 byte of data type + variable size payload.
Second byte describes the type of data stored in AD Struct, here list of identifiers.
All later bytes are payload data.
For advertising data is mandatory to include configuration Flags AD Struct (does not concern to scan response), it takes 3 bytes. We have 28 bytes left.
Assuming that you developing your own GATT Service, so you need to specify it identifier in advertising data. Custom GATT Service UUID identifier can be only in 128bit full length format (unlike 16bit and 32bit service identifiers predefined by Bluetooth standard). In advertising data it will consume 2+16=18 bytes. So, We have 10 bytes left.
Now we can defined manufacturer data 2 bytes used for length and data type
first 2 bytes in payload comes for company identifier (as required in document Supplement to Bluetooth Core Specification section 1.4), company identifiers are assigned by Bluetooth Special Interest Group
For testing purposes you can use 0xFF, 0xFF identifier
And using left 6 bytes you can uniquely identify 281,474,976,710,656 devices.
Sample of advertising data, written in C:
#define GAP_ADV_FLAGS 0x01
#define GAP_ADV_128_UUID 0x06
#define GAP_ADV_MANUF_DATA 0xFF
uint8_t raw_adv_data[31] = {
// len type payload....
0x02, GAP_ADV_FLAGS, 0x06,
// GATT service 128 bit UUID
0x11, GAP_ADV_128_UUID, 0x1d, 0x15, 0xee, 0x49,
0x10, 0x78, 0xc8, 0xa3,
0x9f, 0xaa, 0x82, 0x84,
0x8e, 0x28, 0xbe, 0x43,
// 2 bytes of company ID
0x09, GAP_ADV_MANUF_DATA, 0xff, 0xff,
// 6 bytes of unique data
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
};
PS: Well, if you need to send even more data, you can put in scan response package, which give you extra 31 byte of payload.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With