4

I'm currently working on a showcase app using BLE beacons from BEACONinside. I have set up my app to range two of my beacons (thus having 2 Regions). This works fine and I receive all the callbacks and all the beacon info I need.

I'm monitoring the reported distance and noticed that it will not update the distance values right away, but gradually. Looging each callback I see the reported distance decreasing slowly, even if I run towards the beacons. That means, even with a (for testing) very low scanning interval, I reached the beacons and still have to wait up to ten seconds for the reported distance to reflect the proximity.

Is there a reason for that, and can I tweak a setting to have it updating right away?

My scenario is simply two beacons placed at different points and I want to trigger an action when I get closer to them. So using ranging instead of monitoring would be the way to, right? At the moment I compare the last three measurements and see if I got closer to the beacon.

Thanks!

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
langerhans
  • 769
  • 7
  • 19

1 Answers1

7

Found the solution to this myself. I saw that the library will use a running average of the RSSI to calculate the distance. The sample expiration time is by default 20 seconds. This would explain the gradually updating distance.

So calling

RangedBeacon.setSampleExpirationMilliseconds(5000);

with 5 seconds being just what I was experimenting with, gives a faster response time and so far a good detection rate of the regions.

langerhans
  • 769
  • 7
  • 19
  • 2
    Glad you found the answer! This is correct. Understand that a smaller sampling interval will create more noise on the distance estimate, so make sure you can accept that tradeoff. – davidgyoung Aug 27 '14 at 11:30
  • 1
    Thanks for the heads up. I noticed that but it's acceptable and I tweaked my proximity check accordingly. I can get a sufficiently good detection rate now. BTW, if it's okay to provide feedback here. The magic numbers in the distance calculation are undocumented. It would be interesting to know where they come from and if they can be tweaked for different beacons. – langerhans Aug 28 '14 at 10:03