5

We are creating a bluetooth hardware device and want to store a unique identifier in the database so that multiple users won't try to connect to the same device. There is an Android and an iOS app.

It is my understanding that in iOS you can't access the MAC Address and the UUID provided is generated on the iOS side. We can add a characteristic providing a UUID, but is there a way to have a consistent identifier on iOS and Android without connecting to the bluetooth device?

Jeremiah
  • 1,471
  • 1
  • 13
  • 22

2 Answers2

6

If you have control over the hardware and what it advertises then you can include the mac address (or some other unique identifier) as service data or manufacturer-specific data. See https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html on Android L or above. For lower Android versions you have to parse the scan record yourself, which is a bit of a pain.

For iOS see here: https://stackoverflow.com/a/25392156/4248895

For a quick proof of concept on Android you can use SweetBlue which handles the different OS versions for you under the hood. See:

http://idevicesinc.com/sweetblue/docs/api/com/idevicesinc/sweetblue/BleManagerConfig.ScanFilter.ScanEvent.html#serviceData
http://idevicesinc.com/sweetblue/docs/api/com/idevicesinc/sweetblue/BleManagerConfig.ScanFilter.ScanEvent.html#manufacturerData

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Doug Koellmer
  • 407
  • 2
  • 8
0

For iOS:
BLE Device can advertise service UUIDs in their advertisement data.

[myPeripheralManager startAdvertising:@{ CBAdvertisementDataServiceUUIDsKey :
    @[myFirstService.UUID, mySecondService.UUID] }];

In your iOS APP,you can scan for devices with specify service UUID:

[myCentralManager scanForPeripheralsWithServices:@[myFirstService.UUID, mySecondService.UUID] options:nil];   

Your APP will only discover the BLE Device of these service UUIDs.

wj2061
  • 6,778
  • 3
  • 36
  • 62
  • I can get the service UUID's. What I'm looking for is a UUID for the device so I can distinguish two devices with the same services. – Jeremiah Dec 21 '15 at 17:32
  • @jeremiah In "optional func centralManager(_ central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData advertisementData: [String : AnyObject], RSSI RSSI: NSNumber)" ,you got the peripheral,so you got the device's UUID, which is "peripheral.identifier". – wj2061 Dec 23 '15 at 06:31