Coder Social home page Coder Social logo

Comments (6)

davidgyoung avatar davidgyoung commented on July 17, 2024

The way the Android bluetooth scanning works, you only get one callback for each unique device that Android sees while the scan is running. If you run a scan for 30 seconds, you will only get one signal strength measurement over that period, and you won't have any way to know if the device disappeared. The only way I can find to get periodic updates about a device is to stop scanning and restart.

The reason I chose 1100 ms as the scan interval is to emulate the iOS callback frequency as much as possible. In iOS, you get an update about an iBeacon every 1000 ms. But stopping scanning and restarting exactly every 1000 ms is problematic, because some devices advertise at a frequency of 1000ms. If these intervals are synchronized, it is possible that you could miss every advertisement from a device because you are stopping scanning in the middle of every single one of its transmissions. Thus, I made it start and stop at a slightly different frequency.

from android-ibeacon-service.

OneWorld123 avatar OneWorld123 commented on July 17, 2024

I agree with you. What are the reasons for taking this 5 minute break
between each scan? Do you also emulate some interval from iOS or did you
come up with that time period after some testing? Do you have experience
about the impact on battery live?
Am 05.12.2013 17:52 schrieb "David G. Young" [email protected]:

The way the Android bluetooth scanning works, you only get one callback
for each unique device that Android sees while the scan is running. If you
run a scan for 30 seconds, you will only get one signal strength
measurement over that period, and you won't have any way to know if the
device disappeared. The only way I can find to get periodic updates about a
device is to stop scanning and restart.

The reason I chose 1100 ms as the scan interval is to emulate the iOS
callback frequency as much as possible. In iOS, you get an update about an
iBeacon every 1000 ms. But stopping scanning and restarting exactly every
1000 ms is problematic, because some devices advertise at a frequency of
1000ms. If these intervals are synchronized, it is possible that you could
miss every advertisement from a device because you are stopping scanning in
the middle of every single one of its transmissions. Thus, I made it start
and stop at a slightly different frequency.


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-29914845
.

from android-ibeacon-service.

davidgyoung avatar davidgyoung commented on July 17, 2024

Yes, this emulates what iOS does with an eye toward saving battery usage. From my experience with iOS, I know that when no application is actively ranging beacons in the foreground, the max time it takes to detect an entry/exit from a region slows down to between 4 minutes and 15 minutes. The 5 minute break is basically a shot at a reasonable approach on Android.

I have not done any testing on how this affects battery life, but I would love to have that info. If you would be interested in doing some measurements, please let me know!

from android-ibeacon-service.

davidgyoung avatar davidgyoung commented on July 17, 2024

Some updates on battery life.

As of 0.7, the default background scan interval (which is customizable) is to do one 10 second scan every 5 minutes. In the foreground, a scan is always active.

Here are the rough numbers measured on a Nexus 4:

Using the service in the foreground uses 90.5 mA
Using the service in background mode uses 37.4mA (59% savings)

Details are here.

from android-ibeacon-service.

OneWorld123 avatar OneWorld123 commented on July 17, 2024

Thanks for your testing. I have to apologize for not responding lately.
Could you please share some details about your test? How long did your test take until you measured the 90.5 mA and 37.4 mA consumption? Like a fixed amount of time or from 100% to 0% of the Nexus 4's battery?

from android-ibeacon-service.

davidgyoung avatar davidgyoung commented on July 17, 2024

Yes, the rudimentary tests were similar to what you describe. Here's a link to what we did: https://github.com/RadiusNetworks/android-ibeacon-service/wiki/Battery-Usage

from android-ibeacon-service.

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.