在定位应用程序中检测到iBeacon,但在Beacon Tools中未检测到

时间:2017-07-19 09:32:09

标签: android bluetooth-lowenergy ibeacon transmission

我正在尝试从设备传输主要次要ID,使其成为使用库

的iBeacon
compile 'org.altbeacon:android-beacon-library:2.9.2@aar'

代码

if (mBeaconTransmitter != null) {
            mBeaconTransmitter.stopAdvertising();
        }
        BeaconParser beaconParser=new BeaconParser();
        mBeaconTransmitter = new BeaconTransmitter(getApplicationContext(), new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
        int flag= mBeaconTransmitter.checkTransmissionSupported(this);
        Log.v("@@@WWe"," BEacon Test "+flag);
        Beacon beacon = new Beacon.Builder()
                .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
                .setId2(majorID)//Major
                .setId3(minorID)//Minor
                .setBluetoothName("Vyas Pratik")
                .setBeaconTypeCode(533)
                .setManufacturer(0x0075) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
                .setTxPower(-59)
                .setMultiFrameBeacon(true)
                .build();
//                .setId2(minorID)//Major Try
//                .setId3(majorID)//Minor Try
                //.setBluetoothAddress(bluetoothManager.getAdapter().getAddress())
                //    .setDataFields(Arrays.asList(new Long[]{0l}))


        mBeaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
            @Override
            public void onStartSuccess(AdvertiseSettings settingsInEffect) {
                super.onStartSuccess(settingsInEffect);
                Log.v("@@@WWe"," Sucess "+settingsInEffect.toString());
            }

            @Override
            public void onStartFailure(int errorCode) {
                super.onStartFailure(errorCode);
                Log.v("@@@WWe"," Error "+String.valueOf(errorCode));
            }
        });

但是,使用此代码的信标在Locate app中检测到,但在beacon tools app / near(Google app)中未检测到。请指导我。

由于

1 个答案:

答案 0 :(得分:1)

经过几次试错法后,我找到了解决这个问题的方法,UUID和制造商ID错了。 所以我将它改为低于值,并且信标现在正在谷歌附近和beacon工具中检测到

 Beacon beacon = new Beacon.Builder()
//                .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
//                .setManufacturer(0x0118) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
                .setId1("6d234454-cf6d-4a0f-adf2-f4911ba9ffa6")
                .setManufacturer(0x4c) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
                .setId2(majorID)//Major
                .setId3(minorID)//Minor
                .setBluetoothName("Vyas Pratik")
                .setTxPower(-59)
                .build();