Detect and show the beacons in every 60 seconds or so

Hi,
I am working on the Phonegap Application on the platform called Telerik using this Estimote Plugin http://plugins.telerik.com/cordova/plugin/estimote .

I am trying to show list of beacons around the device. The Application is keep detecting the beacons and the list value like distance from the beacons is keep changing.

I want to slow the process I meant I want to detect the beacons in every particular interval like in every 30 seconds or so.

I have tried using setInterval or setTimeout. But no luck so far.

Would you please help me in achieving the above.

Thanks.

Our Android SDK allows doing that via the the setForegroundScanPeriod method:

http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/BeaconManager.html#setForegroundScanPeriod(long,%20long)

With this method, you can set how often, and for how long the SDK scans for beacons. For example, “scan for 10 seconds every 50 seconds,” which would give you 60-second callbacks.

I took a quick look at this Cordova plugin and they don’t actually expose this method from our SDK. So you would either need to do it yourself, or request they add it, and hope for the best.

Alternatively, you can modify your callback and emulate slower scans:

document.addEventListener('beaconsReceived', onBeaconsReceived, false);

var detectedBeacons = {};
var scanCounter = 0;

function onBeaconsReceived(result) {
  if (result.beacons && result.beacons.length > 0) {
    for (var i=0; i<result.beacons.length; i++) {
      var beacon = result.beacons[i];
      // store every discovered beacon for later
      var beaconKey = beacon.major + ":" + beacon.minor;
      detectedBeacons[beaconKey] = beacon;
    }
  }
  // by default, onBeaconsReceived is called every second
  // so if we count to 60, this will mean a minute has passed
  if (++scanCounter == 60) {
    onLongScanCompleted(detectedBeacons);
    detectedBeacons = {}; // reset the list
    scanCounter = 0; // reset the counter
  }
}

function onLongScanCompleted(beacons) {
  // your code here
}