AltBeacon Library를 사용하여 Radius Networks에서 RadBeacon 태그를 감지하고 싶습니다. 라이브러리 작동 방식을 이해하려면 AltBeacon의 참조 응용 프로그램을 사용하고 싶습니다.AltBeacon 사용
샘플 앱에 this code을 구현했습니다. AltBeacon Library를 프로젝트에 추가 한 후에 프로젝트를 실행할 수 있습니다.
내가 전에 Radi Networks에서 제공하는 IBeacons RadBeacon 태그를 감지하고 싶습니다. BeaconParser를 사용해야한다는 것을 알고 있습니다. 내 질문은 RadBeacon 태그 용 BeaconParser가 어떻게 생겼는지입니다. Here은 Estimote Beacon 용 IBeacon 파서입니다.
나는이 프로젝트를 디버깅 나는 다음과 같은 메시지를 볼 수있는 로그 캣의 내부를 볼 때 :
"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."
어떻게 내가 BeaconParser를 변경해야합니까? 여기 내 소스 코드
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();
}
}
}