def testLocationByRSSI(self): location = Point(1, 3) self.assertAlmostEqual( location.distance(self.beacon.location), self.beacon.getDistanceByRSSI(self.beacon.getRSSI(location)), 1, )
def getRSSI( self, location: Point, scale: float = 1, is_wall: bool = False, noise: bool = False, ) -> float: """Calculate RSSI on given location Args: location (Location): scale (float, optional): Floor scale. Defaults to 1. is_wall (bool, optional): Is wall on a way. Defaults to False. noise (bool, optional): Should noise be added to a signal. Defaults to False. Returns: float: RSSI in dB """ # Distance = 10 ^ ((Measured Power — RSSI) / (10 * N)) distance = location.distance(self.location, scale) if is_wall: n = self.n_wall else: n = self.n signal_strength: float = -10 * n * math.log10(distance) + self.rssi_1 if noise: signal_strength += np.random.normal(0, self.noise_var) logging.debug(f"{self} for {location} RSSI: {signal_strength:4.2f}") return signal_strength