从 CLProximity 获取距离

Get Distance From CLProximity

我正在使用 objective c 开发一个信标检测应用程序,我得到的信标值如下

CLBeacon (uuid:<__NSConcreteUUID 0x174223ee0> XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, major:0, minor:1, proximity:2 +/- 0.32m, rssi:-49)

在这个值中,我想获得作为 +/- 0.32m 值的接近度,但随后我正在访问接近度值,我没有得到它我如何访问这个值,任何人都可以帮助我,我正在使用最新的IOS SDK

CLProximity 不会显示以米为单位的距离 它只会给你价值

CLProximityUnknown,
CLProximityImmediate,
CLProximityNear,
CLProximityFar

要找到以米为单位的距离(例如信标在 15 米范围内),您需要查看 this 文档。公式是第 3 页的 #19,基本上它是这样做的:

Received Signal Strength is related to distance using the equation below.
RSSI [dBm] = -10n log10 (d) + A [dBm] 

在哪里
A 是在 1 米处以 dBm 为单位的接收信号强度 - 您需要在您的系统上对此进行校准。因为您是在已知距离处进行校准,所以您无需考虑传输频率,这简化了方程式。 (只需将 iBeacon 放在 1 米范围内,并测量它的 RSSI)

n传播路径损耗指数即2.7到4.3(免费space有n=2供参考,如果有墙会更大)。

d 是与发件人的距离,单位为米

所以你有所有的值,除了 d,你需要使用提到的公式计算 d

编辑:准确性
CoreLocation 还为 CLBeacon 提供 accuracy 属性。 你是对的,它以米为单位提供,但显示了测量的准确性。

在你的情况下,它表明信标接近度是 CLProximityNear,它的精度为 +/- 0.32m。

这是关于 accuracy

的文档
/*
 *  accuracy
 *
 *  Discussion:
 *    Represents an one sigma horizontal accuracy in meters where the measuring device's location is
 *    referenced at the beaconing device. This value is heavily subject to variations in an RF environment.
 *    A negative accuracy value indicates the proximity is unknown.
 *
 */
@property (readonly, nonatomic) CLLocationAccuracy accuracy;