0

https://altbeacon.github.io/android-beacon-library/samples.htmlのコードを使用して、次のように ios 8 の IBeacon エミッターを検出しようとしていますhttp://blog.passkit.com/configure-iphone-ibeacon -transmitter/で、どのステップが間違っているかが少しわかりません。Region で BeaconIdentifier を myMonitoringUniqueId として使用する必要がありますか? IBeacon を検出できません....使用しているライブラリが Android Beacon Library であるため、ios から IBeacon をリッスンするには追加の手順が必要ですか?

も追加

beaconManager.getBeaconParsers().add(new BeaconParser(). setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")) ;

これは、AltBeacon の Android ビーコン ライブラリで iBeacon を検出するための正しいレイアウトですか?

BeaconIdentifier = @"com.example.apple-samplecode.AirLocate";

import android.app.Activity;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import android.widget.TextView;

import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.logging.LogManager;


public class MainActivity extends Activity implements BeaconConsumer{

    protected static final String TAG = "MonitoringActivity";
    private BeaconManager beaconManager;
    private TextView message;
    private TextView num;
    private int IBeaconCount;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        message = (TextView)findViewById(R.id.IBeaconMsg);
        num = (TextView)findViewById(R.id.Numdetect);
        beaconManager = BeaconManager.getInstanceForApplication(this);
        /*
        *  beaconManager.getBeaconParsers().add(new BeaconParser().
               setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
        * */
        beaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
        //
        beaconManager.bind(this);
        //Hz to see if its receiveing from the emitter
        //beaconManager.setForegroundScanPeriod(2000l);
        //beaconManager.setBackgroundBetweenScanPeriod(1100l);
        //

        //IBeaconCount = 0;
        //num.setText(IBeaconCount);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        beaconManager.unbind(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        //num.setText(IBeaconCount);
    }

    @Override
    public void onBeaconServiceConnect() {
        beaconManager.setMonitorNotifier(new MonitorNotifier() {
            @Override
            public void didEnterRegion(Region region) {
                //IBeaconCount++;
                Log.i(TAG, "I just saw an beacon for the first time!");
                message.setText("I just saw an beacon for the first time!");
                LogManager.d(TAG, "didEnterRegion %s", region);

            }

            @Override
            public void didExitRegion(Region region) {
                Log.i(TAG, "I no longer see an beacon");
                message.setText("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);
                message.setText("I have just switched from seeing/not seeing beacons: "+state);
            }
        });

        try {
            //beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
            beaconManager.startMonitoringBeaconsInRegion(new Region("com.example.apple-samplecode.AirLocate", null, null, null));
        } catch (RemoteException e) {    }
    }

}

didEnterRegion Edited file Log のログメッセージがまだ表示されない:

04-08 12:45:39.283    7223-7223/com.mobinteg.ibeacon W/ModelSpecificDistanceCalculator﹕ Cannot find match for this device.  Using default
04-08 12:45:39.283    7223-7223/com.mobinteg.ibeacon W/ModelSpecificDistanceCalculator﹕ Cannot find match for this device.  Using default
04-08 12:45:39.303    7223-7223/com.mobinteg.ibeacon I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
    OpenGL ES Shader Compiler Version: E031.24.00.08
    Build Date: 03/21/14 Fri
    Local Branch: AU200+patches_03212014
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
04-08 12:45:39.343    7223-7223/com.mobinteg.ibeacon D/OpenGLRenderer﹕ Enabling debug mode 0
04-08 12:45:39.413    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ startLeScan(): null
04-08 12:45:39.453    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-08 12:45:39.483    7223-7262/com.mobinteg.ibeacon I/System.out﹕ Thread-1162(HTTPLog):isShipBuild true
04-08 12:45:39.483    7223-7262/com.mobinteg.ibeacon I/System.out﹕ Thread-1162(HTTPLog):SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
04-08 12:45:39.523    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=64:98:8D:4F:33:00 RSSI=-45
04-08 12:45:39.573    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=6A:7F:9C:42:A0:00 RSSI=-80
04-08 12:45:40.123    7223-7262/com.mobinteg.ibeacon W/ModelSpecificDistanceCalculator﹕ Cannot find match for this device.  Using default
04-08 12:45:40.563    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ stopLeScan()
04-08 12:45:40.563    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ startLeScan(): null
04-08 12:45:40.563    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-08 12:45:40.603    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=64:98:8D:4F:33:00 RSSI=-45
04-08 12:45:40.673    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=6A:7F:9C:42:A0:00 RSSI=-80
04-08 12:45:41.673    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ stopLeScan()
04-08 12:45:41.673    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ startLeScan(): null
04-08 12:45:41.673    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-08 12:45:41.713    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=64:98:8D:4F:33:00 RSSI=-44
04-08 12:45:42.783    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ stopLeScan()
04-08 12:45:42.803    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ startLeScan(): null
04-08 12:45:42.813    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-08 12:45:42.883    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=64:98:8D:4F:33:00 RSSI=-44
04-08 12:45:43.053    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=6A:7F:9C:42:A0:00 RSSI=-87
04-08 12:45:43.933    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ stopLeScan()
04-08 12:45:43.943    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ startLeScan(): null
04-08 12:45:43.953    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-08 12:45:44.003    7223-7248/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=6A:7F:9C:42:A0:00 RSSI=-79
04-08 12:45:44.013    7223-7246/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=64:98:8D:4F:33:00 RSSI=-39
04-08 12:45:45.063    7223-7223/com.mobinteg.ibeacon D/BluetoothAdapter﹕ stopLeScan()

----------------------------------------------編集2-- -------------------------------------------------- ------

以下のようにRangeNotifierをonBeaconServiceConnect内に追加しましたが、didRangeBeaconsInRegionとdidEnterRegion、didExitRegion、didDetermineStateForRegionには決して入りませんアプリが起動したときに一度だけ起動しますアプリが閉じられたときにすべてのリストを停止させる方法誰かがそれを行う方法を指摘できますか?

    beaconManager.setRangeNotifier(new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
            Log.i(TAG,"beacons.size less then 0???????");
            if (beacons.size() > 0) {
                Log.i(TAG, "The first beacon I see is about " + beacons.iterator().next().getDistance() + " meters away.");
            }

            /*
            for(Beacon beacon: beacons){
                Log.i(TAG, "Beacon detected with id1: "+beacon.getId1()+" id2:"+beacon.getId2()+" id3: "+beacon.getId3()+" distance: "+beacon.getDistance());
            }
            */
        }


    });

