Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunningAverageRssiFilter sampleExpiration modification ignored #30

Closed
fediazgon opened this issue May 24, 2017 · 4 comments
Closed

RunningAverageRssiFilter sampleExpiration modification ignored #30

fediazgon opened this issue May 24, 2017 · 4 comments

Comments

@fediazgon
Copy link

fediazgon commented May 24, 2017

Hi.

I'm trying to modify the time interval of the RunningAverageRssiFilter as explained here: Adjusting the averaging time. I'm calling both methods in my Application class (I've seen in the reference application that all the configuration is done in this class), however, the new value is ignored.

I've modified the RunningAverageRssiFilter class to log a message every time the method setSampleExpirationMilliseconds is called:

public static void setSampleExpirationMilliseconds(long newSampleExpirationMilliseconds) {
        LogManager.d(TAG, "Changing sampleExpiration time to %d%n", newSampleExpirationMilliseconds);
        sampleExpirationMilliseconds = newSampleExpirationMilliseconds;
}

This method is called three times, as you can see in my Android Monitor:

issue_abl

The first one corresponds to the call made from my Application class. I think the other two calls are made from the RangedBeacon constructor:

public RangedBeacon(Beacon beacon) {
        //set RSSI filter
        try {
            Constructor cons = BeaconManager.getRssiFilterImplClass().getConstructors()[0];
            filter = (RssiFilter)cons.newInstance();
        } catch (Exception e) {
            LogManager.e(TAG, "Could not construct RssiFilterImplClass %s", BeaconManager.getRssiFilterImplClass().getName());
        }

        RunningAverageRssiFilter.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);
        updateBeacon(beacon);
}

As a result, my configuration is ignored and sampleExpirationMilliseconds returns back to 20000. It seems that the RangedBeacon class has a static method to modify the time interval too. Should not this method be called as well? My current solution:

long sampleExpirationMilliseconds = 5000L;
BeaconManager.setRssiFilterImplClass(RunningAverageRssiFilter.class);
RunningAverageRssiFilter.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);
RangedBeacon.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);

Edited: sorry, I meant to add this issue in the android-beacon-library repository.

@fediazgon fediazgon reopened this May 24, 2017
@fediazgon fediazgon changed the title Can't modify RunningAverageRssiFilter sampleExpiration RunningAverageRssiFilter sampleExpiration modification ignored Jun 2, 2017
@fediazgon
Copy link
Author

fediazgon commented Jun 2, 2017

Please, @davidgyoung, check this issue.

@davidgyoung
Copy link
Member

Apologies for the delay, @fdiazgon, let me take a look and see what I can find.

@davidgyoung
Copy link
Member

Reviewing this now, it appears that the documentation is currently wrong. You are correct in your observations, you cannot use: RunningAverageRssiFilter.setSampleExpirationMilliseconds(sampleExpirationMilliseconds); to adjust this setting, because it is overridden by the call in RangedBeacon. Currently, the proper way to set this setting is:

RangedBeacon.setSampleExpirationMilliseconds(sampleExpirationMilliseconds);

The change in #128 was intended to shift this setting to the RunningAverageRssiFilter, which is why the documentation says to configure this way. However, it appears it never worked as intended. I will keep this issue open as I would like to change the code so that if the setter gets called on RunningAverageRssiFilter it takes precedence over what is called internally from RangedBeacon. This will make the documentation correct and the API work as intended.

@davidgyoung
Copy link
Member

Fixed in AltBeacon/android-beacon-library#523

cupakromer added a commit to AltBeacon/android-beacon-library that referenced this issue Dec 12, 2017
This fixes #627 which is a regression of
#523
(AltBeacon/android-beacon-library-reference#30). It was introduced in
commit f084042 (PR #484) where
the `RunningAverageRssiFilter` has it's value constantly reset after
every cycle in [`RangedBeacon#commitMeasurements`](f084042#diff-65311818bc092d4192549ca6a7932a8aR50).
cupakromer added a commit to AltBeacon/android-beacon-library that referenced this issue Dec 12, 2017
This fixes #627 which is a regression of
#523
(AltBeacon/android-beacon-library-reference#30). It was introduced in
commit f084042 (PR #484) where
the `RunningAverageRssiFilter` has it's value constantly reset after
every cycle in [`RangedBeacon#commitMeasurements`](f084042#diff-65311818bc092d4192549ca6a7932a8aR50).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants