1

I'd like to use the AltBeacon Library to detect the RadBeacon Tag from Radius Networks. To understand how the library works I'd like to use the reference application of AltBeacon.

I implemented this code in my sample app. After adding the AltBeacon Library into the project I can run the project.

Like I mentioned before I' like to detect the IBeacons RadBeacon Tag from Radius Networks. I know that I need to use the BeaconParser. My Question is how the BeaconParser for RadBeacon Tag look like. Here is a IBeacon Parser for Estimote Beacons.
When I debug this project and look inside of the logcat I can see the following messages:

"Beacon detected: id1: "UUID of RadBeacon" id2= "Major of RadBeacon" id3:"Minor of RadBeacon"".
"looking for ranging region mathes for this beacon"
"got record"
"This is not a matching Beacon advertisment."

How do i need to change the BeaconParser? Here is my source code

public class FindRadBeaconActivity extends ActionBarActivity implements BeaconConsumer{
private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
protected static final String TAG = "RangingActivity";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_find_rad_beacon);

    // check bluetooth
    verifyBluetooth();

    beaconManager.getBeaconParsers().add(new BeaconParser().
            setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
    beaconManager.debug = true;
    beaconManager.bind(this);

}

@Override 
protected void onDestroy() {
    super.onDestroy();
    beaconManager.unbind(this);
}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.find_rad_beacon, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

@Override
public void onBeaconServiceConnect() {
    beaconManager.setMonitorNotifier(new MonitorNotifier() {
    @Override
    public void didEnterRegion(Region region) {
      Log.i(TAG, "I just saw an beacon for the first time!");       
    }

    @Override
    public void didExitRegion(Region region) {
      Log.i(TAG, "I no longer see an beacon");
    }

    @Override
    public void didDetermineStateForRegion(int state, Region region) {
        Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);      
    }
    });

    try {
        beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
    } catch (RemoteException e) {   }
}

private void verifyBluetooth() {

    try {
        if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) {
            final AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Bluetooth not enabled");          
            builder.setMessage("Please enable bluetooth in settings and restart this application.");
            builder.setPositiveButton(android.R.string.ok, null);
            builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    finish();
                    System.exit(0);                 
                }                   
            });
            builder.show();
        }           
    }
    catch (RuntimeException e) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Bluetooth LE not available");         
        builder.setMessage("Sorry, this device does not support Bluetooth LE.");
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setOnDismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                finish();
                System.exit(0);                 
            }

        });
        builder.show();

    }

}

}

Community
  • 1
  • 1
EricTag
  • 11
  • 4

1 Answers1

0

If you are looking for RadBeacon Layout, use the below layout

mBeaconManager
            .getBeaconParsers()
            .add(new BeaconParser()
                    .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149