我在我的Android应用程序中使用Radius网络altbeacon库,但每当我从locate app广播altbeacon时,我的应用程序无法检测到altbeacon。
这是我的信标解析器: -
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
这是我的ANDROID STUDIO LOGCAT: -
06-11 11:43:45.239 15797-16636/optimus.com.optimusiothome D/BeaconParser:Ignoring pdu type 01
06-11 11:43:45.239 15797-16636/optimus.com.optimusiothome D/BeaconParser: Processing pdu type FF: 02011a1aff4c0002152f234454cf6d4a0fadf2f4911ba9ffa600000000c50000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
06-11 11:43:45.239 15797-16636/optimus.com.optimusiothome D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 02011a1aff4c0002152f234454cf6d4a0fadf2f4911ba9ffa600000000c50000000000000000000000000000000000000000000000000000000000000000
每当我从我的iphone中的locate app传输altbeacon时,下面的代码会在我的Android应用程序中多次打印在logcat中,但主要关注的是,didRangeBeaconsInRegion()函数从未被调用,并且我的函数中的代码未被执行即我的Android应用程序无法检测altbeacon(从myiphone中的locate app发送): -
06-11 11:44:38.669 18053-18072/optimus.com.optimusiothome D/ScanRecord: parseFromBytes
06-11 11:44:38.669 18053-18072/optimus.com.optimusiothome D/ScanRecord: first manudata for manu ID
06-11 11:44:38.669 18053-18072/optimus.com.optimusiothome D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=69:86:DE:DD:64:1D, mScanRecord=ScanRecord [mAdvertiseFlags=26, mServiceUuids=null, mManufacturerSpecificData={76=[2, 21, 47, 35, 68, 84, -49, 109, 74, 15, -83, -14, -12, -111, 27, -87, -1, -90, 0, 0, 0, 0, -59]}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=null], mRssi=-55, mTimestampNanos=97773873478375}
我在android gradle中使用以下依赖项: -
compile 'org.altbeacon:android-beacon-library:2.7'
更多代码: -
@Override
public void onBeaconServiceConnect() {
Region region = new Region("all-beacon-region",null,null,null);
// this tells the library that we want to know about any beacon we see.
try {
mBeaconManager.startMonitoringBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
//The last line sets the rangeNotifier to this class,
//so our the same RangingActivity class will get callbacks each time a beacon is seen.
mBeaconManager.setRangeNotifier(this);
}
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
for(Beacon beacon : collection)
{
Log.d(TAG, "Beacon detected with id1: " + beacon.getId1() + " id2:" + beacon.getId2() + " id3: " + beacon.getId3() + " distance: " + beacon.getDistance());
((TextView)beacon_transmit_detect.this.findViewById(R.id.message)).setText("Beacon detected with id1: " + beacon.getId1() + " id2:" + beacon.getId2() + " id3: " + beacon.getId3() + " distance: " + beacon.getDistance());
}
}
@Override
protected void onResume()
{
super.onResume();
mBeaconManager=BeaconManager.getInstanceForApplication(this.getApplicationContext());
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
mBeaconManager.bind(this);
}
我的主类实现了BeaconConsumer,RangeNotifier。
答案 0 :(得分:1)
以下是主要信标布局的列表 检查您的布局是否正确。
ALTBEACON“m:2-3 = beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25”
EDDYSTONE TLM“x,s:0-1 = feaa,m:2-2 = 20,d:3-3,d:4-5,d:6-7,d:8-11,d: 12-15"
EDDYSTONE UID“s:0-1 = feaa,m:2-2 = 00,p:3-3:-41,i:4-13,i:14-19”
EDDYSTONE网址:s:0-1 = feaa,m:2-2 = 10,p:3-3:-41,i:4-20v“
IBEACON“m:2-3 = 0215,i:4-19,i:20-21,i:22-23,p:24-24”
此处的参考清单。