Skip to content

Commit

Permalink
Added SampleExpirationMilliseconds parameter. (petermetz#258)
Browse files Browse the repository at this point in the history
Adjusting the averaging filter time
  • Loading branch information
jmesa-sistel authored and petermetz committed Aug 23, 2017
1 parent 93562ce commit 73c3cb6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/android/LocationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.service.RunningAverageRssiFilter;
import org.altbeacon.beacon.service.RangedBeacon;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
Expand All @@ -72,6 +74,8 @@ public class LocationManager extends CordovaPlugin implements BeaconConsumer {
private static final String FOREGROUND_BETWEEN_SCAN_PERIOD_NAME = "com.unarin.cordova.beacon.android.altbeacon.ForegroundBetweenScanPeriod";
private static final String FOREGROUND_SCAN_PERIOD_NAME = "com.unarin.cordova.beacon.android.altbeacon.ForegroundScanPeriod";
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 int DEFAULT_FOREGROUND_SCAN_PERIOD = 200;
private static int CDV_LOCATION_MANAGER_DOM_DELEGATE_TIMEOUT = 30;
private static final int BUILD_VERSION_CODES_M = 23;
Expand Down Expand Up @@ -118,6 +122,16 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
iBeaconManager.setForegroundBetweenScanPeriod(foregroundBetweenScanPeriod);
iBeaconManager.setForegroundScanPeriod(foregroundScanPeriod);

final int sampleExpirationMilliseconds = this.preferences.getInteger(
SAMPLE_EXPIRATION_MILLISECOND, DEFAULT_SAMPLE_EXPIRATION_MILLISECOND);

Log.i(TAG, "Determined config value SAMPLE_EXPIRATION_MILLISECOND: " +
String.valueOf(sampleExpirationMilliseconds));

iBeaconManager.setRssiFilterImplClass(RunningAverageRssiFilter.class);
RunningAverageRssiFilter.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);
RangedBeacon.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);

initBluetoothListener();
initEventQueue();
pauseEventPropagationToDom(); // Before the DOM is loaded we'll just keep collecting the events and fire them later.
Expand Down

0 comments on commit 73c3cb6

Please sign in to comment.