needed interface changes [new options] logger for android wifi-ap-optimization new test-cases
81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
#ifndef WIFIMODELLOGDIST_H
|
|
#define WIFIMODELLOGDIST_H
|
|
|
|
#include "WiFiModel.h"
|
|
#include "LogDistanceModel.h"
|
|
|
|
/**
|
|
* signal-strength estimation using log-distance model
|
|
*/
|
|
class WiFiModelLogDist : public WiFiModel {
|
|
|
|
public:
|
|
|
|
/** parameters describing one AP to the model */
|
|
struct APEntry {
|
|
|
|
Point3 position_m; // the AP's position (in meter)
|
|
float txp; // sending power (-40)
|
|
float exp; // path-loss-exponent (~2.0 - 4.0)
|
|
|
|
/** ctor */
|
|
APEntry(const Point3 position_m, const float txp, const float exp) :
|
|
position_m(position_m), txp(txp), exp(exp) {;}
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
/** map of all APs (and their parameters) known to the model */
|
|
std::unordered_map<MACAddress, APEntry> accessPoints;
|
|
|
|
public:
|
|
|
|
/** ctor */
|
|
WiFiModelLogDist() {
|
|
;
|
|
}
|
|
|
|
/** get a list of all APs known to the model */
|
|
std::vector<AccessPoint> getAllAPs() const {
|
|
std::vector<AccessPoint> aps;
|
|
for (const auto it : accessPoints) {aps.push_back(AccessPoint(it.first));}
|
|
return aps;
|
|
}
|
|
|
|
/** make the given AP (and its parameters) known to the model */
|
|
void addAP(const MACAddress& accessPoint, const APEntry& params) {
|
|
|
|
// sanity check
|
|
Assert::isBetween(params.txp, -50.0f, -30.0f, "TXP out of bounds [-90:-30]");
|
|
Assert::isBetween(params.exp, 1.0f, 4.0f, "EXP out of bounds [1:4]");
|
|
|
|
// add
|
|
accessPoints.insert( std::pair<MACAddress, APEntry>(accessPoint, params) );
|
|
|
|
}
|
|
|
|
virtual float getRSSI(const MACAddress& accessPoint, const Point3 position_m) const override {
|
|
|
|
// try to get the corresponding parameters
|
|
const auto it = accessPoints.find(accessPoint);
|
|
|
|
// AP unknown? -> NAN
|
|
if (it == accessPoints.end()) {return NAN;}
|
|
|
|
// the access-points' parameters
|
|
const APEntry& params = it->second;
|
|
|
|
// free-space (line-of-sight) RSSI
|
|
const float distance_m = position_m.getDistance(params.position_m);
|
|
const float rssiLOS = LogDistanceModel::distanceToRssi(params.txp, params.exp, distance_m);
|
|
|
|
// done
|
|
return rssiLOS;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // WIFIMODELLOGDIST_H
|