2017-07-19 51 views
0

我想利用圖書館iBeacon顯示檢測定位應用程序,但不是在燈塔工具

compile 'org.altbeacon:android-beacon-library:[email protected]' 

代碼

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)); 
      } 
     }); 

但是傳輸從設備使其成爲一個iBeacon顯示主要和次要ID,我的燈塔使用此代碼在「定位」應用程序中檢測到,但未在「信標工具」應用程序/附近(Google應用程序)中檢測到。請引導我。

感謝

回答

1

幾個試錯招後,我到了這個問題,UUID的解決方案,以及製造商ID是錯誤的。 所以我把它改成下面的值和信標現在就在附近檢測在谷歌和燈塔工具藏漢

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(); 
+0

高興你發現了它。是的,使用iBeacon,您必須將製造商代碼設置爲Apple的代碼。 – davidgyoung

+0

是的,設置製造商代碼和正確的uuid使我的代碼工作 –

相關問題