I have successfully modified the reference implementation app of the Android Beacon Library using the following beacon layout, so that it detects an iBeacon device that I have at hand:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
}
}
Being new to the internals of BLE packets, I'm not sure if this is the correct layout to use. The library endorses the AltBeacon standard and its documentation does not mention how to detect iBeacon devices.
- Will this code detect all iBeacon devices? i.e. is the
m:
prefix too restrictive or is it the right byte sequence that matches the iBeacon spec? - Similarly, does the rest of the layout exactly match the iBeacon spec?
Reference: