#If OBJC
- (double) calculateAccuracy:(int)txPower :(double)rssi
{
if (rssi == 0) {
return -1.0; // if we cannot determine accuracy, return -1.
}
double ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
return powf(ratio,10);
} else {
double accuracy = (0.89976) * powf(ratio,7.7095) + 0.111;
return accuracy;
}
}
#End if
' Returns the estimated distance to a beacon in meters
Sub calculateDistanceFromPowerAndSignalStrength( txPower As Int, rssi As Double) As Double
Dim n As NativeObject = Me
Return n.RunMethod("calculateAccuracy::", Array As Object(txPower, rssi)).AsDouble
End Sub