@Test public void testRangeCalculationWithEmptyCacheAndTxPowerSmallerThanRssi() { final Ranger ranger = new Ranger(testFilter); final Beacon beacon = new Beacon("00:11:22:33:44:EE", emptyList(), (byte) -95); beacon.setRssi((byte) -85); final double distance = ranger.calculateDistance(beacon); assertEquals(0.316, distance, 0.001); }
public double calculateDistance(@NonNull Beacon beacon) { final RssiFilter filter = cache.get(beacon); final byte rssi; if (filter != null) { final Byte filteredRssi = filter.getFilteredValue(); if (filteredRssi == null) { rssi = beacon.getRssi(); } else { rssi = filteredRssi; } } else { rssi = beacon.getRssi(); } final Byte txPower = beacon.getTxPower(); return txPower != null ? pow(10.0, (float) (txPower - rssi) / 20) : Double.MAX_VALUE; }
Ranger { public double calculateDistance(@NonNull Beacon beacon) { final RssiFilter filter = cache.get(beacon); final byte rssi; if (filter != null) { final Byte filteredRssi = filter.getFilteredValue(); if (filteredRssi == null) { rssi = beacon.getRssi(); } else { rssi = filteredRssi; } } else { rssi = beacon.getRssi(); } final Byte txPower = beacon.getTxPower(); return txPower != null ? pow(10.0, (float) (txPower - rssi) / 20) : Double.MAX_VALUE; } }
Ranger { public double calculateDistance(@NonNull Beacon beacon) { final RssiFilter filter = cache.get(beacon); final byte rssi; if (filter != null) { final Byte filteredRssi = filter.getFilteredValue(); if (filteredRssi == null) { rssi = beacon.getRssi(); } else { rssi = filteredRssi; } } else { rssi = beacon.getRssi(); } final Byte txPower = beacon.getTxPower(); return txPower != null ? pow(10.0, (float) (txPower - rssi) / 20) : Double.MAX_VALUE; } Ranger(RssiFilter.Builder rssiFilterBuilder); }
Ranger { public double calculateDistance(@NonNull Beacon beacon) { final RssiFilter filter = cache.get(beacon); final byte rssi; if (filter != null) { final Byte filteredRssi = filter.getFilteredValue(); if (filteredRssi == null) { rssi = beacon.getRssi(); } else { rssi = filteredRssi; } } else { rssi = beacon.getRssi(); } final Byte txPower = beacon.getTxPower(); return txPower != null ? pow(10.0, (float) (txPower - rssi) / 20) : Double.MAX_VALUE; } Ranger(RssiFilter.Builder rssiFilterBuilder); double calculateDistance(@NonNull Beacon beacon); }
Ranger { public double calculateDistance(@NonNull Beacon beacon) { final RssiFilter filter = cache.get(beacon); final byte rssi; if (filter != null) { final Byte filteredRssi = filter.getFilteredValue(); if (filteredRssi == null) { rssi = beacon.getRssi(); } else { rssi = filteredRssi; } } else { rssi = beacon.getRssi(); } final Byte txPower = beacon.getTxPower(); return txPower != null ? pow(10.0, (float) (txPower - rssi) / 20) : Double.MAX_VALUE; } Ranger(RssiFilter.Builder rssiFilterBuilder); double calculateDistance(@NonNull Beacon beacon);  }