Swift iBeacon:通过蓝牙获取RSSI
是否可以仅使用CoreBooth获取信标的RSSI值 我已经实现了以下代码:Swift iBeacon:通过蓝牙获取RSSI,swift,core-bluetooth,ibeacon,Swift,Core Bluetooth,Ibeacon,是否可以仅使用CoreBooth获取信标的RSSI值 我已经实现了以下代码: let manager = CLLocationManager() var peripheralManager = CBPeripheralManager() var advertisedData:NSDictionary = NSDictionary() //test if there is a working bluetooth connection func peripheralManagerDidUpdate
let manager = CLLocationManager()
var peripheralManager = CBPeripheralManager()
var advertisedData:NSDictionary = NSDictionary()
//test if there is a working bluetooth connection
func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager!) {
switch peripheral.state {
case CBPeripheralManagerState.PoweredOn:
self.peripheralManager.startAdvertising(self.advertisedData as [NSObject : AnyObject])
println("success")
default: println("default")
}
}
现在我可以测试蓝牙是否被激活。但是我怎样才能得到信标的RSSI值呢?是否只有CoreLocation才有可能实现此功能?
CLBeacon
具有属性rssi
,详细信息请参阅
cbperipal
有一个RSSI
属性,在iOS8中被弃用,苹果建议改用它
由于通常情况下,您应该通过
CLBeacon
(CoreLocation.framework)读取iBeacons值,因此我建议使用rssi
。如果您通过蓝牙低能量(corebooth.framework)控制iBeacon,请使用readRSSI
您无法通过核心蓝牙发现iBeacon。如果您的信标播发其他BLE服务,那么您将能够发现外围设备,并根据@Larme的回答读取RSSI。使用哪种方法我可以为信标创建一个区域或启动信标的CBSI外围设备?