You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
didRangeBeaconsInRegion is called no more than once every 2111ms
Actual behavior
didRangeBeaconsInRegion is called more than once per scanning interval. We take one timestamp at the beginning of the callback and then utilize that timestamp for all of our beaconLogs. Once the beaconLogs have all been created, they are sent to our API.
overridefundidRangeBeaconsInRegion(beacons:Collection<Beacon>, region:Region) {
if (beacons.isEmpty()) {
return
}
val readingTakenAt =Date().time
val someList =ArrayList<BeaconLog>()
for (beacon in beacons){
someList.add(BeaconLog(beacon))
}
// business logic and send to api
}
Querying our database revealed that, the frequency being divisible by 2000 meant it was more likely to be less than the scanning interval.
I would share the logs, but this seems to be reproducible across devices, given enough time, and is difficult to gather logs for.
Steps to reproduce this behavior
Using the sample application, set up foreground service, put beacons at various broadcasting frequencies nearby the device, (<1m) let scan for 24 hours, calculate minimum time between broadcast.
It's hard to say for sure why this might happen without seeing the raw timestamps of when the scans started and ended.
Two points that may affect your measurements:
The library attempts to normalize the scan intervals so they start on a time period that is evenly divisible by the scan period. This is based on system time on the Android device.
If the device CPU is busy (or even if particular threads are busy) it may cause delays in when certain beacon results are delivered. If one scan result is delayed and the next one is not, it may cause what you report.
The issue reported in #198 may affect this as well, but that should cause an early detection only once each time a new beacon is detected in the background after a period where no beacons are visible.
Expected behavior
didRangeBeaconsInRegion only is called after the scanning interval elapses. IE with these intervals:
didRangeBeaconsInRegion is called no more than once every
2111ms
Actual behavior
didRangeBeaconsInRegion is called more than once per scanning interval. We take one timestamp at the beginning of the callback and then utilize that timestamp for all of our beaconLogs. Once the beaconLogs have all been created, they are sent to our API.
Querying our database revealed that, the frequency being divisible by 2000 meant it was more likely to be less than the scanning interval.
We changed our interval from
2100
to2111
(prime number) and repeated the experiment.I would share the logs, but this seems to be reproducible across devices, given enough time, and is difficult to gather logs for.
Steps to reproduce this behavior
Using the sample application, set up foreground service, put beacons at various broadcasting frequencies nearby the device, (<1m) let scan for 24 hours, calculate minimum time between broadcast.
Mobile device model and OS version
Nokia 4.2 TA-1133
- Android 9Samsung T-380
- Android 9Pixel 3a
- Android 10Nexus 9
- Android 5,6,7Android Beacon Library version
implementation 'org.altbeacon:android-beacon-library:2.16.3-beta4@aar'
The text was updated successfully, but these errors were encountered: