Open gptshubham595 opened 1 year ago
Thanks for this report. Can you please provide a few samples of these two values when you see the negative distance?
Tested on Moto G5 S+
Also i've noted that the beacon reading (Ranged 0 beacons) even if the beacon advertiser and receiver are in close vicinity can you help how we can read beacons consistently
foregroundScanPeriod = 700
bacgroundScanPeriod = 700
RunningAverageRssiFilter.setSampleExpirationMiliSeconds(5000L)
Hi @davidgyoung
I faced the same issue that sometimes getting negative distance on Motorola devices.
Explanation :
Next, with this matched model, library will calculate the distance using the formula... ( Two cases )
If the ratio of RSSI measured by a device to the reference RSSI is less than 1 it will use the formula
Else will use
Something more than the above two cases...
In short, The negative distance measured in Motorola devices is because of the negative value of mCoefficient3.
I found this BeaconManager.setDistanceModelUpdateUrl let me try removing the motorola json values
It worked, but can you tell how we can get these three coefficient values for different phones ?
coz I know we can get distance via this formulae but for 2nd equation how we can get variables:
txpower = -40
ratio =(txpower-rssi)/40
distance= math.pow(10,ratio)
print(distance)
Yes, it sounds like the Motorola coefficients should be replaced in the library's built-in and web hosted device map file. As @RenisDudhat described above, there is a certain range of RSSI values input to the formula that will yield negative values and this should not happen.
There are instructions for calculating the constants in the last section of this page: https://altbeacon.github.io/android-beacon-library/distance-calculations.html
If you can take the measurements and come up with a set of coefficients that does not give negative values, we can replace the existing Motorola coefficients with a new one.
Hey, I tried these two formulas to get the values; if I get the C as -ve, I chose different formulae so that C should be positive or zero always
For Motorola device I got these values
A | B | C |
---|---|---|
2.33 | 4.75 | -1.85 |
A | B | C |
---|---|---|
1.60433254 | 5.33443408 | 0 |
@gptshubham595 and @RenisDudhat can you do some testing with these values and see how they work on your Motorola devices in practice?
A | B | C |
---|---|---|
1.60433254 | 5.33443408 | 0 |
In order to properly put this into the config file we really need to know the actual values reported by android.os.Build for:
Build.VERSION.RELEASE,
Build.ID,
Build.MODEL,
Build.MANUFACTURER
The CSV file relies on those actual values for matching purposes.
You can use this URL to configure the library with this equation for initial testing: https://android-beacon-library.s3.amazonaws.com/android-distance2.json
I made it the first equation for Motorola which should match that for your device if you device reports it Build.MANUFACTURER as "Motorola"
I used these values and all worked perfectly fine
@gptshubham595 can you please add code to read these values from your test phone? I can then use the results to add it to the library's built-in android-distance.json file:
Build.VERSION.RELEASE,
Build.ID,
Build.MODEL,
Build.MANUFACTURER
Yeah sure you can use these: I found out for Samsung, vivo, oppo, oneplus, moto, redmi
{
"models":
[
{
"coefficient1": 0.42093,
"coefficient2": 6.9476,
"coefficient3": 0.54992,
"version":"4.4.2",
"build_number":"KOT49H",
"model":"Nexus 4",
"manufacturer":"LGE"
},
{
"coefficient1": 0.42093,
"coefficient2": 6.9476,
"coefficient3": 0.54992,
"version":"4.4.2",
"build_number":"LPV79",
"model":"Nexus 5",
"manufacturer":"LGE",
"default": true
},
{
"coefficient1": 0.9401940951,
"coefficient2": 6.170094565,
"coefficient3": 0.0,
"version":"5.0.2",
"build_number":"LXG22.67-7.1",
"model":"Moto X Pro",
"manufacturer":"XT1115",
"default": false
},
{
"coefficient1": 1.60433254,
"coefficient2": 5.33443408,
"coefficient3": 0,
"version":"6.0",
"build_number":"MPE24.49-18",
"model":"XT1092",
"manufacturer":"Motorola",
"default": false
},
{
"coefficient1": 2.65,
"coefficient2": 3.91,
"coefficient3": 1.61,
"version":"12.0",
"build_number":"SP1A.210812.016",
"model":"CPH2401",
"manufacturer":"Oneplus",
"default": false
},
{
"coefficient1": 0.000475,
"coefficient2": 25.65,
"coefficient3": 5.86,
"version":"6.0",
"build_number":"",
"model":"",
"manufacturer":"Google",
"default": false
},
{
"coefficient1": 0.102139,
"coefficient2": 13.18,
"coefficient3": 2.38,
"version":"6.0",
"build_number":"",
"model":"",
"manufacturer":"Oppo",
"default": false
},
{
"coefficient1":1.660582 ,
"coefficient2": 6.05,
"coefficient3": 0.67,
"version":"6.0",
"build_number":"",
"model":"",
"manufacturer":"Redmi",
"default": false
},
{
"coefficient1": 1.35070638 ,
"coefficient2": 7.31428284,
"coefficient3": 0,
"version":"6.0",
"build_number":"",
"model":"",
"manufacturer":"samsung",
"default": false
},
{
"coefficient1": 1.9504739,
"coefficient2": 5.42879314,
"coefficient3": 0,
"version":"6.0",
"build_number":"",
"model":"",
"manufacturer":"Vivo",
"default": false
}
]
}
Expected behavior
Actual behavior
Steps to reproduce this behavior
Mobile device model and OS version
Android Beacon Library version
altbeacon_version = "2.19.4"