added measurement grouping for beacons
had to change the parameter boundaries of the wifi optimizer to be able to use it for bluetooth... this should be refactored to something more generic.. some minor changes in ble
This commit is contained in:
@@ -23,88 +23,88 @@ class WiFiModelLogDist : public WiFiModel {
|
||||
|
||||
public:
|
||||
|
||||
/** parameters describing one AP to the model */
|
||||
struct APEntry {
|
||||
/** 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)
|
||||
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) {;}
|
||||
/** 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;
|
||||
/** map of all APs (and their parameters) known to the model */
|
||||
std::unordered_map<MACAddress, APEntry> accessPoints;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
WiFiModelLogDist() {
|
||||
;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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) {
|
||||
/** 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]");
|
||||
// sanity check
|
||||
Assert::isBetween(params.txp, -65.0f, -30.0f, "TXP out of bounds [-65:-30]");
|
||||
Assert::isBetween(params.exp, 1.0f, 5.0f, "EXP out of bounds [1:5]");
|
||||
|
||||
// add
|
||||
accessPoints.insert( std::pair<MACAddress, APEntry>(accessPoint, params) );
|
||||
// add
|
||||
accessPoints.insert( std::pair<MACAddress, APEntry>(accessPoint, params) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** does the model know the given AP? */
|
||||
bool knowsAP(const MACAddress& accessPoint) {
|
||||
/** does the model know the given AP? */
|
||||
bool knowsAP(const MACAddress& accessPoint) {
|
||||
|
||||
// try to get the corresponding parameters
|
||||
const auto it = accessPoints.find(accessPoint);
|
||||
// try to get the corresponding parameters
|
||||
const auto it = accessPoints.find(accessPoint);
|
||||
|
||||
// AP known?
|
||||
return (it != accessPoints.end());
|
||||
// AP known?
|
||||
return (it != accessPoints.end());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
virtual float getRSSI(const MACAddress& accessPoint, const Point3 position_m) const override {
|
||||
virtual float getRSSI(const MACAddress& accessPoint, const Point3 position_m) const override {
|
||||
|
||||
// try to get the corresponding parameters
|
||||
const auto it = accessPoints.find(accessPoint);
|
||||
// try to get the corresponding parameters
|
||||
const auto it = accessPoints.find(accessPoint);
|
||||
|
||||
// AP unknown? -> NAN
|
||||
if (it == accessPoints.end()) {return NAN;}
|
||||
// AP unknown? -> NAN
|
||||
if (it == accessPoints.end()) {return NAN;}
|
||||
|
||||
// the access-points' parameters
|
||||
const APEntry& params = it->second;
|
||||
// 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);
|
||||
// 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;
|
||||
// done
|
||||
return rssiLOS;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void readFromXML(XMLDoc* doc, XMLElem* src) override {
|
||||
throw Exception("not yet implemented");
|
||||
}
|
||||
void readFromXML(XMLDoc* doc, XMLElem* src) override {
|
||||
throw Exception("not yet implemented");
|
||||
}
|
||||
|
||||
void writeToXML(XMLDoc* doc, XMLElem* dst) override {
|
||||
throw Exception("not yet implemented");
|
||||
}
|
||||
void writeToXML(XMLDoc* doc, XMLElem* dst) override {
|
||||
throw Exception("not yet implemented");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user