Debian Codegraph @

src/bluetooth_data_tools/distance.py

raw symbols SCIP
1 MAX_THEORETICAL_DISTANCE = 400.0
2
3
4 def calculate_distance_meters(power: int, rssi: int) -> float | None:
5 """Calculate the distance in meters between the scanner and the device."""
6 if rssi == 0 or power == 0:
7 return None
8 if (ratio := rssi / power) < 1.0:
9 distance = ratio**10
10 else:
11 distance = 0.89976 * ratio**7.7095 + 0.111
12 return min(MAX_THEORETICAL_DISTANCE, distance)