首页 文章

无法在android中检测Alt-beacon

提问于
浏览
0

我在我的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中的定位应用程序传输altbeacon以下代码在我的Android应用程序中多次打印在logcat中,但主要关注的是,didRangeBeaconsInRegion()函数永远不会被调用,并且我的函数中的代码未执行即我的android app无法检测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 .

1 回答

  • 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 URL“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”

    这里有参考清单 .

相关问题