I am trying to increase the update rate of my Beacon App. Currently the Beacons itself are setup to an "I am here!"-rate of 500ms.
I read that the default refresh rate of the Android Beacon Library is set to 1100ms which seems to be the case.
But it seems I cannot change this refresh rate (of the Android beacon Library). I tried:
@Override
public void onBeaconServiceConnect() {
// create the necessary region for the Beacon App and give it the Sensorberg UUIDs or parse "null" if it doesn't matter
final Region region = new Region("myBeacons", null, null, null);
beaconManager.setForegroundScanPeriod(200l); // 200ms
beaconManager.setForegroundBetweenScanPeriod(0l); // 0ms
try {
beaconManager.updateScanPeriods();
} catch (RemoteException e) {
Log.e(TAG, "Cannot talk to service" + (e));
}
The OnCreate method first creates an instance of the Manager beaconManager = BeaconManager.getInstanceForApplication(this);
then it sets up the distance detection mode with BeaconManager.setRssiFilterImplClass(ArmaRssiFilter.class);.
After that I setup the beacon data layout with beaconManager.getBeaconParsers().add(new BeaconParser() .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));.
Now I start the manager via beaconManager.bind(this); Then the OnCreate method closes.
Later my onBeaconServiceConnect method I try to speed up the refresh rate (posted code above), but it does not seem to make any change when running the app. It is still over 1 second. Also there is no "Cannot call service" in my logCat.
Can someone please help me setting the refresh rate for scans in Android Beacon Library more frequently? Thanks! :)
UPDATE: I did debug my app and here is the logCat log:
https://www.dropbox.com/s/p2bajo7bp5c1j8j/BeaconLog.txt?dl=0
It is a text file with all the log.
** UPDATE 2:** As by the answers provided by @davidgyoung the Update rate is changed to 200ms correctly. I am doing a console log everytime a beacon is detected in the setRangeNotifier which is called in the onBeaconServiceConnect method and you can clearly tell by the timestamp that this console log is too slow (around a second). It should be at least every 500ms (as this is what the beacons are setup). So what could be a reason that is slowing down the process? I have a Galaxy S5 neo which should be pretty okay and the app is just small.
Console check code:
// check for available data from the Beacons
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
// for each Beacon print the data and do the following functions
for(final Beacon oneBeacon : beacons) {
Log.d(TAG, "distance: " + oneBeacon.getDistance() + "id: " + oneBeacon.getId1() + "/" + oneBeacon.getId2() + "/" + oneBeacon.getId3());
Log output of this code:
06-18 14:19:27.101 19937-20235/de.mediatoni.beaconProto3 D/BeaconService﹕ beacon detected : id1: 73676723-7400-0000-ffff-0000ffff0001 id2: 3788 id3: 2001 06-18 14:19:27.891 19937-20275/de.mediatoni.beaconProto3 D/BeaconService﹕ beacon detected : id1: 73676723-7400-0000-ffff-0000ffff0000 id2: 3788 id3: 2000 06-18 14:19:28.111 19937-20300/de.mediatoni.beaconProto3 D/BeaconService﹕ beacon detected : id1: 73676723-7400-0000-ffff-0000ffff0002 id2: 3788 id3: 2002 06-18 14:19:28.701 19937-20302/de.mediatoni.beaconProto3 D/BeaconService﹕ beacon detected : id1: 73676723-7400-0000-ffff-0000ffff0000 id2: 3788 id3: 2000 06-18 14:19:28.811 19937-20337/de.mediatoni.beaconProto3 D/BeaconService﹕ beacon detected : id1: 73676723-7400-0000-ffff-0000ffff0001 id2: 3788 id3: 2001 06-18 14:19:28.821 19937-20338/de.mediatoni.beaconProto3 D/BeaconService﹕ beacon detected : id1: 73676723-7400-0000-ffff-0000ffff0002 id2: 3788 id3: 2002