added missing code changes

started working on refactoring of sensors
new test-cases
This commit is contained in:
2016-03-17 17:28:41 +01:00
parent 6346231a64
commit f8d7f768f1
18 changed files with 524 additions and 74 deletions

View File

@@ -0,0 +1,35 @@
#ifndef ACCESSPOINT_H
#define ACCESSPOINT_H
#include "../MACAddress.h"
/**
* represents a Wi-Fi-AccessPoint
* an AP is represented by its MAC-Address and
* may provide a readably SSID
*/
class AccessPoint {
public:
/** the AP's MAC-Address */
const MACAddress mac;
/** the AP's readable SSID */
const std::string ssid;
public:
/** ctor */
AccessPoint(const MACAddress& mac, const std::string& ssid) : mac(mac), ssid(ssid) {
;
}
/** ctor */
AccessPoint(const std::string& mac, const std::string& ssid) : mac(mac), ssid(ssid) {
;
}
};
#endif // ACCESSPOINT_H

View File

@@ -0,0 +1,47 @@
#ifndef LOGDISTANCEMODEL_H
#define LOGDISTANCEMODEL_H
#include <cmath>
class LogDistanceModel {
public:
/** convert from RSSI to a distance (in meter) */
static float rssiToDistance(const float txPower, const float pathLoss, const float rssi) {
return pow(10, (txPower - rssi) / (10 * pathLoss));
}
/** convert from a distance (in meter) to the expected RSSI */
static float distanceToRssi(const float txPower, const float pathLoss, const float distance) {
if (distance <= 1) {return txPower;}
return (txPower - (10 * pathLoss * std::log10(distance)));
}
};
#include <vector>
class LogDistFastModel {
private:
std::vector<float> lut;
public:
LogDistFastModel() {
lut.resize(2000);
for (int i = 0; i < 2000; ++i) {
lut[i] = std::log10(i/10.0f);
}
}
float distanceToRssi(const float txPower, const float pathLoss, const float distance) const {
if (distance <= 1) {return txPower;}
return (txPower - (10 * pathLoss * lut[ (int) (distance*10) ]));
}
};
#endif // LOGDISTANCEMODEL_H