I am new to programming iBeacons, and was wondering if someone could help me with a question about ranging updates using the AltBeacon library (android-beacon-library-2.5.1). I have some RadBeacon Dot beacons by Radius networks, which are advertising at 10Hz. I'm just trying the Ranging example from the AltBeacon Quick Start page which looks like this:
public class RangingActivity extends Activity implements BeaconConsumer {
protected static final String TAG = "RangingActivity";
private BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
beaconManager = BeaconManager.getInstanceForApplication(this);
// To detect proprietary beacons, you must add a line like below corresponding to your beacon
// type. Do a web search for "setBeaconLayout" to get the proper expression.
// beaconManager.getBeaconParsers().add(new BeaconParser().
// setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
beaconManager.unbind(this);
}
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Log.i(TAG, "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}}
This is all straightforward, but ranging only returns range data at 1Hz via the didRangeBeaconsInRegion call back. I am wondering how to get range data more frequently from the library, and can't see how to do it. Since the beacons adevrtise at 10Hz, I'd ideally like to sample rssi values from them at this rate (or close to it). It is possible to set the bluetooth scan times to a corresonding value, but the call backs still only occur at 1 Hz. Does anyone know any way to do this?
Thanks in advance, Patrick