Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
836 stars 451 forks source link

Cannot start monitoring on more than 5 beacons #197

Closed iernie closed 7 years ago

iernie commented 7 years ago

I have a loop that starts monitoring on multiple beacons. The code looks something like this

beaconManager.connect(() -> {
    for (BeaconObject beacon : beacons) {
        beaconManager.startMonitoring(new Region(
            beacon.identifier,
            UUID.fromString(beacon.uuid),
            beacon.major,
            beacon.minor)
        );
    }
});

Only, consistently throughout my testing, whenever I add more than 5 beacons, nothing happens. If I go 5 or fewer it works like it should. I cannot figure out why. Any help appreciated.

Im using SDK 0.16.0 on a Pixel XL running Android 7.1.1.

pawelDylag commented 7 years ago

Hello @iernie

Each region sets low-level, ScanFilter in Android BLE stack - some phones have problems with dealing with many filters, so you might want to reduce the number of regions. You can try to move all those beacons under one UUID and MAJOR, and just identify them via different MINOR. In such way, you would be able to set only one region for all those beacons. Also, if you see no possibility to manage regions, you can try turning off hardware filtering using our flag. In your Android Manifest add: <meta-data android:name="disable_hardware_filtering" android:value="true" />

iernie commented 7 years ago

It seems that turning hardware filtering off did the trick.

One more question, though. If I try to add the region without minor, the region I get in onEnterRegion lacks minor as well. Is there any way to get the minor from the beacon when using a region with only UUID and major? If I can do this, I would prefer this over turning hw filtering off, but not if I cannot know what beacon did trigger it and that onEnterRegion triggers for every beacon, not just the first.

pawelDylag commented 7 years ago

Hello @iernie!

Your monitoring listener should return list with beacons in onEnteredRegion.
When entering region, this implies that there is only one beacon in this list -> the one that triggered event. You can access this object to get MINOR data.

iernie commented 7 years ago

Thanks for the help @pawelDylag !