Git Product home page Git Product logo

Comments (24)

davidgyoung avatar davidgyoung commented on August 20, 2024

Two requests:

  1. Will you please tell me the type of beacon you are using, and (if known) what the advertising frequency is?
  2. Will you please turn on debug logging, then attach to this issue a LogCat excerpt for the period where you see the exit/enter events? You can turn on debug logging with beaconManager.setDebug(true)

from android-beacon-library.

matiash avatar matiash commented on August 20, 2024
  1. It's an Estimote beacon. As far as I know the advertising interval hasn't been changed from the default value, so it should be 200ms.
  2. Log can be found at: https://gist.github.com/matiash/d0b1c406e51b19145c0b

There are a couple of REGION_CHANGE entries that I added to mark the spots where didEnterRegion() or didExitRegion() is fired. This seems to be caused by processExpiredMonitors(), maybe the INSIDE_EXPIRATION_MILLIS value should be increased?

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

@matiash, from the log it appears that some other Android process is running that is establishing a connection to your beacon. Do you maybe have an Estimote config app running? It looks to me like this connection may be stopping your beacon from advertising.

Looking at the log, it appears that the library detects the beacon at 12:53:40, then it doesn't detect it again for over 10 seconds, which is what causes your region exit notification. Here is the detection:

08-29 12:53:40.694 17873 650 D BtGatt.GattService: onScanResult() - address=EA:AB:94:75:4E:23, rssi=-96
...
08-29 12:53:40.734 4985 5274 D BeaconService: beacon detected :id1: b9407f30-f5f8-466e-aff9-25556b57fe6d id2: 20003 id3: 38005

A few seconds later, there is a client connection to a BLE device:

08-29 12:53:41.285 17873 17884 D BtGatt.GattService: registerClient() - UUID=ffd9954d-7d40-4767-be0d-f3e30ae01799

Then the next time it is detected is not for 16 seconds later, which is after the region exit fires. The library is designed to fire a region exit if a beacon is not seen in 10 seconds. This should be more than enough time if your beacon is behaving normally.

08-29 12:53:56.389 17873 650 D BtGatt.GattService: onScanResult() - address=EA:AB:94:75:4E:23, rssi=-92
...
08-29 12:53:56.409 4985 5268 D BeaconService: beacon detected :id1: b9407f30-f5f8-466e-aff9-25556b57fe6d id2: 20003 id3: 38005

from android-beacon-library.

matiash avatar matiash commented on August 20, 2024

Sorry, I was out a while. I'll test again and report. Thanks for the patience.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

Another piece of info that would be helpful here is the Android device model you are using, and whether you have WiFi enabled. Some Android models (Nexus 4, Nexus 7 tablet, Moto G, Moto X) have a conflict between WiFi and Bluetooth operating successfully at the same time.

from android-beacon-library.

matiash avatar matiash commented on August 20, 2024

Yes, I'm using a Nexus 7 2013. I knew about that issue and I do experience WiFi disconnections, could that be related to this other problem?

Unfortunately I'm stuck with other things at the moment and haven't been able to retest it. Sorry again.

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

I have the same issue here! i have the beacon right beside my fone and i get random exit/enter region every periodically.
did you guys manage to figure why that is happening ?

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

@naderz, will you please turn on debug logging, then attach to this issue a LogCat excerpt for the period where you see the exit/enter events? You can turn on debug logging with beaconManager.setDebug(true)

Also, will you please tell me the device model you are using and tell me whether it is connected to a WiFi network during the test?

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

@davidgyoung, thanks for your fast reply.
I am using estimote beacons with Note 3 device.
Wifi is turned off.

