【发布时间】:2017-08-04 12:45:27
【问题描述】:
我正在开始借助 ios 中的 Beacons 开发室内导航系统。我们现在有 3 个 Bluecast 信标,我无法从这三个信标中获得准确的距离。我已经通过将三个信标放在同一位置进行测试,但它在主要时间显示不同的距离和 rssi 值。
我对信标提供者显示应用程序和我自己的应用程序进行了同样的尝试,但两个应用程序都显示出相同的价值。
示例代码是
locationManager = CLLocationManager()
locationManager.delegate = self
let uuid = UUID(uuidString: uuidStr)
beaconRegion = CLBeaconRegion(proximityUUID: uuid!, identifier: "Beacones")
beaconRegion.notifyOnEntry = true
beaconRegion.notifyOnExit = true
locationManager.requestAlwaysAuthorization()
locationManager.startMonitoring(for: beaconRegion)
locationManager.startUpdatingLocation()
距离计算器逻辑在下面
public func calculateAccuracy(txPower : Double, rssi : Double) -> Double {
if (rssi == 0) {
return -1.0; // if we cannot determine accuracy, return -1.
}
let ratio :Double = rssi*1.0/txPower;
if (ratio < 1.0) {
return pow(ratio,10.0);
}
else {
let accuracy :Double = (0.89976)*pow(ratio,7.7095) + 0.111;
return accuracy;
}
}
【问题讨论】:
标签: ios swift core-location ibeacon