use of org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator in project android-beacon-library by AltBeacon.
the class BeaconTest method testCalculateAccuracyWithRssiGreaterThanPower.
@Test
public void testCalculateAccuracyWithRssiGreaterThanPower() {
Beacon.setDistanceCalculator(new ModelSpecificDistanceCalculator(null, null));
double accuracy = Beacon.calculateDistance(-55, -50);
assertTrue("Distance should be under one meter if mRssi is less negative than power. Accuracy was " + accuracy, accuracy < 1.0);
}
use of org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator in project android-beacon-library by AltBeacon.
the class BeaconTest method testCalculateAccuracyWithRssiEqualsPower.
@Test
public void testCalculateAccuracyWithRssiEqualsPower() {
Beacon.setDistanceCalculator(new ModelSpecificDistanceCalculator(null, null));
double accuracy = Beacon.calculateDistance(-55, -55);
assertEquals("Distance should be one meter if mRssi is the same as power", 1.0, accuracy, 0.1);
}
use of org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator in project android-beacon-library by AltBeacon.
the class BeaconService method onCreate.
@Override
public void onCreate() {
LogManager.i(TAG, "beaconService version %s is starting up", BuildConfig.VERSION_NAME);
bluetoothCrashResolver = new BluetoothCrashResolver(this);
bluetoothCrashResolver.start();
// Create a private executor so we don't compete with threads used by AsyncTask
// This uses fewer threads than the default executor so it won't hog CPU
mExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
mCycledScanner = CycledLeScanner.createScanner(this, BeaconManager.DEFAULT_FOREGROUND_SCAN_PERIOD, BeaconManager.DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD, mBackgroundFlag, mCycledLeScanCallback, bluetoothCrashResolver);
beaconManager = BeaconManager.getInstanceForApplication(getApplicationContext());
//flatMap all beacon parsers
boolean matchBeaconsByServiceUUID = true;
if (beaconManager.getBeaconParsers() != null) {
beaconParsers.addAll(beaconManager.getBeaconParsers());
for (BeaconParser beaconParser : beaconManager.getBeaconParsers()) {
if (beaconParser.getExtraDataParsers().size() > 0) {
matchBeaconsByServiceUUID = false;
beaconParsers.addAll(beaconParser.getExtraDataParsers());
}
}
}
//initialize the extra data beacon tracker
mExtraDataBeaconTracker = new ExtraDataBeaconTracker(matchBeaconsByServiceUUID);
defaultDistanceCalculator = new ModelSpecificDistanceCalculator(this, BeaconManager.getDistanceModelUpdateUrl());
Beacon.setDistanceCalculator(defaultDistanceCalculator);
monitoringStatus = MonitoringStatus.getInstanceForApplication(getApplicationContext());
// Look for simulated scan data
try {
Class klass = Class.forName("org.altbeacon.beacon.SimulatedScanData");
java.lang.reflect.Field f = klass.getField("beacons");
this.simulatedScanData = (List<Beacon>) f.get(null);
} catch (ClassNotFoundException e) {
LogManager.d(TAG, "No org.altbeacon.beacon.SimulatedScanData class exists.");
} catch (Exception e) {
LogManager.e(e, TAG, "Cannot get simulated Scan data. Make sure your org.altbeacon.beacon.SimulatedScanData class defines a field with the signature 'public static List<Beacon> beacons'");
}
}
use of org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator in project android-beacon-library by AltBeacon.
the class BeaconTest method testCalculateAccuracyWithRssiLessThanPower.
@Test
public void testCalculateAccuracyWithRssiLessThanPower() {
Beacon.setDistanceCalculator(new ModelSpecificDistanceCalculator(null, null));
double accuracy = Beacon.calculateDistance(-55, -60);
assertTrue("Distance should be over one meter if mRssi is less negative than power. Accuracy was " + accuracy, accuracy > 1.0);
}
use of org.altbeacon.beacon.distance.ModelSpecificDistanceCalculator in project android-beacon-library by AltBeacon.
the class BeaconTest method testCalculateAccuracyWithRssiEqualsPowerOnInternalProperties.
@Test
public void testCalculateAccuracyWithRssiEqualsPowerOnInternalProperties() {
Beacon.setDistanceCalculator(new ModelSpecificDistanceCalculator(null, null));
Beacon beacon = new Beacon.Builder().setTxPower(-55).setRssi(-55).build();
double distance = beacon.getDistance();
assertEquals("Distance should be one meter if mRssi is the same as power", 1.0, distance, 0.1);
}
Aggregations