Edmund 最新主题

推荐阅读

1 6405 2016-10-13
本帖最后由 Edmund 于 2016-10-13编辑

Measuring distance(测量距离)

TX power ,用于确定你和beacon之间距离有多近。根据这个值不但可以获得粗略的信息(比如靠近/远离/不在范围内等),也可以获取精确到米的距离,TX power是距离设备1米测得的信号强度值(RSSI- Received Signal Strength Indication,接收到的信号强弱指标)。假如接收到的信号强度减弱了,那么我们可能在远离。只要知道1米距离的RSSI,以及当前的RSSI(我们可以从接收到的信号中一块获取到这些信息),就可计算出当前距离beacon基站的距离


Android 平台

1 Ibeacon扫描SDK库

Android最常用的是android-beacon-library

beacongithub地址

具体使用方法在项目的README.md 描述的比较详细

2 altbeacon内置设备模型以及用于beacon测距的算法中的系数


{  "models":  [    {      "coefficient1": 0.42093,      "coefficient2": 6.9476,      "coefficient3": 0.54992,      "version":"4.4.2",      "build_number":"KOT49H",      "model":"Nexus 4",      "manufacturer":"LGE"    },    {      "coefficient1": 0.42093,      "coefficient2": 6.9476,      "coefficient3": 0.54992,      "version":"4.4.2",      "build_number":"LPV79",      "model":"Nexus 5",      "manufacturer":"LGE",      "default": true    },    {      "coefficient1": 0.9401940951,      "coefficient2": 6.170094565,      "coefficient3": 0.0,      "version":"5.0.2",      "build_number":"LXG22.67-7.1",      "model":"Moto X Pro",      "manufacturer":"XT1115",      "default": false    },    {      "coefficient1": 0.1862616782,      "coefficient2": 8.235367435,      "coefficient3": -0.45324519,      "version":"6.0",      "build_number":"MPE24.49-18",      "model":"XT1092",      "manufacturer":"Motorola",      "default": false    }  ]

}

3 ALTBeacon中的测距方法

@Override

public double calculateDistance(int txPower, double rssi) {   

 if (rssi == 0) {      

   return -1.0; // if we cannot determine accuracy, return -1.    }    LogManager.d(TAG, "calculating distance based on mRssi of %s and txPower of %s", rssi, txPower);    

   double ratio = rssi*1.0/txPower;    double distance;    if (ratio < 1.0) {        distance =  Math.pow(ratio,10);    }    else {        distance =  (mCoefficient1)*Math.pow(ratio,mCoefficient2) + mCoefficient3;    }    LogManager.d(TAG, "avg mRssi: %s distance: %s", rssi, distance);  

  return distance; }


方法中的公式用到两个值,一个txpower 一个rssi ,用到两个值就可以通过公式求出距离

4 移动端距离计算

如果当前的设备没有在altbeacon内置设备模型列表中,beacon SDK 则选择Nexus 5系数进行距离计算,如下

public static double calculateAccuracy(int txPower, double rssi) {       

if (rssi == 0) {           return -1.0; // if we cannot determine accuracy, return -1.       }      

double ratio = rssi * 1.0 / txPower;       

if (ratio < 1.0) {          

return Math.pow(ratio, 10);      

} else {           

double accuracy = (0.42093) * Math.pow(ratio, 6.9476) + 0.54992;        

  return accuracy;       }   }


0

0条回复