We want to use AccessorySetupKit to pair our BLE accessories. However, currently all our products announce the same BLE service UUID. The manufacturer data is different for every product.
I try to pair our products with ASK and create the ASDiscoveryDescriptor with the expected manufacturer data:
let descriptorA = ASDiscoveryDescriptor()
descriptorA.bluetoothServiceUUID = CBUUID("CE1EB45C-1BD2-45BE-8163-ACC88BE94CB2") // same
descriptorA.bluetoothManufacturerDataBlob = Data([0xd2, 0x0a, 0x00, /* A */ 0x2a, 0x00, 0x00, 0x00]) // different
descriptorA.bluetoothManufacturerDataMask = Data([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])
let descriptorB = ASDiscoveryDescriptor()
descriptorB.bluetoothServiceUUID = CBUUID("CE1EB45C-1BD2-45BE-8163-ACC88BE94CB2") // same
descriptorB.bluetoothManufacturerDataBlob = Data([0xd2, 0x0a, 0x00, /* B */ 0x2b, 0x00, 0x00, 0x00]) // different
descriptorB.bluetoothManufacturerDataMask = Data([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])
However, it seems random which device is found, as if the service UUID is the primary key to handle things in ASK.
My questions are:
- Is it possible to use only manufacturer data to distinguish between different products with the same service UUID?
- How do I use bluetoothManufacturerDataMask properly? I assume that internally some filtering like this is done:
DataBlob & DataMask == ReceivedManufacturerData & DataMask
. Because of that I have set all bits of the mask to 1. Should this e done differently?
thanks @melle for the last piece of info. Your plist looks almost perfect, but you're missing the NSAccessorySetupBluetoothCompanyIdentifiers
key to indicate what manufacturer ID's you would like to scan for (https://developer.apple.com/documentation/bundleresources/information_property_list/nsaccessorysetupbluetoothcompanyidentifiers/)
In your case, you need to specify an array of 1 string, "0ad2".
Adding this to the plist will allow us to send you the data that we found.
Please let me know if that helps.
Thanks.