Why not just use the inverse-distance-squared law to estimate distance from the access point (AP)?
Plotted above are RSSI (Received Signal Strength Indicator) values (vertical axis, in dBm) versus actual distance between smartphone and access point (horizontal axis, in meters) in a typical three level house. The red curve corresponds to the inverse square law — which is clearly not a good fit to the observed signal strength (it does provide an upper bound on signal strength). The green line shows a log-linear fit to the data. It represents an exponential decay of singal with distance with slope a bit over 3 dB per meter. So the observed decay with distance fits that of a signal passing through an absorbing medium. More importantly, the spread in RSSI for a given distance is huge, making inversion to estimate the distance from RSSI ill posed.

Another method exploits the fact that different combinations of signal strengths from several different APs will be found in different locations. This method involves exploring the whole volume to be mapped — and recording the RSSI values for each of the APs in each location. This is an effort that has to be repeated when objects that may affect the RF field are moved. In use, some method is employed to find the location where the recorded RSSIs best match the presently observed RSSIs.

## Channel State Information (CSI)

RSSI provides only one noisy estimate of the state of the channel. In orthogonal frequency-division multiplexing (OFDM) signalling, each subchannel has a state (amplitude and phase) given as a complex nummber. This state has to be estimated for proper decoding of the signal. The estimate is based on the received preamble. In the case of 20 MHz bandwidth, out of 64 subchannels, 52 are used for data, 4 for pilots and 8 are nulled. This means the CSI vector has 56 non-zeor (complex) components, which provide much more information than the single (real) value of RSSI does. Nevertheless, since using CSI requires a fingerprinting approach, it has the same disadvantages as the above. Further, Android does not make physical layer (PHY) information, such as the CSI, accessible to applications.

## WiFi Fine Time Measurement (FTM) Round Trip Time (RTT) for indoor location.

The time a WiFi signal takes to travel in air from a smartphone (“station” - STA) to a WiFi access point (AP) is, of course, proportional to the actual distance between them (about 3.3 nanoseconds per meter). Since the internal clocks in the smartphone and the access points are not synchronized, a one-way time measurement cannot be based on differences between timestamps at the two ends. Fortunately, the difference in timestamps when the signal travels in the reverse direction is affected in the opposite way by the clock offset. As a result, the round trip time (RTT) can be obtained without having to know the clock offsets - by simple addition and subtraction of four times: RTT = (t4-t1 + t2-t3).
(from “How To Achieve 1 Meter Accuracy In Android” by Frank van Diggelen, Roy Want and Wei Wang). Importantly, the second FTM “Ping” from the access point includes the time-of-departure t1 and the time-of-arrival t4 at the access point.

The round trip time measurements are not perfectly accurate, being subject to various types of measurement error, RF interference as well as the positions and motions of objects in the environment. Repeated measurements improve the quality a bit:

(from “How To Achieve 1 Meter Accuracy In Android” by Frank van Diggelen, Roy Want and Wei Wang). Note that the last interchange (“Ping” and “Pong”) is not followed by yet another signal containing t4 and t1, so the round trip time for the last interchange cannot be determined. Hence, with a burst of $$N$$ interchanges, only $$(N-1)$$ round trip times can be determined.

Knowing the round trip times to 3, 4, or more APs in known location allows one to estimate the position of the smartphone given the positions of the APs (Conversely, an AP can be located given round trip times from a smartphone in 3, 4, or more known locations). If neither smartphone nor access point locations are known initially, one can perform simultaneous localization and mapping or SLAM.

The recently agreed upon IEEE 802.11-2016 WiFi standard provides methods for performing such measurements (with an expected accuracy of perhaps a meter or two). The recently released Android Pie (Android 9.0) supports such IEEE 802.11-2016 based RTT measurements (as of API level 28).

This sample screen shot shows floor plans of three levels of a building with six “responders” (APs) shown in green and the estimated position of a smartphone (STA) in red. The “dilution of precision” (noise gain) depends on the positioning of the responders, and varies somewhat troughout the volume (see Placement of Responders).