I get the RSSI value from the searched bluetooth device in list.
But didn't know how to Calculate the distance.
We need txPower to calculate that but from where I get this txPower.
I'm using this code but don't know it's correct.
func calculateNewDistance(txCalibratedPower: Int, rssi: Int) -> Double{
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 know how to Calculate the distance.
We need txPower to calculate that but from where I get this txPower.
I'm using this code but don't know it's correct.
func calculateNewDistance(txCalibratedPower: Int, rssi: Int) -> Double{
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
}
}