问题
I'm on Android 6.0.1 (Nexus 5) and testing beacon montoring via the Altbeacon library 2.9.1, and while testing the device at home near the beacon (a few rooms away) I get multiple entry/exit callbacks. The beacon is based off of a Raspberry Pi 3 with the default settings (transmitting as iBeacon).
I am using the Altbeacon reference app however in the log output I'm seeing entry event messages (didEnterRegion) every 5-6 minutes, resulting in notifications. The Nexus 5 is stationary on the desk during this time.
The only source code modification was to add a specific region to monitor, but that is about it.
Any ideas on why the behavior is this way?
回答1:
The most likely explanation is that transmissions from the beacon are only intermittently being received by your Android device.
With default settings, the Android Beacon Library considers a region as having been exited if no beacons matching the region have been detected in 10 seconds. A Linux beacon transmitter will by default send out advertisements once per second. If 10 of these transmissions are missed in a row, you will get a region exit, then a region entry the next time one is received. Understand that even under ideal conditions, not all beacon transmissions are received due to radio noise and other issues. Once you get near the edge of the beacon's transmitter range, such intermittent exit/entry events will happen increasingly frequently.
To solve this problem you can do a number of things:
Increase the transmitter frequency of your beacon from 1 Hz to 10 Hz. This will make it much less likely that no beacon packets will be received in 10 seconds.
Increase the transmitter power if possible (although this likely is not possible with a Raspberry Pi)
Move the beacon closer to the Android receiver
Increase the region exit timeout to 20 secs from 10 secs by calling
BeaconManager.setRegionExitPeriod(20000l);
来源:https://stackoverflow.com/questions/40835671/altbeacon-reference-app-and-multiple-exit-entry-calls