How to Calculate the accurate distance from nearby bluetooth device like mobile phones in iOS?

I search the nearby Bluetooth devices. And using the RSSI and tx-power value (tx-power hardcoded power value Usually ranges between -59 to -65) the distance by this code. 

 func calculateNewDistance(txCalibratedPower: Int, rssi: Int) -> Double{
    //txCalibratedPower : hard coded power value. Usually ranges between -59 to -65
    if rssi == 0 { return -1 }
     
    let ratio = Double(exactly:rssi)!/Double(txCalibratedPower)
    if ratio < 1.0{
      return pow(10.0, ratio)
    }else{
      let accuracy = 0.89976 * pow(ratio, 7.7095) + 0.111
      return accuracy
    }
  }


But didn't get that much accuracy.

For android, they use the Kalman filter to remove the noise between the path and calculate the distance (80 - 85 %) accuracy.

So anyone helps me out to calculate the distance.

Question is already here but didn't have a solution : [https://stackoverflow.com/questions/3624945/how-to-measure-distance-between-two-iphone-devices-using-bluetooth)
Please refrain from asking the same question several times. Better look at answers and tell what you did or could not do with it.
https://developer.apple.com/forums/thread/656117

This being said, BT will not give you an "accurate" distance. Received signal strength depends on propagation conditions. And you should precise what accurate here means for you.
How to Calculate the accurate distance from nearby bluetooth device like mobile phones in iOS?
 
 
Q