Listing 1. Function used to calculate the RSSI accuracy. |
1
|
/*
|
2
|
* Calculates the accuracy of RSSI value considering txPower
|
3
|
* https://developer.radiusnetworks.com/2014/12/04/fundamentals-
|
4
|
* beacon-ranging.html
|
5
|
*/
|
6
|
protected static double calculateRating(int txPower, double rssi) {
|
7
|
if (rssi == 0) {
|
8
|
return -1.0; // if we cannot determine accuracy, return -1.
|
9
|
}
|
10
|
|
11
|
double ratio = rssi*1.0/txPower;
|
12
|
if (ratio < 1.0) {
|
13
|
return Math.pow(ratio,10);
|
14
|
}
|
15
|
else
|
16
|
return (0.89976)*Math.pow(ratio,7.7095) + 0.111;
|
17
|
}
|