BLE scan response increase times to get kCBAdvDataLocalName

I'm developing iOS application which works as BLE central.

I have a question about the scan response information.

My application is working in foreground and executing scanForPeripheralsWithService:options() when open app

[self.centralManager scanForPeripheralsWithServices:nil options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }];

In almost all case, when didDiscoverPeripheral() is called, my application can get the localName of the peripheral with the key @"kCBAdvDataLocalName" in around 30 seconds.

(The peripheral device is developed by other vendor)

Below is the NSLog output of didDiscoverPeripheral() with localName.

[MyApp]: (-[MyBleCentralMgr centralManager:didDiscoverPeripheral:advertisementData:RSSI:]) RSSI=-63, advertisementData={ 
kCBAdvDataIsConnectable = 1; 
kCBAdvDataLocalName = "DeviceName"; 
kCBAdvDataManufacturerData = <[manufactorer data of peripheral device]>; 
}

My application didn't stop scaning after app is killed but we stop scaning device when connected with found peripheral in (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral


In abnormal case:

We've also tried to get right device name but time is increase in around 5 minutes or longer if we're polling open then kill app immediately in many times (hinger 10 times). It seems the callback for discovering API is kept in iOS after we open then kill app immediately when connected peripheral. How we can get right device name around 30~60 seconds in the abnormal stub?

Replies

Putting aside any details about how the app is being killed, issues with the advertised name vs. GATT name, and so on, based on the simple fact that it takes 30 seconds to discover the peripheral when the app is in the foreground, and 5 minutes to do so when the app is not in the foreground, the simplest conclusion is that the peripheral is advertising at a grossly slow rate.


There is nothing that can be done in the app to decrease time to discovery if the advertising is not done fast enough. The peripheral needs to change the advertising interval to a faster, and preferably, to one of the recommended advertising intervals as described in


Technical Q&A QA1931:

Using the correct Bluetooth LE Advertising and Connection Parameters for a stable connection

<https://developer.apple.com/library/prerelease/content/qa/qa1931/_index.html>