문제

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

도움이 되었습니까?

해결책

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];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top