Correct layout for detecting Kontakt beacon on Android using AltBeacon

I am trying to detect a Contact Beacon with the following BeaconLayout:

setBeaconLayout("m:8-9=0215,i:10-13,i:14-15,i:16-17,i:18-25")); 

but I don't seem to be doing it right. Proposal structure is as follows:

enter image description here

Thanks in advance.

+11
android ibeacon altbeacon
Aug 15 2018-11-14T00:
source share
2 answers

Thanks to @davidgyoung's comments, I finally discovered my Kontakt lighthouse with the following code:

 public class MainActivity extends Activity implements BeaconConsumer { protected static final String TAG = "RangingActivity"; BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25")); beaconManager.bind(this); } @Override public void onBeaconServiceConnect() { beaconManager.setRangeNotifier(new RangeNotifier() { @Override public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) { if (beacons.size() > 0) { Log.d(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) { } } 

Please note that I am using a Kontakt version 2.2 beacon, which is different from the version posted above.

+12
Aug 17 '14 at 19:51
source share

A few problems with your beaconLayout:

  • The byte offsets in the beaconLayout line start with the manufacturer data (byte 6 in the table that you are showing), so you need to subtract 6 from all of your offsets.

  • The table shows that there are only three identifiers in the beacon, but your beaconLayout line has four. Note that the first identifier is 16 bytes long.

If you earn it, write the correct beaconLayout that you used.

+5
Aug 15 '14 at 21:09
source share



All Articles