iOS 和 Android 无需连接即可访问的蓝牙设备是否有唯一标识符?

Is there a unique identifier for a Bluetooth device accessible to iOS and Android without connecting?

我们正在创建一个蓝牙硬件设备,并希望在数据库中存储一个唯一的标识符,这样多个用户就不会尝试连接到同一台设备。有一个 Android 和一个 iOS 应用程序。

据我了解,在 iOS 中您无法访问 MAC 地址,并且提供的 UUID 是在 iOS 端生成的。我们可以添加提供 UUID 的特性,但是有没有办法在不连接到蓝牙设备的情况下在 iOS 和 Android 上获得一致的标识符?

如果您可以控制硬件及其宣传的内容,那么您可以将 mac 地址(或其他一些唯一标识符)作为服务数据或制造商特定数据。请参阅 Android L 或更高版本中的 https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html。对于较低的 Android 版本,您必须自己解析扫描记录,这有点痛苦。

iOS 见此处:

要快速证明 Android 的概念,您可以使用 SweetBlue,它可以在后台为您处理不同的 OS 版本。参见:

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

对于iOS:
BLE 设备可以在其广告数据中广告服务 UUID。

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

在您的iOS APP中,您可以扫描具有指定服务UUID的设备:

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

您的APP只会发现这些服务UUID的BLE Device。