10-21 01:42:10.266 6881-7064/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
10-21 01:42:10.271 6881-7064/com.lixar.ibeacons D/BeaconService﹕ beacon detected :id1: b9407f30-f5f8-466e-aff9-25556b57fe6d id2: 27532 id3: 4479
10-21 01:42:10.271 6881-7064/com.lixar.ibeacons D/BeaconService﹕ This region does not match: id1: b9407f30-f5f8-466e-aff9-25556b57fe6d id2: 40657 id3: 26331
10-21 01:42:10.271 6881-7064/com.lixar.ibeacons D/BeaconService﹕ looking for ranging region matches for this beacon
10-21 01:42:10.716 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to stop scan for another 98 milliseconds
10-21 01:42:10.816 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Done with scan cycle
10-21 01:42:10.816 6881-6881/com.lixar.ibeacons D/MonitorState﹕ We are newly outside the region because the lastSeenTime of 1413808918178 was 12640 seconds ago, and that is over the expiration duration of 10000
10-21 01:42:10.816 6881-6881/com.lixar.ibeacons D/BeaconService﹕ found a monitor that expired: id1: b9407f30-f5f8-466e-aff9-25556b57fe6d id2: 40657 id3: 26331
10-21 01:42:10.816 6881-6881/com.lixar.ibeacons D/Callback﹕ attempting callback via intent: ComponentInfo{com.lixar.ibeacons/org.altbeacon.beacon.BeaconIntentProcessor}
10-21 01:42:10.831 6881-6881/com.lixar.ibeacons D/BluetoothAdapter﹕ stopLeScan()
10-21 01:42:10.846 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Restarting scan. Unique beacons seen last cycle: 1 Total beacon advertisement packets seen: 1
10-21 01:42:10.846 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 5000 milliseconds
10-21 01:42:10.851 6881-9296/com.lixar.ibeacons D/BeaconIntentProcessor﹕ got an intent to process
10-21 01:42:10.851 6881-9296/com.lixar.ibeacons D/BeaconIntentProcessor﹕ got monitoring data
10-21 01:42:10.856 6881-9296/com.lixar.ibeacons D/BeaconIntentProcessor﹕ Calling monitoring notifier:com.lixar.ibeacons.BaseApplication@42e5cdc8
10-21 01:42:10.856 6881-9296/com.lixar.ibeacons D/Nader﹕ UUIDb9407f30-f5f8-466e-aff9-25556b57fe6dMajor40657Minor26331
10-21 01:42:10.856 6881-9296/com.lixar.ibeacons D/Nader﹕ Exit Region
10-21 01:42:11.851 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 3998 milliseconds
10-21 01:42:12.851 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 2996 milliseconds
10-21 01:42:13.856 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 1993 milliseconds
10-21 01:42:14.856 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 992 milliseconds
10-21 01:42:15.851 6881-6881/com.lixar.ibeacons D/BluetoothAdapter﹕ startLeScan(): null
10-21 01:42:15.856 6881-8106/com.lixar.ibeacons D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
10-21 01:42:15.861 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to stop scan for another 1099 milliseconds
10-21 01:42:15.861 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Scan started
10-21 01:42:16.301 6881-6893/com.lixar.ibeacons D/BluetoothAdapter﹕ onScanResult() - Device=E3:50:66:DB:9E:D1 RSSI=-56
10-21 01:42:16.301 6881-6893/com.lixar.ibeacons D/BeaconService﹕ got record
10-21 01:42:16.306 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 0201061aff4c000215b9407f30f5f8466eaff925556b57fe6d9ed166dbb60909657374696d6f74650e160a18d19edb6650e3b6d19edb6600000000000000
10-21 01:42:16.306 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ This is a recognized beacon advertisement -- 0215 seen
10-21 01:42:16.306 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ Byte array is size 2
10-21 01:42:16.306 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 0
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 209 is 209
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 1
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 158 is 40448
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ Byte array is size 2
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 0
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 219 is 219
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 1
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 102 is 26112
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ Byte array is size 1
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 0
10-21 01:42:16.311 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 182 is 182
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ Byte array is size 2
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 0
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 21 is 21
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 1
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 2 is 512
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ Byte array is size 2
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 0
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 76 is 76
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ index is 1
10-21 01:42:16.316 6881-7069/com.lixar.ibeacons D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
10-21 01:42:16.321 6881-7069/com.lixar.ibeacons D/BeaconService﹕ beacon detected :id1: b9407f30-f5f8-466e-aff9-25556b57fe6d id2: 40657 id3: 26331
10-21 01:42:16.321 6881-7069/com.lixar.ibeacons D/Callback﹕ attempting callback via intent: ComponentInfo{com.lixar.ibeacons/org.altbeacon.beacon.BeaconIntentProcessor}
10-21 01:42:16.331 6881-7069/com.lixar.ibeacons D/BeaconService﹕ looking for ranging region matches for this beacon
10-21 01:42:16.331 6881-9340/com.lixar.ibeacons D/BeaconIntentProcessor﹕ got an intent to process
10-21 01:42:16.336 6881-9340/com.lixar.ibeacons D/BeaconIntentProcessor﹕ got monitoring data
10-21 01:42:16.336 6881-9340/com.lixar.ibeacons D/BeaconIntentProcessor﹕ Calling monitoring notifier:com.lixar.ibeacons.BaseApplication@42e5cdc8
10-21 01:42:16.336 6881-9340/com.lixar.ibeacons D/Nader﹕ UUIDb9407f30-f5f8-466e-aff9-25556b57fe6dMajor40657Minor26331
10-21 01:42:16.336 6881-9340/com.lixar.ibeacons D/Nader﹕ Got a didEnterRegion call
10-21 01:42:16.336 6881-9340/com.lixar.ibeacons D/Nader﹕ UUID b9407f30-f5f8-466e-aff9-25556b57fe6dMajor 40657Minor 26331
10-21 01:42:16.866 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to stop scan for another 98 milliseconds
10-21 01:42:16.966 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Done with scan cycle
10-21 01:42:16.966 6881-6881/com.lixar.ibeacons D/BluetoothAdapter﹕ stopLeScan()
10-21 01:42:16.976 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Restarting scan. Unique beacons seen last cycle: 1 Total beacon advertisement packets seen: 1
10-21 01:42:16.981 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 5000 milliseconds
10-21 01:42:17.986 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 3997 milliseconds
10-21 01:42:18.986 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 2994 milliseconds
10-21 01:42:19.991 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 1992 milliseconds
10-21 01:42:20.991 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to start next bluetooth scan for another 989 milliseconds
10-21 01:42:22.076 6881-6881/com.lixar.ibeacons D/BluetoothAdapter﹕ startLeScan(): null
10-21 01:42:22.086 6881-6893/com.lixar.ibeacons D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
10-21 01:42:22.096 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Waiting to stop scan for another 1100 milliseconds
10-21 01:42:22.096 6881-6881/com.lixar.ibeacons D/BeaconService﹕ Scan started
10-21 01:42:22.651 6881-6892/com.lixar.ibeacons D/BluetoothAdapter﹕ onScanResult() - Device=C0:5A:11:7F:6B:8C RSSI=-79
10-21 01:42:22.651 6881-6892/com.lixar.ibeacons D/BeaconService﹕ got record

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

