Estimote / Android-Fleet-Management-SDK

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

Some beacons not found when monitoring #219

Closed lwasylkowski closed 7 years ago

lwasylkowski commented 7 years ago

We have an issue with our app not recognizing some of the beacons. I've created a trivial app, register for monitoring of 4 beacons, and only two are ever found (very consistently and immediatiely). Estimote app founds all of them immediately.

This is all the code:

public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getSimpleName();

    private static List<BeaconRegion> regions = new ArrayList<BeaconRegion>() {{
        add(new BeaconRegion("CAF4B0AB-876E-4644-BE90-AEA64AC14FED", UUID.fromString("CAF4B0AB-876E-4644-BE90-AEA64AC14FED"), 100, 20));
        add(new BeaconRegion("5D73747E-4360-F223-4C60-DCB07EF61443", UUID.fromString("5D73747E-4360-F223-4C60-DCB07EF61443"), 100, 33));
        add(new BeaconRegion("B9407F30-F5F8-466E-AFF9-25556B57FE6D", UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), 100, 4));
        add(new BeaconRegion("5510C9A0-F621-4431-9E0F-46546C683375", UUID.fromString("5510C9A0-F621-4431-9E0F-46546C683375"), 100, 5));
    }};

    private BeaconManager beaconManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        EstimoteSDK.initialize(this.getApplication(), APP_ID, APP_SECRET);
        EstimoteSDK.enableDebugLogging(true);
    }

    @Override
    protected void onResume() {
        super.onResume();

        SystemRequirementsChecker.checkWithDefaultDialogs(this);

        if (!SystemRequirementsHelper.checkAllPermissions(this)) {
            return;
        }

        beaconManager = new BeaconManager(this);

        beaconManager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener() {
            @Override
            public void onEnteredRegion(BeaconRegion beaconRegion, List<Beacon> list) {
                Log.d(TAG, String.format("onEnteredRegion: %s", beaconRegion.toString()));
            }

            @Override
            public void onExitedRegion(BeaconRegion beaconRegion) {
                Log.d(TAG, String.format("onExitedRegion: %s", beaconRegion.toString()));
            }
        });

        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            @Override
            public void onServiceReady() {
                for (BeaconRegion region : regions) {
                    beaconManager.startMonitoring(region);
                }
            }
        });
    }

    @Override
    protected void onPause() {
        if (beaconManager != null) {
            beaconManager.disconnect();
            beaconManager = null;
        }
        super.onPause();
    }
}

Here's the breakdown of the beacons we use:

5d73747... - G1.8, Estimote OS 4.9.4 - found caf4b0a... - F2.2, Estimote OS 4.5.0 - found b9407f3... - D3.4, Estimote OS 3.2.0 - not found 5510c9a... - D3.4, Estimote OS 3.2.0 - not found

The first two are found almost immediately. The other two - never. Here's logcat:

EstimoteSDK  I  BeaconService.onCreate:79 Creating beacon service for android version 25
EstimoteSDK  V  BeaconService.startMonitoring:195 Starting iBeacon monitoring: BeaconRegion{identifier=CAF4B0AB-876E-4644-BE90-AEA64AC14FED, proximityUUID=caf4b0ab-876e-4644-be90-aea64ac14fed, major=100, minor=20, secure=false}
             V  BeaconService.startMonitoring:195 Starting iBeacon monitoring: BeaconRegion{identifier=5D73747E-4360-F223-4C60-DCB07EF61443, proximityUUID=5d73747e-4360-f223-4c60-dcb07ef61443, major=100, minor=33, secure=false}
             V  BeaconService.startMonitoring:195 Starting iBeacon monitoring: BeaconRegion{identifier=B9407F30-F5F8-466E-AFF9-25556B57FE6D, proximityUUID=b9407f30-f5f8-466e-aff9-25556b57fe6d, major=100, minor=4, secure=false}
             V  BeaconService.startMonitoring:195 Starting iBeacon monitoring: BeaconRegion{identifier=5510C9A0-F621-4431-9E0F-46546C683375, proximityUUID=5510c9a0-f621-4431-9e0f-46546c683375, major=100, minor=5, secure=false}
BluetoothAdapter  D  isLeEnabled(): ON
BluetoothLeScanner  D  onClientRegistered() - status=0 clientIf=5 mClientIf=0
MainActivity  D  onEnteredRegion: BeaconRegion{identifier=5D73747E-4360-F223-4C60-DCB07EF61443, proximityUUID=5d73747e-4360-f223-4c60-dcb07ef61443, major=100, minor=33, secure=false}
NetworkSecurityConfig  D  No Network Security Config specified, using platform default
MainActivity  D  onEnteredRegion: BeaconRegion{identifier=CAF4B0AB-876E-4644-BE90-AEA64AC14FED, proximityUUID=caf4b0ab-876e-4644-be90-aea64ac14fed, major=100, minor=20, secure=false}
BluetoothAdapter  D  isLeEnabled(): ON

I'm using Google Pixel, Android 7.1.2; estimote SDK 1.0.3 release

I've tried disabling hardware filtering (I think this is an issue in our other app), but nothing changed (not even logs about hardware filtering being disabled)

xcastoreo commented 7 years ago

Hi @lwasylkowski,

see the issue #211, the version of your beacons is the cause ^^

lwasylkowski commented 7 years ago

I see. Still, I feel this is an open issue and a bug in the SDK. First, Estimote App does find the beacons, so it's possible. Second - beacons batteries are supposed to last for years. It doesn't seem right that the official SDK isn't compatible with them only after a year or so

pawelDylag commented 7 years ago

Hello @lwasylkowski , @xcastoreo

Sorry for the delay, we've been very busy here :) Thank you for the straightforward bug report. I appreciate all the details! This is a bug indeed - we are to blame here ;) The scanning for old D3.4 beacons must have been affected by our latest changes. This will be fixed in next release, stay tuned!

For being patient and pointing this out - here is a cookie for you: 🍪 :)