Here is my testing code to get the advertisement data, the repeat scan does not get the updated advertisement data.
import UIKit
import CoreBluetooth
class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate {
var centralManager:CBCentralManager!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
centralManager = CBCentralManager(delegate: self, queue: nil);
}
override func viewWillAppear(animated: Bool) {
NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector("startScan"), userInfo: nil, repeats: true);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func startScan() {
println("startScan");
centralManager.scanForPeripheralsWithServices(nil, options: nil);
NSTimer.scheduledTimerWithTimeInterval(3, target: self, selector: Selector("stopScan"), userInfo: nil, repeats: false);
}
func stopScan() {
println("stopScan");
centralManager.stopScan();
}
func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) {
}
func centralManagerDidUpdateState(central: CBCentralManager!) {
println("centralManagerDidUpdateState");
}
}