Estimote / Android-Proximity-SDK

Estimote Proximity SDK for Android
https://developer.estimote.com
MIT License
83 stars 41 forks source link

Proximity SDK : onExit triggers late when beacon flipped to off #83

Closed ManojMM026 closed 5 years ago

ManojMM026 commented 6 years ago

Prerequisites

Basic information

Estimote SDK version: 1.0.1

Android devices affected: Samsung galaxy s8.

Android OS version affected: Oreo 8.1

Beacon hardware version: J1.6

Description

I am using proximity sdks to detect enter and exit of beacon. However what I have observed is beacon enter triggers fairly quicker than beacon exit when you flip the beacon to off. Another issue is when I flip it to on ti fires multiple events with enter and exit.

(Optional) Steps to reproduce:

  1. Flip beacon to off
  2. Flip Beacon to on

Expected behavior: It should quickly trigger enter and exit event for each beacon as I am observing them separately with separate tag.

Actual behavior: Enter event triggers fairly quick but exit events sometimes take too long to fire.

Additional information

  //setup cloud credentials
         val cloudCredentials = EstimoteCloudCredentials(AppConstants.ESTIMOTE_APP_ID, AppConstants.ESTIMOTE_APP_TOKEN)

         beaconTagList.add(beaconIce)
         beaconTagList.add(beaconBlueBerry)
         beaconTagList.add(beaconMint)
         beaconTagList.add(beaconHermanBlueberry)
         beaconTagList.add(beaconLemon)

         //Create observer
         proximityObserver = ProximityObserverBuilder(this, cloudCredentials)
                 .withTelemetryReportingDisabled()
                 .withAnalyticsReportingDisabled()
                 .withEstimoteSecureMonitoringDisabled()
                 .withLowLatencyPowerMode()
                 .onError {

                     it.printStackTrace()
 //                    AppConstants.showToast(this, it.message!!)
                     Log.e(AppConstants.TAG, "Error " + it.printStackTrace())

                 }
                 .build()

         for (beaconTag in beaconTagList) {
             //Create zone for beacons with specified tag
             var venueZone = ProximityZoneBuilder()
                     .forTag(beaconTag)
                     .inNearRange()
                     .onEnter { przCtx ->
                         AppConstants.loge("Beacon Event Entering Device  " + przCtx.deviceId + " TAG : " + przCtx.tag)
                     }
                     .onExit {
                         AppConstants.loge("Beacon Event  Exiting Device  " + it.deviceId + " TAG : " + it.tag)

                     }
                     .onContextChange {
                         for (zone in it) {
                         AppConstants.loge("Beacon Event Entering Device  " + zone.deviceId + " TAG : " + zone.tag)

                         }
                     }
                     .build()
             venueZones.add(venueZone)
         }

         //start observing
         observationHandler = proximityObserver
                 .startObserving(venueZones)
pawelDylag commented 5 years ago

Hey @ManojMM026

Our proximity algorithms are somehow based on a RSSI of your beacon. If you flip it to off, it will immediately stop advertising, thus not providing us enough information about the potential position. In such case our SDK "automatically" triggers onExit after 20s, and this is why you get this event delayed. In the real world application it would not make a problem - people will constantly receive signals from the beacon. This only affect development cycle.

Don't worry, we're working on a different approach for developing/testing your app in your debug environment, just stay tuned! 🚀

Cheers, Paweł