How to calculate distance between two iOS devices using Multipeer connectivity(Wifi network)?
Asked Answered
T

2

7

How to calculate the distance between two iOS devices using a wireless connection.

I figure out we can calculate using BLE, using RSSI number.

But the range of the device varies and the device placed in the room far away cannot be discovered.

My requirement is to calculate the distance device present in the room.

I have looked into the Multi-peer connectivity framework, but there is no such thing as the RSSI number.

Thanks in advance.

Treasury answered 9/6, 2020 at 13:30 Comment(4)
I didn't see any API for distance. I'd experiment with sending data of known size and seeing if speed correlates with distance enough to give you an estimateJarodjarosite
can you please elaborate or send any reference link for the same.Treasury
It’s just an idea. You have to try it. There is no link. Set up two phones 10 feet apart, send 1 k of data back and forth and measure the time. Then do the same with it 20, 30, 40 feet apart and measure the time. See if it matters how far apart they areJarodjarosite
Just collect a lot of data and then see if there is a correlationJarodjarosite
H
3

You can check the new NearbyInteraction https://www.reddit.com/r/iOSProgramming/comments/hfq5w8/nearbyinteraction_guide_and_github_repository/?utm_source=share&utm_medium=web2x&context=3

but will works on iphone 11 and above , bcz thes devices have the U1 chip

Haemagglutinate answered 18/11, 2020 at 7:21 Comment(3)
Thanks for the answer. We have achieved similar feature using iBeacon. I wanted to know whether it is possible with multipeer framework.Treasury
@ketakiDamale what distance was you able to achieve using iBeacon between iPhones?Crossbeam
@ketakiDamale kindly, can you share how you achieve itHaemagglutinate
T
0

@Lance Samaria and @ Bassem Halawa here is the code using iBeacon. I was able to achieve distance proximity 85% to 90%. I have used Kalman filter to reduce background noise.

Here is the link for Kalman filter : - [https://mcmap.net/q/1626672/-kalman-filter-for-rssi-in-ios/9673374][1]

I have calculated distance using RSSI value here is the code supporting that.

 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
        }
    }

Let me know if this was helpful. [1]: Kalman filter for RSSI in iOS

Treasury answered 18/1, 2021 at 7:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.