Android AltBeacon Unable To Detect PiBeacon Device

530 Views Asked by At

I am working on Android beacon app with PiBeacon as a beacon device.
I have setup Respberry Pi As Beacon Device as given on adfruit website.
I can see that PiBeacon is transmitting by using other BLE Scanner application available on Play Store.
I have download the Altbeacon and configure my Android Studio Project according to given guide on Altbeacon Sample but the app is not showing the ble device. Can anyone help me what i am doing wrong ? Following is the code that i am using for scanning PiBeacon.

public class MonitoringActivity extends Activity implements BeaconConsumer {
    protected static final String TAG = "MonitoringActivity";
    private BeaconManager beaconManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ranging);
        beaconManager = BeaconManager.getInstanceForApplication(this);
        // To detect proprietary beacons, you must add a line like below corresponding to your beacon
        // type.  Do a web search for "setBeaconLayout" to get the proper expression.
        // beaconManager.getBeaconParsers().add(new BeaconParser().
        //        setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
        beaconManager.bind(this);
    }

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

    @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) {    }
    }
}
1

There are 1 best solutions below

0
On

The PiBeacon you reference sends and iBeacon transmission, but by default, the Android Beacon Library only detects open-source AltBeacon transmissions.

It's easy to detect other beacon types, but you need to add a new BeaconParser for the beacon type you are interested in. The instructions are right there in the comments of the code you posted:

To detect proprietary beacons, you must add a line like below corresponding to your beacon type. Do a web search for "setBeaconLayout" to get the proper expression.

Apologies, for the need to do this -- unfortunately intellectual property restrictions mean that we cannot include the expression in the library or post it on public forums like this. Fortunately, it is easy to find with a Google search.