How to get a unique beacon identifier using the Estimote SDK in Android

I am developing an application in which I use Beacons. To do this, I passed the corresponding Estimote SDK. Now the fact is that I need to know the unique identifier of a particular beacon. Suppose I have 3 beacons and they are all present in the range of the device. Now I want to perform different functions based on the unique identifier of the beacons. To do this, I need to know the unique identifier of each lighthouse. Currently I am giving the UUID for the beacon and just checking if it is in the device area or not. My code is as follows: -

private static final String ESTIMOTE_PROXIMITY_UUID = "XYZ"; private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId",ESTIMOTE_PROXIMITY_UUID, null, null); beaconManager.setMonitoringListener(new MonitoringListener() { @Override public void onExitedRegion(Region region) { //Region Exited } @Override public void onEnteredRegion(Region arg0, List<Beacon> arg1) { // TODO Auto-generated method stub //Do something ... } }); 

Now I need to get a unique beacon identifier programmatically so that I can make a decision depending on the identifiers. Please help me deal with this. Any help would be noticeable. Thanks.

+7
android ibeacon ibeacon-android android-ibeacon estimote
source share
2 answers

Each lighthouse has an ID .
ID is 20 bytes long and is divided into three parts:

  • proximityUUID (16 bytes)

  • major number (2 bytes)

  • minor number (2 bytes).

How to use them to identify a particular beacon?

First, you should know that there may be many lighthouses around you. These beacons may come from other suppliers, companies, or developers, so you want to filter them out.
To filter beacons, you must use proximityUUID to group beacons provided by you or your company. Give the same proximityUUID all your beacons.
After that, you can start monitoring and vary:

 private final Region MY_BEACONS = new Region("MY_BEACONS","YOUR_PROXIMITY_UUID", null, null); beaconManager.startMonitoring(MY_BEACONS); beaconManager.startRanging(MY_BEACONS); 

Now, at your listeners, you will be notified when your lighthouses are in the area.

Now suppose you are writing a movie theater app in a city. Each cinema has two different beacons to perform different actions. How to distinguish between cinema beacons and how to do it for a specific beacon in speculative cinema?

Use the major and minor fields. For example:

  • use major to identify all beacons in a particular movie theater,
  • use minor to identify a particular beacon in a particular movie theater.

When you create an ID for beacons this way, you can get a specific beacon and complete the action:

  private final int SCARY_CINEMA_ID = 1111; private final int SCARY_CINEMA_BEACON_1 = 1; private final int SCARY_CINEMA_BEACON_2 = 2; private final int COMEDY_CINEMA_ID = 2222; private final int COMEDY_CINEMA_BEACON_1 = 1; private final int COMEDY_CINEMA_BEACON_2 = 2; @Override public void onEnteredRegion(Region region, List<Beacon> beacons) { for(Beacon beacon : beacons){ if(beacon.getMajor() == SCARY_CINEMA_ID){ if(beacon.getMinor == SCARY_CINEMA_BEACON_1){ //do something for this beacon } else{ //do something for second beacon in cinema } } else if(beacon.getMajor == COMEDY_CINEMA_ID){ ... } } 

Hope this helps you :)

+6
source share
0
source share

All Articles