I have 3 sensors with same CBUUID, i.e. all three sensors transmit the same type of services but have different MAC address.
In forground scanning things are fine I can use CBCentralManagerScanOptionAllowDuplicatesKey = YES to get different delegate callbacks for same CBUUID by different BLE device. But in background scanning of peripherals CBCentralManagerScanOptionAllowDuplicatesKey is ignored. How will I scan these 3 sensors in the background because all packets will be coalesced into one and advertised as one packet by iOS.
The
allowDuplicatesoption means that you app will receive multiple callbacks to thedidDiscoverdelegate method for the same peripheral.It is not required simply to discover multiple peripherals that are advertising the same service.
When you start scanning you should specify the
CBUUIDof the service you are interested in. Once you get a call todidDiscoveryou can store the peripheral'sidentifierand use that to connect to the peripheral in the future.Scanning for a specific service works in both the foreground and background.