| Listing 3. Distance calculation. | |
| 1 | /** |
| 2 | * Calculates distances using the log-distance path loss model |
| 3 | * |
| 4 | * @param rssi the currently measured RSSI |
| 5 | * @param calibratedRssi the RSSI measured at 1m distance |
| 6 | * @param pathLossParameter the path-loss adjustment parameter |
| 7 | */ |
| 8 | public static double calculateDistance(double rssi, float calibratedRssi) { |
| 9 | float pathLossParameter = 3f; |
| 10 | return Math.pow(10, (calibratedRssi - rssi) / (10 * pathLossParameter)); |
| 11 | } |