Question

When I disable duplicate key filtering using:

NSDictionary *options    = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];

The build and run works fine (and captures all of the advertising packets) but it always produces this error first:

"CoreBluetooth[WARNING] is disabling duplicate filtering, but is using the default queue (main thread) for delegate events"

I am able to stop the warning from showing if I add:

dispatch_queue_t centralQueue = dispatch_queue_create("central", DISPATCH_QUEUE_SERIAL);

right before I create an instance of CBCentralManager and set the queue argument to centralQueue. Is this the proper way to fix this problem? Or is there a better way?

Thanks

Was it helpful?

Solution

Just so there is a proper answer:

Setting the scan options to allow duplicates may degrade overall performance if the CBCentralManager is setup to run on the main queue. It is best to run the CBCentralManager on a separate queue if you need to allow duplicates.

dispatch_queue_t centralQueue = dispatch_queue_create("mycentralqueue", DISPATCH_QUEUE_SERIAL);
_centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:centralQueue];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top