Estimote / Android-Fleet-Management-SDK

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

Ranging returns duplicates for stickers #147

Closed doudasek closed 8 years ago

doudasek commented 8 years ago

Hi,

I'm just testing stickers with new Android SDK v0.10.0 (happened even in v0.9.4). If I start ranging with specified UUID and major, it returns duplicates time to time. I've noticed it especially happens when moving with phone or sticker.

Log:

onBeaconsDiscovered() called with: region = [Region{identifier=2, proximityUUID=d0d3fa86-ca76-45ec-9bd9-6af48071227c, major=56368, minor=null, secure=false}],

list = [[Beacon{macAddress=[E9:26:AE:4A:9D:25], proximityUUID=d0d3fa86-ca76-45ec-9bd9-6af48071227c, major=56368, minor=3182, measuredPower=-65, rssi=-49},

Beacon{macAddress=[E9:43:98:3E:0E:25], proximityUUID=d0d3fa86-ca76-45ec-9bd9-6af48071227c, major=56368, minor=3182, measuredPower=-65, rssi=-49},

Beacon{macAddress=[E9:3C:AE:8B:14:25], proximityUUID=d0d3fa86-ca76-45ec-9bd9-6af48071227c, major=56368, minor=3182, measuredPower=-65, rssi=-51},

Beacon{macAddress=[E9:52:06:FB:CA:25], proximityUUID=d0d3fa86-ca76-45ec-9bd9-6af48071227c, major=56368, minor=3182, measuredPower=-65, rssi=-54},

Beacon{macAddress=[E9:28:7D:CC:AD:25], proximityUUID=d0d3fa86-ca76-45ec-9bd9-6af48071227c, major=56368, minor=3182, measuredPower=-65, rssi=-71}]]

My code:

            mRegion = new Region(
                    "0",
                    UUID.fromString("d0d3fa86-ca76-45ec-9bd9-6af48071227c"),
                    56368, 
                    null);

            mBeaconManager = new BeaconManager(getActivity().getApplicationContext());
            mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
                @Override
                public void onServiceReady() {
                    mBeaconManager.startRanging(mRegion);
                }
            });

            mBeaconManager.setErrorListener(new BeaconManager.ErrorListener() {
                @Override
                public void onError(final Integer integer) {
                    mBeaconsInRange = null;
                }
            });

            mBeaconManager.setRangingListener(new BeaconManager.RangingListener() {
                @Override
                public void onBeaconsDiscovered(final Region region, final List<com.estimote.sdk.Beacon> list) {
                    Log.d(TAG, "onBeaconsDiscovered() called with: " + "region = [" + region + "], list = [" + list + "]");
                    mBeaconsInRange = list;
                }
            });

Sticker info: Operating System - SA1.1.0 Hardware Revision - SB0

The same happens to my friend who use iOS SDK. Where is problem?

Thank you, Martin

Poberro commented 8 years ago

What is happening is that you are listening to iBeacon packets that are interleaved with main Nearable packets. Since stickers are rotating MAC addresses (clearly seen on log above), scanner recognizes them as several different devices. If you move the device, it will advertise those packets more frequently. You can find more information here: http://developer.estimote.com/nearables/stickers-vs-beacons/

If you wish to have only one device returned you should listen for Nearables using following code:

       mBeaconManager.setNearableListener(new BeaconManager.NearableListener() {
          @Override
          public void onNearablesDiscovered(List<Nearable> list) {

          }
        });
        mBeaconManager.startNearableDiscovery();

(See https://github.com/Estimote/Android-SDK#quick-start-for-nearables-discovery) Stickers will be differentiated using their unique identifier, not a MAC address and there will be no duplicates returned by listener.

BTW. Those packets contain much more information like:

doudasek commented 8 years ago

Thank you!