Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.x
Description
CBCentralManager, -scanForPeripheralsWithServices:options: has the last parameter 'options', which is a dictionary to pass 'named' values. There are at the moment two options: CBCentralManagerScanOptionAllowDuplicatesKey and CBCentralManagerScanOptionSolicitedServiceUUIDsKey. The first one is a number/boolean, saying if duplicate filtering should be disallowed. Not passing this option (as it is in our code now) means " the central coalesces multiple discoveries of the same peripheral into a single discovery event." Also, Apple's docs have a warning:
Important
Disabling this filtering can have an adverse effect on battery life; use it only if necessary.
Arguably, by default Qt has a scan timeout, and for iOS it's 20 s. (so even if duplicates discovered and reported again, the scan finishes relatively soon, no problem for a battery life). Also, it was reported that with duplicates disabled, RSSI never properly found for a particular device. For 5.15 we introduce a workaround - an environment variable which allows to pass this scan option, if set: QT_BLUETOOTH_SCAN_ENABLE_DUPLICATES (with a positive integer as value enabling duplicates). For 6.x it probably makes sense to have a better API, especially if other platforms (Android, BlueZ on linux) have similar abilities.