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

2

100

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:

Categorize answered 30/7, 2014 at 2:46 Comment(2)
The reference application is down now..Costmary
@Costmary Thanks, updated the link to the new repo.Categorize
M
70

This worked for me: "m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"

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.

Montgomery answered 31/7, 2014 at 2:20 Comment(9)
Thanks! From testing with Estimote beacons I can confirm that the m:2-3=0215 change is indeed necessary.Gauger
This worked for me also..i used.. beaconManager.getBeaconParsers().add(new BeaconParser(). setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));Aspia
This detects Estimote beacons very efficiently..but i have another Roximity Beacon..its not getting detected..what is the beaconLayout for roximity beaconsAspia
How do you read that layout? What is m, i and p? I have an out-of-the-box beacon bought from China. By using Bluetooth LE Scanner app, I was able to find the beacon's UUID, major and minor. But how do I find the UUID pattern to put it into setBeaconLayout?Prog
@AimanB Kindly refer this : #25320182. In this, m: Manufacturer Data, i: Proximity UUID, i: Major Number, i : Minor Number, p: Signal Power,d : battery level. They represent byte offset. (You need to add 6 while counting).Eg: Manufacturer ID is in between 8th and 9th in the string "m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24".Microclimatology
is there a way to scan for any beacon around regardless if its estimote or not ?Address
The iBeacon spec does require the manufacturer ID to be 0x4c00, so yes you do need that part. I have also tested beacons with manufacturer IDs set to other values and they are not detected by various apps.Groschen
There have been two proposed patterns and some confusion over which is correct: "m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24" and "m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24 Can someone speak to which of these will detect iBeacons from all manufacturers?Veats
@Veats I suspect either should work. One is just more verbose than the other.Brothel
G
5

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.

Groschen answered 3/11, 2015 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.