无法使用Altbeacon检测信标(TI SensorTag CC2650)

时间:2016-05-02 14:02:14

标签: android bluetooth-lowenergy ibeacon altbeacon

我正在尝试使用Altbeacon库检测TI SensorTag作为iBeacon。

我已经实现了Altbeacon教程中的代码,并尝试解析为iBeacon布局,如本文所述:

Is this the correct layout to detect iBeacons with AltBeacon's Android Beacon Library?

然而,

的大小
Collection<Beacon> beacons = 0 

即使我可以在日志文件中找到Beacon,如下所示:

  

D / BluetoothLeScanner:onScanResult() - ScanResult {mDevice = A0:E6:F8:B6:62:01,mScanRecord = ScanRecord [mAdvertiseFlags = 5,mServiceUuids = [0000aa80-0000-1000-8000-00805f9b34fb],mManufacturerSpecificData = {13 = [3,0,0]},mServiceData = {},mTxPowerLevel = 0,mDeviceName = CC2650 SensorTag],mRssi = -36,mTimestampNanos = 625504179339285}

我的代码如下:

public class BeaconActivity extends Activity implements BeaconConsumer {

    private final static int REQUEST_ENABLE_BT = 1;
    private static final String TAG = "BeaconActivity";

    private BeaconManager beaconManager = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_beacon);
        beaconManager = BeaconManager.getInstanceForApplication(this);
        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);
    }

    @Override
    public void onBeaconServiceConnect() {
        beaconManager.setRangeNotifier(new RangeNotifier() {
            @Override
            public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
                Log.d(TAG, "onBeaconService");
                if (beacons.size() > 0) {
                    Beacon firstBeacon = beacons.iterator().next();
                    Log.i(TAG, "The first beacon " + firstBeacon.toString() + " is about " + firstBeacon.getDistance() + " meters away.");
                }
            }
        });

        try {
            beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));

        } catch (RemoteException e) {
            Log.v(TAG, "Error whilte trying to startRangingBeaconsInRegion: ", e);
        }
    }

1 个答案:

答案 0 :(得分:0)

下面显示的日志行表示检测到的BLE数据包信标传输。这可能意味着SensorTag未加载正确的固件作为信标进行传输。

D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=A0:E6:F8:B6:62:01, >mScanRecord=ScanRecord [mAdvertiseFlags=5, mServiceUuids=[0000aa80-0000-1000->8000-00805f9b34fb], mManufacturerSpecificData={13=[3, 0, 0]}, mServiceData={}, >mTxPowerLevel=0, mDeviceName=CC2650 SensorTag], mRssi=-36, >mTimestampNanos=625504179339285}

以上意味着检测到的SensorTag传输正在为制造商德州仪器发送GATT服务UUID和制造商广告,其中包含三个数据字节:03 00 00.该传输与任何已知的信标格式不对应。