OverMind
OverMind

Reputation: 135

Altbeacon library ranging is detecting a beacon only 30% of the time

I am using AltBeacon library to range beacons near my device. I am using all the default values of the library, that is 1100ms of scan period, and 0ms between scan periods.

The library is calling my listener every 1100ms, but the problem is that in a lot of this callings, there is no beacon detection. The beacon is only detected about 30%-40% of the callings, the other 70% of the callings says that there is no beacons around.

What can i do to solve this?

Regards

Upvotes: 3

Views: 2998

Answers (2)

davidgyoung
davidgyoung

Reputation: 64941

After reviewing a very large 50 second LogCat excerpt sent privately, I saw that two beacons were detected at irregular intervals:

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 %

The library code was starting and stopping bluetooth scans every 1100 ms as expected, and in 89% of the ranging cycles, at least one of the two beacons was detected. This suggests that the app, library and operating system are all working properly -- there are no significant periods of time where no beacons aren't being detected. What's more the RSSI of each beacon suggests a reasonably strong signal that is fairly consistent over the period of the log. But the detection interval of the beacons is highly irregular. This is unusual.

This suggests some radio or hardware issue, either with the beacons, the phone, or the radio environment. A few possibilities:

  1. The beacons really are not transmitting regularly, and actually do have dropouts. (This seems unlikely if you are using two different beacon models.)
  2. The phone's bluetooth hardware has an issue that is causing it to miss a lot of bluetooth advertising packets (perhaps due to CRC errors), so the operating system, library and app never see them.
  3. The testing is being done in a location with lots of radio noise, which is causing the CRC errors mentioned in possibility 2.

I think a problem with the Android device is the most likely of the possibilities, although I admit this is the first such case I have seen. I would suggest that you try with a second Android device and see if you can reproduce the issue. Because of the possibility that this is a hardware issue, it would be useful to document the device model you are using.

EDIT: The questioner sent additional information offline saying he was using a Nexus 5 with the 2.0-beta7 version of the library, and said the problem did not used to exist and only showed up when upgrading to this version of this library. I did some additional tests myself with on a Nexus 5 and the 2.0-beta7 version of the library, modifying the android-beacon-library-reference app to add the following code on each ranging callback:

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

    }
}

I then turned on a RadBeacon USB transmitting with 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6/1/1 at 10Hz, and then looked at the debug output with the filter and results below. As you can see, there was no cycle for the 60 seconds I ran the test where any beacons were not detected.

$ 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

Upvotes: 5

davidgyoung
davidgyoung

Reputation: 64941

EDIT: After seeing a log excerpt, I have submitted a second answer.

Two possibilities come to mind:

  1. Try repeating this test with WiFi disabled on your Android device. Some Android devices have combined WiFi/Bluetooth components that interfere with each other when in simultaneous use.

  2. Make sure it is not a hardware issue. Try using a known working scanner like an iOS device with the Locate app installed or the Android Locate app (using your same custom beacon parser expression) and see if you see the same behavior.

Upvotes: 1

Related Questions