onEddystonesFound for 20s although the beacon is off

I have a problem similar to Monitoring onExitedRegion delay

I’m using:

  • Estimote Android SDK 1.0.13
  • 1x Estimote Location Beacon F3.3 with only Eddystone UID activated
  • Android 5.1

I use EddystoneListener and start it with startEddystoneDiscovery().
Other settings are:

beaconManager.setForegroundScanPeriod(200, 0);
beaconManager.setRegionExitExpiration(1000);

Here is the problem:

  1. Eddystone is not in a range or batteries are removed.
  2. In SDK 0.16.0: onEddystonesFound is only invoked for next 1000ms and then I dont get any data from beacon. —> it’s correct behavior.
  3. In SDK 1.0.13: onEddystonesFound is invoked for next 20000ms, although the beacon is off ( battries are removed).
    The problem is, that I get fake-data from beacon.
    How can I prevent the App/ SDK to generate the fake data?

On github is this issue known Issue 248

Setting setRegionExitExpiration is used only for monitoring and won’t affect Eddystone ranging.
Expiration time for ranging (time is no packet from beacon) is set to 20s to avoid irregular batch scans in Android 7.+ and it is not user changeable.
Mentioned issue is about setRegionExitExpiration when monitoring iBeacons and already has been fixed and is during verification.

But how can you explain a problem, that a onEddystonesFound event is invoked, although a beacon is off?

The beacon is set to -30dBm broadcasting power and 200ms advertising intervall.

In 0.16.0 a beacon didn’t invoked an onEddystonesFound if it was off or outside a maximal range,
but now in 1.0.+ an onEddystonesFound event is even invoked for max. 20s, when the beacon is off.
All this time the app delivers fake data and rssi of a beacon stays almost the same, although a beacon isn’t in a range.
And if I use computeAccuracy(eddystone) the result is always almost the same, although a distance to a beacon increases.
My question is: why onEddystonesFound is onvoke although there is no beacon?

P.S. I’d rather removed the batteries of a beacon for tests.

What happens after 20s? There is no more “fake” beacon data received? Even if you leave it scanning for a few minutes?

Even if I leaving, it (the app) received fake data for 20s, same is, when I remove the batteries.
As I said, with 0.16.0 all worked fine, but now not anymore.

@Wojciech_Wawerek @heypiotr @pober
here is my code:

beaconManager.setEddystoneListener(new BeaconManager.EddystoneListener() {
                @Override
                public void onEddystonesFound(List<Eddystone> list) {
                    if (list != null) {
                        for (Eddystone eddystone : list) {
                            if (eddystone.instance.equals("eb5b8276f027")) {
                                Log.d(TAG, "onEddystonesFound: eb5b8276f027  is there!!!");
                            }
                        }
                    }
                }
}

at 08:39:08 I removed the batteries, but as you can see the data is still incoming for exactly 20s. Why?The beacon isn’t there anymore.

08-09 08:39:07.838 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:08.078 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:08.460 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:08.634 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:08.858 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:09.098 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:09.342 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:09.578 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:09.812 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:10.048 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:10.283 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:10.520 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:10.865 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:11.063 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:11.315 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:11.537 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:11.807 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:12.017 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:12.263 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:12.516 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:12.792 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:12.979 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:13.234 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:13.460 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:13.702 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:13.942 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:14.167 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:14.400 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:14.638 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:14.888 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:15.137 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:15.358 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:15.597 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:15.834 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:16.072 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:16.359 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:16.574 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:16.808 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:17.052 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:17.288 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:17.528 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:17.769 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:18.036 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:18.249 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:18.489 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:18.693 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:18.941 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:19.168 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:19.407 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:19.647 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:19.898 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:20.128 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:20.368 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:20.608 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:20.856 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:21.084 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:21.319 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:21.529 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:21.797 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:22.010 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:22.252 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:22.487 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:22.733 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:23.012 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:23.210 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:23.449 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:23.697 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:23.929 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:24.129 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:24.386 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:24.612 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:24.849 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:25.103 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:25.347 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:25.544 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:25.796 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:26.014 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:26.256 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:26.500 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:26.730 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:26.971 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:27.208 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:27.498 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:27.698 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:27.941 D: onEddystonesFound: eb5b8276f027  is there!!!
08-09 08:39:28.197 D: onEddystonesFound: eb5b8276f027  is there!!!

As I mentioned before 20s is expiration time. It means that SDK will consider beacon missing 20s after it received last packet from it and will report that beacon is there before this time is due.
On Androids 5.0 and newer Bluetooth stack uses something called batch scans. It means it will report received packets after in groups instead to avoid waking up application processor. Those batch scans by our experience are quite irregular (even when you tell Android exact time) and can take up several seconds.
Other thing is that due to uncertain nature of radio waves and way Bluetooth perform scans some some packets from single beacon may be missing from time to time.
Expiration time prevents beacon from appearing and disappearing frequently from the list that is returned in callback.
Pre 1.* SDKs suffered from too short expiration time which caused many false onEnter/onExit events.

@Wojciech_Wawerek @heypiotr @pober
I understand what you mean, but I’m using EddystoneDiscovery and EddystoneListener.
There are no onExit/onEnter event, only onFound.

You mean, that batch scanning is the cause, why the onEddystonesFound event is still invoking although the beacon is off, do you?
If yes: why in 0.16.0 the batch scanning didn’t affect onEddystonesFound event?

Too short expiration period was causing problems in both ranging and monitoring.

Batch scan is not only one reason why longer expiration period was introduced (way Bluetooth scans for packets, properties of radio waves) and it was causing problems only on some phones.

There is a list of currently visible beacons that its updated each time new scan record arrives. If the beacon is not scanned for 20s it is removed from the list. There is also a timer that periodically calls onFound method with that list as a parameter. That is why you are receiving callbacks.

@pober
Is there a workaround or the only solution for me is to change sdk version to 0.16.0?
Is there a possibility to clear this list manually?

@pober
I just switched to 0.16.0 and found some strange behavior:

  1. I commentedthis line

//beaconManager.setRegionExitExpiration(1000);

and onEddystonesFound event is invoked for next 20s although the batteries were removed from beacon.

  1. I uncommented the line

beaconManager.setRegionExitExpiration(1000);

and now, the onEddystonesFound doesn’t invoked after I removed the batteries.

So: in 0.16.0 setRegionExitExpiration setting was affecting the behavior of EddystoneListener!
and in 1.0+ anymore. I’ve tried it on the same device with the same app.

It could be very usefull to make a function like setEddystonesFoundExpiration in 1.0+ version!

We are working on a solution for this problem. First we will try to automatically calculate expiration time based on how frequently we receive packet. Secondly we are adding timestamp field to packet classes so you will know when the last packet was really received and you can filter them in onFound method.

1 Like

@pober

thank you! second thing is very nice to have!