Skip to content

Commit

Permalink
feat: add ARMA filter support for distance calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinHaigh authored and petermetz committed May 11, 2019
1 parent f2fe545 commit 40abc3b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/android/LocationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.service.RunningAverageRssiFilter;
import org.altbeacon.beacon.service.ArmaRssiFilter;
import org.altbeacon.beacon.service.RangedBeacon;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
Expand Down Expand Up @@ -81,6 +82,8 @@ public class LocationManager extends CordovaPlugin implements BeaconConsumer {
private static final int DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD = 0;
private static final String SAMPLE_EXPIRATION_MILLISECOND = "com.unarin.cordova.beacon.android.altbeacon.SampleExpirationMilliseconds";
private static final int DEFAULT_SAMPLE_EXPIRATION_MILLISECOND = 20000;
private static final String ENABLE_ARMA_FILTER_NAME = "com.unarin.cordova.beacon.android.altbeacon.EnableArmaFilter";
private static final boolean DEFAULT_ENABLE_ARMA_FILTER = false;
private static final int DEFAULT_FOREGROUND_SCAN_PERIOD = 1100;
private static int CDV_LOCATION_MANAGER_DOM_DELEGATE_TIMEOUT = 30;
private static final int BUILD_VERSION_CODES_M = 23;
Expand Down Expand Up @@ -135,8 +138,16 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
Log.i(TAG, "Determined config value SAMPLE_EXPIRATION_MILLISECOND: " +
String.valueOf(sampleExpirationMilliseconds));

iBeaconManager.setRssiFilterImplClass(RunningAverageRssiFilter.class);
RunningAverageRssiFilter.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);
final boolean enableArmaFilter = this.preferences.getBoolean(
ENABLE_ARMA_FILTER_NAME, DEFAULT_ENABLE_ARMA_FILTER);

if(enableArmaFilter){
iBeaconManager.setRssiFilterImplClass(ArmaRssiFilter.class);
}
else{
iBeaconManager.setRssiFilterImplClass(RunningAverageRssiFilter.class);
RunningAverageRssiFilter.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);
}
RangedBeacon.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);

initBluetoothListener();
Expand Down

0 comments on commit 40abc3b

Please sign in to comment.