IBeacon 测量距离方法
IBeacon 可通过RSSI(信号强度)和设备在一米时的RSSI值粗略计算出距离.
计算公式
d = 10 ^ (abs(RSSI) - A) / (10 * n);
d ----- 计算得到的距离.
RSSI - 接收信号的强度(负值).
A ----- 发射端和接收端相隔一米时的信号强度.
n ----- 环境衰减因子.
JAVA 代码计算公式
// 使用这个测量距离
public static double calculateDistance(int txPower,int rssi){
// 信号值得绝对值.
int absRssi = Math.abs(rssi);
// txPower 一米值. 暂时使用经验值 59 .需要替换成自己的真实值.
txPower = 59;
double power = (absRssi - txPower)/(10 * 2.0);
return Math.pow(10,power);
}
参考链接 : http://blog.csdn.net/njchenyi/article/details/46981423
网友评论