0

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

olop01
  • 273
  • 3
  • 18
  • Have you played with scan settings? `ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder(); scanSettingsBuilder.setReportDelay(0); scanSettingsBuilder.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY);` – Michiyo Jun 17 '16 at 05:41
  • I'm not sure why this doesn't work. It looks to me like it should. It might be helpful if you turn on debug logging with `beaconManager.setDebug(true)` then capture a LogCat output for 30 seconds or so before and after you change the scanning interval. If you can do this and post the log somewhere, I'll take a look. – davidgyoung Jun 17 '16 at 13:17
  • @davidgyoung I have updated the post with the log. It says: **06-17 19:03:13.641 10161-10161/de.mediatoni.beaconProto3 D/BeaconManager﹕ updating scan period to 200, 0** – olop01 Jun 17 '16 at 17:07

1 Answers1

0

Based on the logs posted, it looks like the scan cycle is successfully changed to 200 ms. I suspect that this is working, and something else at a higher level is making updates not happen more than once a second.

06-17 19:03:14.461  10161-10161/de.mediatoni.beaconProto3 D/CycledLeScanner﹕ Scan started
...
06-17 19:03:14.661  10161-10161/de.mediatoni.beaconProto3 D/CycledLeScanner﹕ Done with scan cycle
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • You're right. I am searching for the cause of this lag. I have a console log everytime a Beacon is detected and it clearly tells by the timestamp, that it is too slow. (see UPDATE 2) – olop01 Jun 18 '16 at 12:29
  • I have created another small test app to see how often it logs and it still only updates the log every second instead of each 200ms. Could it be that my S5 Neo is too slow for it?? You can see the sample code I use, here: https://www.dropbox.com/s/1nlbq1mvwiox9zx/BeaconApp.txt?dl=0 – olop01 Jun 18 '16 at 14:01