if i am in the region of the beacon and my application is in the background, and periodic scanning is happening? is it normal to get random exit/enter? we shouldnt right ?
Btw i un installed all other estimote applications or IBeacon scanning applications that i had on my device

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

It is common for Estimote beacons to be configured to transmit only twice per second or less often to save battery power. This can be problematic, because sometimes transmissions are lost due to radio noise or low signal level. I suspect the infrequent transmission rate is what is causing your random exit events -- the Note 3 actually does not see any beacon transmissions during the sampling interval.

Three options: (1) increase the transmit frequency of your beacons, or replace them with beacons that transmit the recommended 10x per second (2) lengthen the sampling interval of the beacon library with beaconManager.setForegroundScanPeriod(5000l) / beaconManager.setBackgroundScanPeriod(5000l) (3) change the logic of your application to ignore exit events if they are followed by an entry event within a few seconds -- you'd have to use a timer to do this.

While I suspect this is the issue, the log you attached does not show an entry event followed by an exit event. So I could be certain, you would need to attach a log excerpt that shows didExitRegion followed by didEnterRegion

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

@davidgyoung thanks for the reply.
Sorry i was asleep, different timezones.
there is logs see : Exit Region
Enter : Got a didEnterRegion call

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

I just wanted to let you know that the transmit frequency was set on the device to 950ms.
So making it 5000ms scan period make it work. So i tried making it 2000ms the frequency of enter and exit was reduced but it still happened.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

Yes, the issue is that not 100% of beacon transmissions get received by mobile devices. They get lost due to radio noise and/or low signal. This is one of the many reasons that the best practice is to have beacons advertise as many times per second as possible. If no beacons are detected in the sampling interval, you will get exit notifications followed quickly by entry notifications. This happens on CoreLocation on iOS as well as in this library. Unfortunately, this is a hardware limitation.

Do you think setting the scan period to 5000ms is a sufficient solution for your use case? An alternative might be to have a separate setting for the region exit timeout that is independent of the scan interval.

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

@davidgyoung well i think 5000ms will make the battery die faster... so the less the better.
Can elaborate more on ur suggested solution ?

if not then maybe i can use Geofencing in my solution to make sure that i dont scan all the time.
Does your library support geofencing ? if it doesnt maybe after i finish my implementation i can push it to this library as well

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

@naderz, it doesn't really matter for battery how long the scans are in the foreground, as the libraeycscans all the time by default. As soon as it stops a scan cycle it starts one immediately.

In the background, the library pauses for 5 minutes between scans to save battery. If you leave this alone, your app should be pretty friendlyvon the battery.

from android-beacon-library.

naderz avatar naderz commented on August 20, 2024

So then there shouldnt be any concern with the 5000ms at all for scans.

Any thoughts about geofencing ? to maybe make the periodic scans more frequent in a certain area

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

It is very reasonable to alter the scan rate when inside a geofence. This library has no geofence functions, but google play services provide them. RadiusNetworks also has a ProximityKit service that combines geofences and beacon functionality. It is built on top of this library.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

Closing issue as the configured advertising frequency appears to be the root cause.

from android-beacon-library.

 avatar commented on August 20, 2024

@naderz - do mind sharing on how you got this fixed? please,

from android-beacon-library.

bhutta123 avatar bhutta123 commented on August 20, 2024

@davidgyoung As you mentioned in one of your comment that if library doesn't detect beacon for 10 seconds didExitRegion() gets called. How can i configure this value? I wan't to change this value to 1 minute to avoid to frequent enter/exit calls.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on August 20, 2024

This setting is now configurable. You can change the default 10 secs to 60 secs with:

beaconManager.setRegionExitPeriod(60000l)

That said, this is still not the recommended solution to the problem described in this issue. Increasing the frequency of beacon transmissions will give better results.

from android-beacon-library.

bhutta123 avatar bhutta123 commented on August 20, 2024

Thanks for the quick reply. Increasing frequency decrease battery life a lot. I have tested with 100ms frequeny also if device is far from the beacon (aprox boundry) it keeps entering and exiting the region within minutes though device is static.

from android-beacon-library.

andersborgabiro avatar andersborgabiro commented on August 20, 2024

My experience is that a beacon at 0 dBm and 1 second ping lasts 1 year on a CR2477 battery (mileage may vary), so 100 ms would be very draining. A lower power doesn't give good enough proximity precision, nor reach. I therefore recommend USB beacons, if there's a way to connect them.

from android-beacon-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.