Altbeacon库测距仅在30%的时间内检测到信标

时间:2014-10-01 06:27:17

标签: android ibeacon altbeacon

我正在使用AltBeacon库来搜索设备附近的信标。我使用的是库的所有默认值,即扫描周期为1100毫秒,扫描周期为0毫秒。

该库每1100毫秒调用一次我的监听器,但问题是在很多这样的调用中,没有信标检测。信标只被检测到大约30%-40%的呼叫,另外70%的呼叫表示周围没有信标。

我该怎么做才能解决这个问题?

此致

2 个答案:

答案 0 :(得分:5)

在审查了私人发送的非常大的50秒LogCat摘录后,我看到有两个信标被不定期检测到:

Beacon #1 7383942b-xxxx-xxxx-xxxx-xxxxxxxxxxxx id2: 5 id3: 5000
   Max time between detections:   5.75600001 s
   Mean time between detections:  2.03854544 s
   % range cycles with detection: 51%

Beacon #2 b9407f30-xxxx-xxxx-xxxx-xxxxxxxxxxxx id2: 60039 id3: 2279
   Max time between detections:   4.794999515 s
   Mean time between detections:  1.377583336 s
   % range cycles with detection: 82 %

库代码按预期每1100毫秒启动和停止蓝牙扫描,并且在89%的测距周期中,检测到两个信标中的至少一个。这表明应用程序,库和操作系统都正常工作 - 没有重要的时间段没有检测到信标。更重要的是,每个信标的RSSI表明在日志期间相当强的信号是相当一致的。但是信标的检测间隔是高度不规则的。这很不寻常。

这表明无线电或硬件问题,无论是信标,电话还是无线电环境。一些可能性:

  1. 信标真的没有定期传输,实际上确实有辍学。 (如果您使用两种不同的信标模型,这似乎不太可能。)
  2. 手机的蓝牙硬件有一个问题,导致它错过了很多蓝牙广告包(可能是由于CRC错误),因此操作系统,库和应用程序永远不会看到它们。
  3. 测试是在一个有很多无线电噪声的地方进行的,导致可能性2中提到的CRC错误。
  4. 我认为Android设备的问题最有可能发生,尽管我承认这是我见过的第一个这样的情况。我建议您尝试使用第二个Android设备,看看是否可以重现该问题。由于这可能是硬件问题,因此记录您正在使用的设备模型会很有用。

    编辑:提问者离线发送了其他信息说他正在使用带有2.0-beta7版本库的Nexus 5,并说这个问题以前不存在,只在升级时出现到这个版本的库。我自己在Nexus 5和2.0-beta7版本的库上做了一些额外的测试,修改了android-beacon-library-reference应用程序,在每个测距回调中添加以下代码:

    public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
        if (beacons.size() > 0) {
            EditText editText = (EditText)RangingActivity.this
                    .findViewById(R.id.rangingText);
            int rssi = -100;
            for (Beacon beacon: beacons) {
                logToDisplay("Beacon "+beacon.toString()+" is about "+beacon.getDistance()+" meters away, with Rssi: "+beacon.getRssi());
                if (beacon.getId1().toString().equals("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6") && beacon.getId2().toString().equals("1") && beacon.getId3().toString().equals("1")) {
                    rssi = beacon.getRssi();
                }
            }
            if (rssi > -100) {
                Log.d(TAG, "Beacon found in ranging cycle.  rssi: "+rssi);
            }
            else {
                Log.d(TAG, "Beacon not found in ranging cycle");
            }
    
        }
    }
    

    然后我以10Hz的频率打开RadBeacon USB传输2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 / 1/1,然后用滤波器和结果查看调试输出。正如您所看到的,在没有检测到任何信标的情况下,我运行测试的60秒没有循环。

    $ adb logcat -v time | grep "ranging cycle"
    
    10-07 15:17:00.076 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:01.180 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -73
    10-07 15:17:02.287 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -75
    10-07 15:17:03.422 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:04.545 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:05.714 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:06.815 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:07.989 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -65
    10-07 15:17:09.087 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -72
    10-07 15:17:10.198 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -65
    10-07 15:17:11.322 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -71
    10-07 15:17:12.484 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:13.587 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -64
    10-07 15:17:14.758 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:15.867 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:16.998 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:18.195 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:19.280 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:20.415 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:21.560 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:22.659 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:23.802 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:25.035 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -66
    10-07 15:17:26.189 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:27.331 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -73
    10-07 15:17:28.458 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:29.618 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -67
    10-07 15:17:30.756 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -84
    10-07 15:17:31.886 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -76
    10-07 15:17:33.047 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -76
    10-07 15:17:34.193 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -85
    10-07 15:17:35.339 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -83
    10-07 15:17:36.502 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -90
    10-07 15:17:37.683 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -78
    10-07 15:17:38.871 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -87
    10-07 15:17:40.079 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -90
    10-07 15:17:41.234 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -85
    10-07 15:17:42.422 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -87
    10-07 15:17:43.588 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -88
    10-07 15:17:44.751 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -88
    10-07 15:17:45.924 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -86
    10-07 15:17:47.114 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -83
    10-07 15:17:48.264 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -82
    10-07 15:17:49.409 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -82
    10-07 15:17:50.612 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -88
    10-07 15:17:51.781 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -79
    10-07 15:17:52.913 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -79
    10-07 15:17:54.122 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -82
    10-07 15:17:55.296 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -84
    10-07 15:17:56.441 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -89
    10-07 15:17:57.631 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -75
    10-07 15:17:58.782 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -63
    10-07 15:17:59.924 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -71
    10-07 15:18:01.098 D/RangingActivity(16630): Beacon found in ranging cycle.  rssi: -72
    

答案 1 :(得分:1)

编辑:看到日志摘录后,我提交了第二个答案。

有两种可能性浮现在脑海中:

  1. 尝试在Android设备上禁用WiFi时重复此测试。某些Android设备将WiFi /蓝牙组件组合在一起使用时会相互干扰。

  2. 确保它不是硬件问题。尝试使用已知的工作扫描程序,如安装了定位应用程序的iOS设备或Android Locate app(使用相同的自定义信标解析器表达式),看看是否看到相同的行为。