86 lines
2.2 KiB
C++
86 lines
2.2 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#ifndef WIFIOPTIMIZER_H
|
||
#define WIFIOPTIMIZER_H
|
||
|
||
#include "WiFiFingerprints.h"
|
||
#include "WiFiOptimizerStructs.h"
|
||
#include "../VAPGrouper.h"
|
||
|
||
#include <unordered_map>
|
||
|
||
namespace WiFiOptimizer {
|
||
|
||
enum class Mode {
|
||
FAST,
|
||
MEDIUM,
|
||
QUALITY,
|
||
};
|
||
|
||
|
||
/** base-class for all WiFiOptimizers */
|
||
class Base {
|
||
|
||
protected:
|
||
|
||
/** each MAC-Adress has several position->rssi entries */
|
||
std::unordered_map<MACAddress, std::vector<RSSIatPosition>> apMap;
|
||
|
||
/** how to handle virtual access points [group, not-group, ..] */
|
||
const VAPGrouper vg;
|
||
|
||
public:
|
||
|
||
/** ctor */
|
||
Base(const VAPGrouper vg) : vg(vg) {;}
|
||
|
||
/** get a list of all to-be-optimized access-points (given by their mac-address) */
|
||
virtual std::vector<MACAddress> getAllMACs() const {
|
||
std::vector<MACAddress> res;
|
||
for (const auto& it : apMap) {res.push_back(it.first);}
|
||
return res;
|
||
}
|
||
|
||
/** get all [VAPGrouped, Averaged] fingerprints for the given mac */
|
||
virtual const std::vector<RSSIatPosition>& getFingerprintsFor(const MACAddress& mac) {
|
||
const auto& it = apMap.find(mac);
|
||
if (it == apMap.end()) {throw Exception("mac not found: " + mac.asString());}
|
||
return it->second;
|
||
}
|
||
|
||
/** add a new fingerprint to the optimizer as data-source */
|
||
virtual void addFingerprint(const WiFiFingerprint& fp) {
|
||
|
||
// group the fingerprint's measurements by VAP (if configured)
|
||
const WiFiMeasurements measurements = vg.group(fp.measurements);
|
||
|
||
// add each available AP to its slot (lookup map)
|
||
for (const WiFiMeasurement& m : measurements.entries) {
|
||
const RSSIatPosition rap(fp.pos_m, m.getRSSI());
|
||
apMap[m.getAP().getMAC()].push_back(rap);
|
||
}
|
||
|
||
}
|
||
|
||
/** add new fingerprints to the optimizer as data-source */
|
||
virtual void addFingerprints(const WiFiFingerprints& fps) {
|
||
for (const WiFiFingerprint& fp : fps.getFingerprints()) {
|
||
addFingerprint(fp);
|
||
}
|
||
}
|
||
|
||
};
|
||
|
||
|
||
}
|
||
|
||
#endif // WIFIOPTIMIZER_H
|