2

I experience an issue and can reproduce it on different devices with different Android OS. I get the expected behaviour with iBeacon scanning for the first time. When I scan the next time I get no Beacons. The result list in delegate is empty. I printed a count on the setRangeNotifier with the size of the beacons but apparently after it only shows the beacons size to be 1 for the first time after which it continually displays a 0.

beaconManager.setRangeNotifier(new RangeNotifier() {
    @Override
    public void didRangeBeaconsInRegion(final Collection<Beacon> beacons, Region region) {
       Log.d("Beacons count",beacons.size());
    }
});

Output: Beacons Count 1 Beacons Count 0 Beacons Count 0 Beacons Count 0

My ranging period and scanning period is as below

beaconManager.setBackgroundScanPeriod(1000l);
beaconManager.setBackgroundBetweenScanPeriod(31000l);
Furkan Varol
  • 252
  • 2
  • 8
MindBrain
  • 7,398
  • 11
  • 54
  • 74
  • 1
    This is in the background, yes? So each log line is every 32 seconds? What library version is this and what OS versions? (scanning code is different on 5.x and 4.x) – davidgyoung Feb 26 '15 at 22:26
  • Yeah. This service runs in the background. The OS version is CynogenMod. device is One Plus. Yes log line is every 32 seconds. Library version I am using is 2.0. Os Version is 4.4.4. – MindBrain Feb 27 '15 at 16:34
  • @davidgyoung : What is the ideal value to set for the BackgroundScanPeriod and the BackgroundBetweenScanPeriod in the code for receiving the beacon signals frequently? – MindBrain Feb 27 '15 at 17:16
  • Well, the background default of scanning for 10 seconds every 5 minutes is intended to save battery. For optimal responsiveness you should set it to the same as the foreground -- scan fotr 1.1 seconds every 1.1 seconds. – davidgyoung Feb 28 '15 at 00:09

3 Answers3

1

This is not expected behavior, and I have not seen this on Android 4.4 on other devices. Based on limited information, it is possible it could be an app issue, or it may be an issue with the 4.4 CynogenMod ROM for the One Plus. See my other answer with a detailed test case for a reference device (Nexus 5).

To eliminate the possibility of an app issue, try using the Locate app, which is based on the same library and see if you get the same results.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • @davidyoung Setting the Scanning period to scan for 1.1 for every 1.1 seconds has worked apparently. However, when the scanning periods are set as above it seems to miss beacons signals. – MindBrain Feb 28 '15 at 00:50
  • 1
    Hmmm... I cannot think why that might be true, but I will try it. – davidgyoung Feb 28 '15 at 01:11
1

I have tried to reproduce the symptoms you describe, but have been unable to do so on a Nexus 5 with Android 5 and a transmitting RadBeacon USB.

Reference application modifications:

  • Added these lines to the BeaconReferenceApplication onCreate() method:

    beaconManager.setBackgroundBetweenScanPeriod(1000l);
    beaconManager.setBackgroundBetweenScanPeriod(31000l);
    beaconManager.setAndroidLScanningDisabled(true);
    BeaconManager.setDebug(true);
    

The third line above is needed because I was testing on a Nexus 5 with Android 5 and I wanted to exercise the 4.x scanning APIs, like you would be done on a 4.4 phone.

  • Added this line to the RangingActivity didRangeBeaconsInRegion callback:

    Log.d(TAG, "ranged beacon: "+firstBeacon.toString());
    

Testing steps:

  • Enable a RadBeacon USB transmitting at 10 HZ.

  • Log the results with:

    $ /Users/dyoung/sdk-android-studio/platform-tools/adb logcat -v time | grep "anged beacon"
    
  • Run the reference app, started ranging in the foreground, and after three seconds put it into the background. See the following logging results:

    03-01 08:39:00.146 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:39:01.282 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:39:02.482 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:39:03.515 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:39:12.148 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:39:44.274 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:40:16.179 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:40:48.239 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:41:20.272 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:41:52.205 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    03-01 08:42:24.202 D/RangingActivity(11146): ranged beacon: id1: 04ff791e-f83b-434b-8031-1b3e72bdbcb7 id2: 1 id3: 1
    

As you can see, the callbacks come every 1.1 seconds in the foreground, and every 32 seconds in the background. This is as expected.

If you cannot repeat the above steps using the reference application on the OnePlus device with Cyanogenmod 4.4, then the issue may be with the ROM for that device. If you can confirm this and capture a full Logcat output for the period where the callbacks don't come (with debug turned on as described above), then please open an issue at http://github.com/AltBeacon/android-beacon-library/issues and attach a copy of the log capture.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
0

Upon further reflection I think it is the scan intervals that were the problem. The scan intervals reported were to spend 1 second looking for beacons every 32 seconds. This is not enough of a duty cycle, especially for beacons that transmit at only 1Hz. Not all transmissions are received due to radio noise, and it is important that scan durations be 1100 ms or more in order to prevent the transmission from straddling the boundary where the scanner is starting up or shutting down.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204