evothings / cordova-eddystone

Cordova/PhoneGap plugin for Eddystone beacons
Apache License 2.0
57 stars 35 forks source link

Long time between beacon detection #7

Open trivector-se opened 8 years ago

trivector-se commented 8 years ago

We are experiencing that the time between beacons detections tend to be very long after the app has run for a while.

Code used: evothings.eddystone.startScan( function(beacon) { newBeaconTime = new Date().getTime(); console.log('last found beacon ' + (newBeaconTime - lastFoundBeaconTime) + ' milliseconds ago'); lastFoundBeaconTime = newBeaconTime; // Update beacon data. beacon.timeStamp = Date.now(); beacons[beacon.address] = beacon; }, function(error) { showMessage('Eddystone scan error: ' + error); }); }

At first, the console outputs very small numbers, ranging from 20milliseconds to around 500 milliseconds.

After about a minute these numbers tend to reach 4000 to 7000 milliseconds.

Thanks in advance.

Regards, Jimmie J

idesignpixels commented 8 years ago

I have also seen this, it's almost like it gets lazy... spent ages debugging my own code but it's the plugin. I find after 3 minutes or so it deletes beacons and finds them and then deletes and so on, very frustrating!

ghost commented 8 years ago

Does this happen on iOS and/or Android?

idesignpixels commented 8 years ago

I have only tested in ios

ghost commented 8 years ago

@Lindstrom1989 Thanks, putting this on the TODO-list.

idesignpixels commented 8 years ago

Has there been any progress on this?

ghost commented 8 years ago

@Lindstrom1989 Sorry for slow response. I did testing on Android a while ago and noticed that performace varied a lot dependent on the device used. On Nexus 7 2013 it was very slow, on other Android devices it was much faster. On iOS it has been fast.

rmarquois commented 8 years ago

+1.

I have the same behavior on iOS 9.x (iPhone 5 and iPhone 6). The success callback is not called periodically when my beacon is on.

I logged into EVOBLE.m file - (void) centralManager: (CBCentralManager *)central didDiscoverPeripheral: (CBPeripheral *)peripheral advertisementData: (NSDictionary *)advertisementData RSSI: (NSNumber *)RSSI method and it seems that it comes from the Core Bluetooth framework.

No problem with Android (in my case Nexus 5 and Lollipop version).

ghost commented 8 years ago

@rmarquois Thanks for the update, will test Eddystone on iOS 9.

NodeKing commented 7 years ago

Has anyone managed to implement a fix for this?

yuhr commented 7 years ago

Probably this is the same problem I ran into. The interval value of my beacon is set to 100ms, and at first the API reports data per 100-200ms (acceptable for me), but gradually slows down - after a few minutes it reports per 200-2000ms - while the app is in foreground. When the app returns from background, the interval seems reactivated.

I've found a workaround for this; stop and start scanning periodically.

evothings.eddystone.startScan(cb, console.error);
setInterval(function() {
  evothings.eddystone.stopScan();
  evothings.eddystone.startScan(cb, console.error);
}, 1000);