Is this the correct layout to detect iBeacons with AltBeacon's Android Beacon Library?

别等时光非礼了梦想. 提交于 2019-11-26 03:02:58

问题


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:

  • Example of an iBeacon packet seen on SO

回答1:


That worked for me, too!

I don't think you need to match the 4c00 part because that is the manufacturer id, so you can probably leave that off and start with m:2-3=0215 Everything else looks right, and it seems to work.




回答2:


You can download the iBeacon spec (click "Download Artwork and Specifications").

In the current version the Company ID must be 0x4C00, and the beacon type must be 0x0215. All other fields are required, and as you specified.

So yes, you are exactly correct and it will detect all compliant iBeacons.

OT: It also specifies that the advertising interval must be 100ms, but I seriously doubt all iBeacons stick to that.



来源:https://stackoverflow.com/questions/25027983/is-this-the-correct-layout-to-detect-ibeacons-with-altbeacons-android-beacon-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!