Search code examples
ibeaconibeacon-androidaltbeacon

Beacon getDistance() Units of measurement and calculation methods


I've started to use the Android Beacon Library from RadiusNetwork. After some try, i've reached the result to display my iBeacon data on Nexus 5. The questions are:

The distance are in meters or in some other units? I've seen that there is an algorithm based upon the power and the rssi, there is a way to improve the precision of the function beacon.getDistance()?


Solution

  • The units are in meters. The included algorithm is based on a best fit curve using measured distance vs. 60 second averaged RSSI values for a Nexus 5. The real time estimates are based on a 20 second average of the RSSI.

    You may easily customize the algorithm by overriding the Beacon class with one that provides a custom calculateDistance method.

    You tell the library about your new beacon class by making a custom BeaconParser class that returns this beacon type from the BeaconParser.fromScanData method. Once you have this class, you register it like so:

    BeaconManager.getBeaconParsers().add(myCustomBeaconParser);