On Apr 20, 2012, at 5:57 AM, Pierre Bouchet wrote:
Hi,
I'm running [CBCentralManager scanForPeripheralsWithServices:nil options:nil].
In my implementation of didDiscoverPeripheral I call printf("%s\n", [peripheral.name UTF8String]) and [CBCentralManager stopScan].
However didDiscoverPeripheral sometimes gets called a second time, with a peripheral that has the same name and UUID as the first one, even though the system is not supposed to be scanning anymore.
This happens even with CBCentralManagerScanOptionAllowDuplicatesKey set to NO.
If the peripheral supports active scanning and the application is in the foreground, you will get two calls to the didDiscoverPeripheral. The first call contains the data in the advertising packet from the peripheral. The second call contains additional data from the scan response packet from the peripheral.
Also the device name printed to the console is always (null) the first time a device is discovered after launching the app.
You will see this behavior if the advertising packet from the peripheral does not contain a name and the peripheral instead provides the name in the scan response packet.
Am I misunderstanding how scanning works?
I'm using Xcode 4.3 to run my app on an iPhone 4S with iOS 5.1 - the BLE peripheral comes from the TI CC2540 dev kit and it's the only BLE device in range when I run my tests.
Regards,
Pierre