I'm new to corebluetooth. My aim is to keep reading RSSI number of the connected device. I can read the RSSI number once, however I have no idea how to initialise to read the RSSI number constantly. Can somebody suggest? Followings are my code so far
func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) {
self.connectingPeripheral = peripheral
centralManager.stopScan()
self.centralManager.connectPeripheral(peripheral, options: nil)
ConnectingLabel.hidden = false
println(peripheral)
println( RSSI )
}
Once you are connected to the peripheral you can call peripheral.readRSSI()
periodically. This will result in a callback to the peripheralDidUpdateRSSI
CBPeripheralDelegate
method. At this point you can access the peripheral's RSSI property.
Strangely, both the peripheralDidUpdateRSSI
delegate method and RSSI
property are flagged as deprecated in the documentation, but no alternative is provided and no warnings are given by the compiler when you use this method and property, so I suspect it is a documentation bug.