ログファイル:

04-09 12:28:16.383  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Waiting to stop scan cycle for another 1100 milliseconds
04-09 12:28:16.383  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Scan started
04-09 12:28:16.383  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Set scan periods called with 1100, 110 Background mode must have changed.
04-09 12:28:16.383  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ We are not in the background.  Cancelling wakeup alarm
04-09 12:28:16.383  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ cancel wakeup alarm: null
04-09 12:28:16.433  27850-27874/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=73:A5:A7:D6:24:06 RSSI=-67
04-09 12:28:16.433  27850-27874/com.mobinteg.ibeacon D/CycledLeScannerForJellyBeanMr2﹕ got record
04-09 12:28:16.443  27850-27872/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=D0:4F:7E:0A:88:5B RSSI=-92
04-09 12:28:16.443  27850-27872/com.mobinteg.ibeacon D/CycledLeScannerForJellyBeanMr2﹕ got record
04-09 12:28:16.443  27850-27891/com.mobinteg.ibeacon D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011a0bff4c0009060102000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
04-09 12:28:16.443  27850-27891/com.mobinteg.ibeacon D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting 02 15.  The bytes I see are: 02011a0bff4c0009060102000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
04-09 12:28:16.443  27850-27890/com.mobinteg.ibeacon D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011a1aff4c00021513ba60dbdcdb42ec99a33f7eef7bbdbd00000000c50000000000000000000000000000000000000000000000000000000000000000
04-09 12:28:16.443  27850-27890/com.mobinteg.ibeacon D/BeaconParser﹕ This is a recognized beacon advertisement -- 02 15 seen
04-09 12:28:16.443  27850-27890/com.mobinteg.ibeacon D/BeaconService﹕ beacon detected : id1: 13ba60db-dcdb-42ec-99a3-3f7eef7bbdbd id2: 0 id3: 0
04-09 12:28:16.443  27850-27890/com.mobinteg.ibeacon D/Callback﹕ attempting callback via intent: ComponentInfo{com.mobinteg.ibeacon/org.altbeacon.beacon.BeaconIntentProcessor}
04-09 12:28:16.453  27850-27890/com.mobinteg.ibeacon D/BeaconService﹕ looking for ranging region matches for this beacon
04-09 12:28:16.453  27850-27892/com.mobinteg.ibeacon D/BeaconIntentProcessor﹕ got an intent to process
04-09 12:28:16.453  27850-27892/com.mobinteg.ibeacon D/BeaconIntentProcessor﹕ got monitoring data
04-09 12:28:16.453  27850-27892/com.mobinteg.ibeacon D/BeaconIntentProcessor﹕ Calling monitoring notifier: com.mobinteg.ibeacon.MainActivity$2@420d5b28
04-09 12:28:16.453  27850-27892/com.mobinteg.ibeacon I/MonitoringActivity﹕ I have just switched from seeing/not seeing beacons: 1
04-09 12:28:16.453  27850-27892/com.mobinteg.ibeacon I/MonitoringActivity﹕ I just saw an beacon for the first time!
04-09 12:28:17.383  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Waiting to stop scan cycle for another 97 milliseconds
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Done with scan cycle
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ stopping bluetooth le scan
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/BluetoothAdapter﹕ stopLeScan()
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Normalizing between scan period from 110 to -1027
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ starting a new scan cycle
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ starting a new bluetooth le scan
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/BluetoothAdapter﹕ startLeScan(): null
04-09 12:28:17.493  27850-27872/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Waiting to stop scan cycle for another 1100 milliseconds
04-09 12:28:17.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Scan started
04-09 12:28:17.503  27850-27874/com.mobinteg.ibeacon D/BluetoothAdapter﹕ onScanResult() - Device=73:A5:A7:D6:24:06 RSSI=-63
04-09 12:28:17.503  27850-27874/com.mobinteg.ibeacon D/CycledLeScannerForJellyBeanMr2﹕ got record
04-09 12:28:17.503  27850-28015/com.mobinteg.ibeacon D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011a1aff4c00021513ba60dbdcdb42ec99a33f7eef7bbdbd00000000c50000000000000000000000000000000000000000000000000000000000000000
04-09 12:28:17.503  27850-28015/com.mobinteg.ibeacon D/BeaconParser﹕ This is a recognized beacon advertisement -- 02 15 seen
04-09 12:28:17.503  27850-28015/com.mobinteg.ibeacon D/BeaconService﹕ beacon detected multiple times in scan cycle : id1: 13ba60db-dcdb-42ec-99a3-3f7eef7bbdbd id2: 0 id3: 0
04-09 12:28:17.503  27850-28015/com.mobinteg.ibeacon D/BeaconService﹕ beacon detected : id1: 13ba60db-dcdb-42ec-99a3-3f7eef7bbdbd id2: 0 id3: 0
04-09 12:28:17.503  27850-28015/com.mobinteg.ibeacon D/BeaconService﹕ looking for ranging region matches for this beacon
04-09 12:28:18.493  27850-27850/com.mobinteg.ibeacon D/CycledLeScanner﹕ Waiting to stop scan cycle for another 99 milliseconds

---------------------------------------編集3--------- ----------------------------

didEnterRegion 内のログをに変更しました

Log.i(TAG, "I just saw an beacon for the first time! Id1->"+region.getId1());

didRangeBeaconsInRegionに入り始めましたが、beacons.size()は0として表示されます......

---------------------------------------編集 4--------- ------------------------------

デバイスでOKがLog.i(TAG, "I just saw an beacon for the first time! Id1->"+region.getId1()+" id 2:"+region.getId2()+" id 3:"+region.getId3());表示され、距離がうまく機能しています...

4

1 に答える 1