My app only seems to detect my beacons every 5 seconds

I’ve been playing about with developing a timer application on Android.

One of my beacons starts the timer and another beacon stops it.

I have set the Advertising interval of both beacons to around 200ms. and I have set the scan frequency of the application to do a full scan every one second.

I am currently using the debug tool that stops the beacon transmitting when it is turned over and when I flip over the starting beacon there is about a 5 second delay before the timer starts to run. I then flip the start beacon back over to stop it transmitting and flip the stop beacon the right way up. again there is a 5 second delay before the timer stops running.

It seems to me that the onBeaconsDiscovered() method is running once every 5 seconds which is causing this latency in my app. My understanding is that onBeaconsDiscovered() will run once the app has completed one full scan and wait cycle, which doesn’t seem to be the case here.

I was wondering if you might know what I might be doing wrong ? below is how I’m setting the scanning intervals :

beaconManager = new BeaconManager(this);

beaconManager.setBackgroundScanPeriod(1000, 50);
beaconManager.setForegroundScanPeriod(1000, 0);

beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List list) { …}
}

Thanks in advance.

Hi @Conor_Toner,

1/ What’s your intent? Ranging or monitoring for beacons?
2/ By default ranging scans for 1000ms and restarts scanning thereafter. That means that onBeaconsDiscovered should be invoked every second even if there are no beacons around. That’s not case for your?
3/ What device/OS you are testing on?

Hi @wiktor,

Cheers for the speedy reply.

At the minute I’m hoping to use ranging to pick up the beacons, I assumed this would fit my goal better but monitoring might also work.

iv added a line to my code that updates a counter every time the onBeaconsDiscovered methed is called so as far as I can see that method is being called aprox. once every 5 seconds.

I’m testing it on an android device running lollipop.

Let’s focus on that counter in onBeaconsDiscovered that is called ~each 5 seconds.

1/ Method is not invoked on main/UI thread. Are you doing any UI operations? If so please run the code on main thread.
2/ Can you post small snippet of code where you are seeing this behaviour? I’m interested in everything related to Estimote SDK.

Hi there,

I got exactly the same issue in my Android app even I’ve set the BeaconManager as below:

beaconManager = new BeaconManager(activity);
beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(1), 0);
beaconManager.setForegroundScanPeriod(TimeUnit.SECONDS.toMillis(1), 0);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
    @Override
    public void onBeaconsDiscovered(Region region, List<Beacon> list) {

        //my code

    }
});

region = new Region("ranged region", UUID.fromString("======my uuid====="), null, null);

beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
    @Override
    public void onServiceReady() {
        beaconManager.startRanging(region);
    }
});

The library I’m using is “com.estimote:sdk:0.10.1@aar”

Please indicate, thanks

Hello,

I got exactly same issue in some Android devices. Ranging listener is called in 1 second for some devices but in some device it is called after 5 seconds.

Any help would be appreciated.

Best Regards,
Monik

Are you using the latest version of the Estimote Android SDK? If not, can you check if it fixes this problem? Also, which devices exactly are affected?

Consider opening a bug report on our Android SDK’s issue tracker: