I am using a raspberry pi as a beacon. When I change the UUID of the Beacon, I want my android app using Android Beacon Library to detect the new UUID as fast as possible. In my knowledge two parameters can influence this: The scan period and the transmission rate. I am using 10Hz in the transmission and 300 ms in the setForegroundScanPeriod parameter. I am detecting the UUID change quite fast but I am wondering if there an optimal values for this two parameters to detect the change faster? Is there any other parameter that can influence this ?
The Android Beacon Library's ranging APIs are is designed to give regular updates on which beacons are visible, by default every 1.1 seconds. This means using default settings, and a beacon that advertises at 10 Hz (every 0.1 s), a first detection would come anywhere from 0.1-1.1 seconds later.
You can reduce the upper limit on this range by decreasing the scan interval in the library. If you call setForegroundScanPeriod(300l)
, the the maximum time to detection might go down to 300ms (0.3 seconds). For this to work, you must ensure your beacon is advertising at least at 10 Hz, otherwise the shorter scan cycles will often miss a detection and actually lead to longer detection times.
You could reduce this number even more, but you generally want the scan cycle to be at least 1.1x the length of your transmission rate for infrequent transmissions, or 2x for frequent transmissions. So for a beacon transmitting every 1s, set it to 1100ms. For one transmitting every 100ms, set it to 200ms.