从CLProximity获得距离

Kam*_*ena 4 objective-c proximity ios ibeacon

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

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

在这个值我希望得到接近+/- 0.32m值作为值,但后来我访问接近值我没有得到它我怎么能访问这个值可以任何人帮我这个我使用最新IOS SDK

l0g*_*g3r 6

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

CLProximityUnknown,
CLProximityImmediate,
CLProximityNear,
CLProximityFar
Run Code Online (Sandbox Code Playgroud)

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

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

其中
A 是1米处的dBm接收信号强度 - 您需要在系统上校准此信号.因为您在已知距离进行校准,所以不需要考虑传输频率,这简化了等式.(只需将iBeacon置于1米范围内,并测量其RSSI)

n传播路径损耗指数,即2.7到4.3(自由空间有n = 2作为参考,如果有墙,它将更大).

d 是发送方的距离,以米为单位

所以除了d之外你有所有的值,你需要用提到的公式来计算d.

编辑:准确性
CoreLocation也提供accuracy属性CLBeacon.你是对的,以米为单位提供,但显示测量的准确度.

在你的情况下,它表明信标接近度是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;
Run Code Online (Sandbox Code Playgroud)