Search code examples
androidibeacon-androidandroid-ibeaconeddystone

Randomize scan period for eventual beacon detection


I am trying to understand the statement "We recommend not reducing the scan period to be less than 1.1 seconds, since many beacons only transmit at a frequency of 1 Hz" used in android beacon library documentation.

Is it because we might miss the beacon packet as the scan time is too less? My use case requires to keep the battery consumption in check. I wanted to ask if this particular scenario will work.

I have set background scan time of 20ms and background between scan time of 980ms.

This means that there is a scan every second. This configuration can increase responsiveness of the application. Also, as the scan period is low, it should save battery too.

1) Will this configuration be able to detect beacon? 2) If it misses due to low scan period, is it still possible to detect beacons in the next scan? 3) If the frequency of of transmission is 1Hz and if it misses onces, will it miss everytime as the total of both the background scan time and between scan time is 1 second? 4) If yes, will randomizing scan periods within a range help?

Thanks


Solution

  • Consider the following factors:

    1. If a beacon packet is sent over the air when a scan is active, you have a 90% chance of detecting it at close range.

    2. If the scan is started or stopped in the middle of the transmission, the packet will not be detected.

    3. Starting scanning is not instantaneous. It takes time. From the time you command scanning to start, you will miss packets until scanning is fully started. This time this takes is device dependent, but it is probably in the 10s of milliseconds.

    4. If you set a scan period shorter than the beacon transmission rate, the odds of detecting it are reduced approximately by the ratio of the scan period divided by the transmission period.

    5. BLE advertisement packets are sent out irregularly.

    All of the above factors mean that short scan intervals are bad for reliable detections. If you want to save battery, you are better off leaving the scanner on for 1.1 seconds, then leaving it off for as long as you need to reach your battery targets. Trying to make average detection times faster by reducing both the scan period and the between scan period will only make the average detection time slower, because you are losing useful scan time by the time wasted cycling on and off based on points 2 and 3.