/* * © 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 WIFIMEASUREMENT_H #define WIFIMEASUREMENT_H #include "AccessPoint.h" #include "../../data/Timestamp.h" /** * describes a measurement received for one access-point at a given time */ class WiFiMeasurement { private: friend class VAPGrouper; /** the access-point we got a measurement for */ AccessPoint ap; /** the measured signal strength */ float rssi; /** FTM: estimated distance in m **/ float distance = NAN; /** FTM: standard deviation of estimated distance in m. Only valid if numSuccessfulMeasurements >= 2 **/ float distanceStdDev = NAN; /** FTM: The number of attempted measurements used in the RTT exchange **/ int numAttemptedMeasurements = 0; /** FTM: The number of successful measurements used to calculate the distance and standard deviation **/ int numSuccessfulMeasurements = 0; /** OPTIONAL. frequence the signal was received */ float freq = NAN; /** OPTIONAL. timestamp the measurement was recorded at */ Timestamp ts; public: /** ctor */ WiFiMeasurement(const AccessPoint& ap, const float rssi) : ap(ap), rssi(rssi), freq(NAN) { ; } /** ctor with freq*/ WiFiMeasurement(const AccessPoint& ap, const float rssi, const float freq) : ap(ap), rssi(rssi), freq(freq) { ; } /** ctor with timestamp */ WiFiMeasurement(const AccessPoint& ap, const float rssi, const Timestamp ts) : ap(ap), rssi(rssi), freq(NAN), ts(ts) { ; } /** ctor with timestamp and ftm */ WiFiMeasurement(const AccessPoint& ap, const float rssi, const Timestamp ts, const float distance, const float distanceStdDev, const int numAttemptedMeasurements, const int numSuccessfulMeasurements) : ap(ap), rssi(rssi), freq(NAN), ts(ts), distance(distance), distanceStdDev(distanceStdDev), numAttemptedMeasurements(numAttemptedMeasurements), numSuccessfulMeasurements(numSuccessfulMeasurements) { ; } /** ctor with timestamp and freq*/ WiFiMeasurement(const AccessPoint& ap, const float rssi, const float freq, const Timestamp ts) : ap(ap), rssi(rssi), freq(freq), ts(ts) { ; } public: /** get the AP we got the measurement for */ const AccessPoint& getAP() const {return ap;} /** get the measurement's signal strength */ float getRSSI() const {return rssi;} /** OPTIONAL: get the measurement's timestamp (if known!) */ const Timestamp& getTimestamp() const {return ts;} float getFtmDist() const { return distance; } float getFtmDistStd() const { return distanceStdDev; } int getNumAttemptedMeasurements() const { return numAttemptedMeasurements; } int getNumSuccessfulMeasurements() const { return numSuccessfulMeasurements; } /** timestamp known? */ bool hasTimestamp() const {return ts == ts;} /** OPTIONAL: get the measurement's frequency (if known!) */ float getFrequency() const {return freq;} /** frequency known? */ bool hasFrequency() const {return freq == freq;} /** set another signal strength */ void setRssi(float value){rssi = value;} /** set the timestamp */ void setTimestamp(const Timestamp& val){ts = val;} void setFtmDist(float val) { distance = val; } /** as string for debug printing */ std::string asString() const { std::string res = ap.asString(); if (hasTimestamp()) {res += " @" + std::to_string(ts.ms());} if (hasFrequency()) {res += " " + std::to_string((int)freq) + " MHz";} res += " - " + std::to_string(rssi) + " dBm "; return res; } }; #endif // WIFIMEASUREMENT_H